-
Notifications
You must be signed in to change notification settings - Fork 53
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
Avoid subtract with overflow when growing the stack on musl libc #51
base: master
Are you sure you want to change the base?
Conversation
Hm, this calculation wrapping would suggest that the stack has already overflowed, and in turn that: a) the stack, for some reason, hasn't guard pages (or they aren't being hit); I… think. Making this change doesn't necessarily look too wrong to me, but I feel that returning a |
This is my concern as well. Can I provide anything else that might be useful from the program execution to help determine this? For example, would find a |
Most helpful would probably be printing out the values for |
I’m experiencing this bug when building deno on Alpine Linux. |
@jirutka anyway you could attach a debugger to the failing binary and poke around what are the values of limit and |
|
I’ve tried to build it with the fallback variant of |
Yeah, disabling |
build.rs of So this is not an issue of stacker, the stack has already overflowed in the recursive code from My workaround is creating a new thread with 8MB stack. https://github.com/12101111/overlay/blob/master/dev-lang/deno/files/stacker.patch |
Is it known why the guard page was not hit on function entry? Is it that stack probes do not exist/work on musl? Or is it that musl systems don’t guard their stack with a guard page? |
@richfelker do you know why this would happen? |
I would guess there's code that's assuming the value returned by Note that the value glibc is returning is not reliable; it's possible to crash before that (under memory pressure) or that it's inaccurate due to change in rlimit after process image start. For example, if stack rlimit was 1M at exec time, but was later increased to 8M before calling I'm not sure how to best fix this. It's a messy area where exiting practice was rather broken, |
@12101111, I used your patches (thanks a lot for your insight!), the trick with the runtime build script helped and most of the tests passed. However, (only) the following tests (out of 1289) panicked on overflow from stacker:
Then I rebuilt it again with your patches and my patch disabling |
Hello,
I have noticed on Alpine Linux 3.13.2 with musl libc 1.2.2-r0 that I can reliably trigger a runtime panic in this crate when growing the stack while deserializing a JSON structure with
serde_stacker
. Relevant backtrace snippet is as follows:This PR updates the
remaining_stack()
method to simply returnNone
in the event thatcurrent_stack_ptr() < get_stack_limit()
.All of the included tests pass locally for me, and the panic no longer manifests with my patched copy of
stacker
, but I'm not sure if this is the right way to solve this problem. As such, please feel free to treat this PR as informational.