-
Notifications
You must be signed in to change notification settings - Fork 105
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
Function crash details not reported #323
Comments
Hello, This If you compile on Apple Silicon machines (M1 or newer), be sure to create a Lamdda function that runs on on If you use SAM to deploy, there is a a one-line code change in your SAM template :
If you created your function in the AWS console, there is a similar parameter you can set at function creation time. |
Hi Sébastien, Thanks for replying. I don’t think that is it, the architecture do match, and the lambda is working fine most of the time. However, I do have a race condition or logic error that makes it crash from time to time, and I can’t get any information or stack trace on the AWS console (other than the illegal instruction message). Since I can’t reproduce locally, it is a pain to debug, and I’m trying to figure out if there is any way to get the stack trace of the crash. Thanks for your time! Max. |
@DCVortexxx You're saying that the error is intermitent, and most of the time, it works. That rules out an Architecture mismatch. You can try to set the environemnt variable LOG_LEVEL=trace in the Lambda environment. The runtime will produce more tracing, maybe the cause will be visible there. Otherwise, we will need to modify the error handling to produce more verbose output in case of a runtime crash |
Hello @sebsto, and thanks for your reply. Unfortunately, setting It is mentioned in the lifecycle management section of the README that:
What I would expect (or like) is when such a signal is captured, the SDK would provide the developer with sufficient informations about what happened, to fix his own issue. However, I'm not fully sure how signal trapping works and maybe what I'm asking is impossible. On a side note, I've added (a lot of) logs in my own function as well to help me debug, and I managed to pinpoint the location of the crash. |
I'm not sure it's possible to print a stacktrace when the binary is compiled in release mode. Binaries typically crash with EXC_BAD_ACCESS error and nothing more. Can you reproduce the crash when executing locally in DEBUG mode ? Another debug strategy I often use is to capture the raw event (as string) passed to the runtime. Setting LOG_LEVEL=trace should allow you to capture the raw JSON. Then I verify if the JSON can be decoded by the corresponding Lambda Event struct. Anyway, we're on the verge to rewrite the Lambda runtime to accommodate for Swift 6 strict concurrent and Service lifecycle. I suggest to not change anything related to signal handling in this version but rather take this feedback into consideration for v2. @fabianfett wdyt ? |
That makes sense indeed.
No I did not manage to reproduce it in debug, but given my logs in production, it happens ~0.05% of the time.
Yeah, all good on that side, there's nothing distinctive about the event that could explain it. I managed to narrow it down to a call to This call is wrapped in a
That definitely makes sense. |
Hello @DCVortexxx |
Expected behavior
When a function crashes for an unexpected reason (
fatalError
, memory corruption...), the stack trace and details of the error are not stored/logged/reported to CloudWatch.I'm fairly new to server-side Swift and AWS in general, so if I'm missing something, feel free to point it out. 🙏
Actual behavior
I would like to have some more informations about the crash, in order to debug and fix crashes in my lambda.
The only details I can see in CloudWatch when my function crashes are:
Steps to reproduce
fatalError
for instance)If possible, minimal yet complete reproducer code (or URL to code)
You can simply use the
ErrorHandling
example from this repository.Send a
.fatal
request, causing a crash.What version of this project (
swift-aws-lambda-runtime
) are you using?1.0.0-alpha
Swift version
The lambda is archived in a docker container using the image swift:5.9.0-amazonlinux2, on the
ubuntu-latest
runner (x86_64 architecture).Amazon Linux 2 docker image version
swift:5.9.0-amazonlinux2
The text was updated successfully, but these errors were encountered: