Skip to content
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

Add pthread_create interpose #8

Merged
merged 12 commits into from Mar 17, 2022
Merged

Add pthread_create interpose #8

merged 12 commits into from Mar 17, 2022

Conversation

Jake-Shadle
Copy link
Member

@Jake-Shadle Jake-Shadle commented Mar 16, 2022

  • Move debug_print out of unix
  • Cleanup docs
  • Use upstreams
  • Intercept pthread_create

This ports the code from https://hg.mozilla.org/mozilla-central/file/3cf2b111807aec49c54bc958771177d33925aace/toolkit/crashreporter/pthread_create_interposer/pthread_create_interposer.cpp so that pthread_create always installs an alternate signal stack, regardless of whether the thread is created in Rust or from C/C++ (barring shenanigans).

This works in glibc, but not musl, so will have to tackle that another time.

Resolves: #4

@Jake-Shadle
Copy link
Member Author

I went down a rabbit hole due to https://github.com/criblio/appscope/blob/15fdf115874731d86f84105b128f86f4afa0f67d/src/fn.c#L14-L84 but never got it working, but looking at the musl source, the implementation is in __pthread_create with the same signature...so I cheated.

This intercepts pthread_create to ensure an alternate signal stack is
always installed to ensure that stack overflows can always be caught no
matter if the thread is created via Rust's std::Thread or otherwise
@Jake-Shadle Jake-Shadle merged commit 82f76f7 into main Mar 17, 2022
@Jake-Shadle Jake-Shadle deleted the ptrace-intercept branch March 17, 2022 06: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.

Interpose pthread_create calls
1 participant