-
Notifications
You must be signed in to change notification settings - Fork 123
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
Use libsigchain on Android #1745
Use libsigchain on Android #1745
Conversation
CI gfxreconstruct build queued with queue ID 258470. |
CI gfxreconstruct build # 4846 running. |
CI gfxreconstruct build # 4846 failed. |
CI gfxreconstruct build queued with queue ID 258985. |
CI gfxreconstruct build # 4855 running. |
CI gfxreconstruct build # 4855 passed. |
2b90ddf
to
1d977e5
Compare
CI gfxreconstruct build queued with queue ID 267570. |
CI gfxreconstruct build # 4924 running. |
CI gfxreconstruct build # 4924 passed. |
1d977e5
to
3f56ae5
Compare
CI gfxreconstruct build queued with queue ID 280665. |
CI gfxreconstruct build # 5096 running. |
CI gfxreconstruct build # 5096 passed. |
@@ -341,6 +358,9 @@ bool PageGuardManager::CheckSignalHandler() | |||
void* PageGuardManager::SignalHandlerWatcher(void* args) | |||
{ | |||
while (instance_->enable_signal_handler_watcher_ && | |||
#if defined(__ANDROID__) |
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.
I'd love later for this#if/#endif inside the condition of a while to be broken out somehow, maybe a convenience function or a lambda defined before the while. But that shouldn't gate this.
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.
What if I made libsigchain_active_
always a member of PageGuardManager
on all platforms? That would remove some of the sketchier #ifdefs where I break up the while
or play games with braces
Install page guard signal handler using AddSpecialSignalHandlerFn from the libsigchain in the Android runtime. This prevents traced applications from replacing our signal handler when they try to install thier own signal handlers with sigaction. This is implicitly enabled when using page_guard on Android and falls back to sigaction if libsigchain isn't found or the add call fails. If the signal handler watcher is enabled, the watcher thread will exit as soon as our handler is successfully added with libsigchain.
3f56ae5
to
5007fab
Compare
CI gfxreconstruct build queued with queue ID 292192. |
CI gfxreconstruct build # 5254 running. |
CI gfxreconstruct build # 5254 passed. |
sa.sa_flags = SA_SIGINFO; | ||
sigemptyset(&sa.sa_mask); | ||
sa.sa_sigaction = PageGuardExceptionHandler; | ||
static std::jmp_buf abort_env; |
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.
why is this abort_env static? Seems to only be used while this function is active, no?
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.
It is referenced in the sa_sigaction
callback so it needs a static lifetime. I could have also made it a global variable, but as you say, it only gets used in this function. If there is a better way to pass abort_env
to the SIGABRT
handler I would love to know!
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.
ah, I see it is to make the lambda assigned to sa_sigaction to be stateless, so it can be assigned to a function pointer.
Thanks for the explanation :-)
No, I'm not aware of a better way to pass an value to a signal handler.
Install page guard signal handler using AddSpecialSignalHandlerFn from the libsigchain in the Android runtime. This prevents traced applications from replacing our signal handler when they try to install thier own signal handlers with sigaction.