Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploaded function has a 50/50 chance to succeed. #25

Closed
aksir1987 opened this issue Mar 5, 2019 · 8 comments
Closed

Uploaded function has a 50/50 chance to succeed. #25

aksir1987 opened this issue Mar 5, 2019 · 8 comments

Comments

@aksir1987
Copy link

Hello,

Fantastic sdk and very much needed.

Recently I followed the basic tutorial and run a simple C++ program on aws lambda.

However, it has a 50/50 chance of success, which is very confusing.

It is a simple program with little usage of dynamic memory allocation and only printf and std::string is used from the standard library.

When it failed, it returns
{
"errorMessage": "RequestId: da9a1e36-07cb-45a2-9e4e-db2f80288d11 Process exited before completing request"
}

The printf marks I put there indicates the code went through just fine but it failed to get out of the handler function.

What can be the issue?

Thank you.

@marcomagdy
Copy link
Contributor

Can you provide the code here to reproduce the problem?

@phadej
Copy link

phadej commented Mar 6, 2019

Do you have your lambda's network configured right, if you configure other of your VPC subnets wrong (you need two!) then lambda will work 50% of the time.

@aksir1987
Copy link
Author

aksir1987 commented Mar 8, 2019

Can you provide the code here to reproduce the problem?

The total code is a bit difficult to show here due to the length. Here is the basic content.

Everything inside Cmyclass is standard C++ and thoroughly tested.

invocation_response my_handler(invocation_request const& request)
{

Cmyclass *pmyclass= new Cmyclass;

std::string str  = pmyclass->get_str();

delete pmyclass;

printf("Sucess\n");

return invocation_response::success(str, "application/json");
}

In the test function on the page of aws-lambda, it shows me:

START RequestId: 1b475a69-f9a9-4b13-8b45-aca566c7ecc8 Version: $LATEST
Sucess
[ERROR] [1552062898632] LAMBDA_RUNTIME Failed to get next invocation. No Response from endpoint
END RequestId: 1b475a69-f9a9-4b13-8b45-aca566c7ecc8
REPORT RequestId: 1b475a69-f9a9-4b13-8b45-aca566c7ecc8 Duration: 130.08 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 104 MB
RequestId: 1b475a69-f9a9-4b13-8b45-aca566c7ecc8 Process exited before completing request

So the typoed "Sucess" indicate that the myclass method has gone through with no problem, correct?
What is the problem then?

@aksir1987
Copy link
Author

Do you have your lambda's network configured right, if you configure other of your VPC subnets wrong (you need two!) then lambda will work 50% of the time.

I chose no VPC by default for just trying this. Basically all the configurations are default.

Is one required to run smoothly?

@marcomagdy
Copy link
Contributor

So the typoed "Sucess" indicate that the myclass method has gone through with no problem, correct?

The code you pasted above seems fine.
However, if str was a reference as in std::string& str = pmyclass->get_str(); then that would explain why you're crashing sometimes.

@aksir1987
Copy link
Author

So the typoed "Sucess" indicate that the myclass method has gone through with no problem, correct?

The code you pasted above seems fine.
However, if str was a reference as in std::string& str = pmyclass->get_str(); then that would explain why you're crashing sometimes.

No it is not . get_str() is a std::string get_str() and every time it did print out "Sucess".

@marcomagdy
Copy link
Contributor

I didn't mean the signature of get_str().
I'm saying the variable you're assigning the result of that method to.
std::string& a = p->get_str(); vs std::string b = p->get_str();

In the case of (a) it's a dangling reference if you delete p.
In the case of (b) it's fine.

@aksir1987
Copy link
Author

I didn't mean the signature of get_str().
I'm saying the variable you're assigning the result of that method to.
std::string& a = p->get_str(); vs std::string b = p->get_str();

In the case of (a) it's a dangling reference if you delete p.
In the case of (b) it's fine.

I am pretty sure it is (b). Yet it still crash...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants