EmbarkStudios / crash-handling

Collection of crates to deal with crashes
Apache License 2.0
138 stars 13 forks source link

Interpose pthread_create calls #4

Closed Jake-Shadle closed 2 years ago

Jake-Shadle commented 2 years ago

Firefox does a rather complicated interposition of pthread_create to ensure that the alternate signal stack is always used for every thread, but...I'm not actually 100% sure this is needed.

gabrielesvelto commented 2 years ago

On our side it's needed mainly to catch stack overflows and to guarantee that we can catch other type of crashes even when we're close to the stack limit. Our graphics code has often deep stacks, so even though the code might not overflow the stack directly the exception handler might.

Jake-Shadle commented 2 years ago

Hmm, I suppose my stack overflow tests must be incorrect then since they are catching those cases from main and non-main threads just fine so far, so they must not be complicated enough, or perhaps this is because the alternate stack from the standard library giving a false sense of security.

gabrielesvelto commented 2 years ago

Are you using Rust for the tests? IIRC the Rust runtime adds an alternate signal stack to every thread that's created unless you provide yours.

gabrielesvelto commented 2 years ago

Yeah, it's here.

Jake-Shadle commented 2 years ago

Yes, now that I've directly invoked pthread_create it doesn't work, so fixing now. :slightly_smiling_face: