Skip to content

Update crash handler behavior to opt-in#484

Merged
waahm7 merged 11 commits intomainfrom
opt-in-crash-handler
Jul 6, 2023
Merged

Update crash handler behavior to opt-in#484
waahm7 merged 11 commits intomainfrom
opt-in-crash-handler

Conversation

@waahm7
Copy link
Copy Markdown
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
Comment thread awscrt/common.py Outdated
Comment thread source/module.c Outdated

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
Copy Markdown
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");

Comment thread source/module.c
/* 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
Copy Markdown
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

Comment thread README.md Outdated
waahm7 and others added 2 commits July 5, 2023 11:26
@waahm7 waahm7 merged commit f7451c0 into main Jul 6, 2023
@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.

2 participants