You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was recently developing Rust support for coz since I was curious how it could help us analyze compile times (in rustc and cargo themselves), and in developing Rust support for coz one thing I was initially baffled by was that coz-run programs would always segfault very quickly! Digging in it looked like the first SIGPROF signal was segfaulting on the first stack access.
Rust programs, by default, configure a pretty small sigaltstack for SIGSEGV so they can print "you just overflowed the stack" if the stack was overflowed. It looks like coz's own usage of SA_ONSTACK for SIGPROF causes coz itself to run on the Rust standard library's tiny stack, which immediately stack overflows. For reference the Rust standard library allocates SIGSTKSZ which I think is around 8k, and the stack frame for the first function called by SIGPROF was around 8k, hence the segfault.
I managed to work around this by setting up a much larger sigaltstack whenever coz is used, but I figured it might be good to report this for anyone else who runs into it!
The text was updated successfully, but these errors were encountered:
Thinking on this a bit more, is SA_ONSTACK still needed with the SIGPROF handler? From some local testing if SA_ONSTACK is used but no stack is configured with sigaltstack, I think it just uses the thread's current stack to deliver the signal, which should be appropriate in most cases for libcoz?
I was recently developing Rust support for
coz
since I was curious how it could help us analyze compile times (inrustc
andcargo
themselves), and in developing Rust support forcoz
one thing I was initially baffled by was thatcoz
-run programs would always segfault very quickly! Digging in it looked like the firstSIGPROF
signal was segfaulting on the first stack access.Rust programs, by default, configure a pretty small
sigaltstack
forSIGSEGV
so they can print "you just overflowed the stack" if the stack was overflowed. It looks likecoz
's own usage ofSA_ONSTACK
forSIGPROF
causescoz
itself to run on the Rust standard library's tiny stack, which immediately stack overflows. For reference the Rust standard library allocatesSIGSTKSZ
which I think is around 8k, and the stack frame for the first function called bySIGPROF
was around 8k, hence the segfault.I managed to work around this by setting up a much larger
sigaltstack
whenevercoz
is used, but I figured it might be good to report this for anyone else who runs into it!The text was updated successfully, but these errors were encountered: