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

Update crash handler behavior to opt-in #484

Merged
merged 11 commits into from
Jul 6, 2023
Merged

Update crash handler behavior to opt-in #484

merged 11 commits into from
Jul 6, 2023

Conversation

waahm7
Copy link
Contributor

@waahm7 waahm7 commented Jun 29, 2023

Description of changes:
Our current crash handler unintentionally catches crashes from other Python libraries that utilize native code. The stacktrace dumped by the crash handler makes it look like our fault as it contains PyInt_init calls at the top of the stack trace. These calls, in reality, are simply function calls made to print the stack trace and printed as PyInt_init in release mode. To address this, this PR alters the crash handler to be an opt-in feature, disabling its automatic registration. Users can enable the crash handler by setting an env variable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@waahm7 waahm7 changed the title Update crash handler behavior to Opt-in Update crash handler behavior to opt-in Jun 29, 2023
@waahm7 waahm7 marked this pull request as ready for review June 29, 2023 21:08
awscrt/common.py Outdated Show resolved Hide resolved
source/module.c Outdated
@@ -804,6 +804,7 @@ static PyMethodDef s_module_methods[] = {

static const char s_module_name[] = "_awscrt";
PyDoc_STRVAR(s_module_doc, "C extension for binding AWS implementations of MQTT, HTTP, and friends");
AWS_STATIC_STRING_FROM_LITERAL(s_crash_handler_env_var, "AWS_CRT_ENABLE_CRASH_HANDLER");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debatable: shorter name, similar to pre-existing "AWS_CRT_MEMORY_TRACING"?

Suggested change
AWS_STATIC_STRING_FROM_LITERAL(s_crash_handler_env_var, "AWS_CRT_ENABLE_CRASH_HANDLER");
AWS_STATIC_STRING_FROM_LITERAL(s_crash_handler_env_var, "AWS_CRT_CRASH_HANDLER");


/* Don't report this memory when dumping possible leaks. */
struct aws_allocator *nontracing_allocator = aws_default_allocator();

struct aws_string *crash_handler_env = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking of "AWS_CRT_MEMORY_TRACING", we have a hack so that it's always turned on when tests run. let's do the same thing and always turn on the crash handler

README.md Outdated Show resolved Hide resolved
waahm7 and others added 2 commits July 5, 2023 11:26
Co-authored-by: Michael Graeb <graebm@amazon.com>
@waahm7 waahm7 merged commit f7451c0 into main Jul 6, 2023
64 checks passed
@waahm7 waahm7 deleted the opt-in-crash-handler branch July 6, 2023 00:42
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

Successfully merging this pull request may close these issues.

None yet

2 participants