-
-
Notifications
You must be signed in to change notification settings - Fork 192
fix: more defensive auto thread stack guarantee #1196
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
Conversation
… since all come directly from kernel32 which guaranteed to be loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some first nitpicks/typos/questions
@stima, I just wanted to ping you with the soon-to-be-released approach regarding the previous conversations. In particular, this last comment also led to the current reasoning: #1049 (comment). In your scenario, you could leave the auto-init enabled to cover the trivial threads and only manually set the threads you know might be excluded anyway (or not assign a guarantee for those). @pcorbineau, @robert-jamieson, and @MaxLeb: I will release this next week as a fix. If you have time to try out the PR, feedback would be welcome. The primary concern is that no stack overflow happens in your current setup without additional configuration. Of course, I would also be happy to know if the exposed parameters make sense to you. In your scenario, at least based on what I gathered from your previous feedback, you could reduce the handler stack size to 32KiB and only require a factor of two. Of course, this may not be enough for these threads in all cases, so if overflows from these threads (however unlikely) aren't actionable due to missing symbols, you can leave it at the defaults, which won't set any guarantees for nVidia's driver threads. |
Thank you. We did the tests:
|
Thanks a lot for the feedback!
Great!
The default settings should work well for you, too. The parameterization is primarily there if you see an issue with the particular threads not being "covered" or if you own such a thread and have detailed stack usage bounds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
expose handler stack size as first step where applicable.
4f60d29
to
f43da87
Compare
This builds on top of #1049, provides a fix for #1193, and adds further parameterization for users who want to tune this to their use cases.
The PR does the following
SENTRY_HANDLER_STACK_SIZE
that sets the required stack size for the handler (for Linux/macOS usinginproc
and Windows using any backend, it defaults to 64KiB, which is also the current default).SENTRY_THREAD_STACK_GUARANTEE_FACTOR
which is the factor that the stack reserve of a given thread must at least be larger than the specifiedSENTRY_HANDLER_STACK_SIZE
to ask for a guarantee (only Windows, defaults to 10x).SENTRY_THREAD_STACK_GUARANTEE_AUTO_INIT
that toggles between turning on and off auto-initialization of the thread stack guarantee for each thread after the sentry library has been loaded (if building as a dynamic library). This option only initializes the thread that callssentry_init()
when doing a static build (only Windows, defaults toOn
).SENTRY_THREAD_STACK_GUARANTEE_VERBOSE_LOG
that toggles between turning on and offINFO
level logging of successful setting of thread stack guarantees (only Windows, defaults toOff
).sentry_set_thread_stack_guarantee()
) to allow users to set the stack guarantee for each thread manually if the auto-initialization doesn't behave as the use case requires itif a thread doesn't have at least
SENTRY_HANDLER_STACK_SIZE x SENTRY_THREAD_STACK_GUARANTEE_FACTOR
of stack reserve, we won't request a guarantee from that thread.Reasoning