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

Use libsigchain on Android #1745

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

mikes-lunarg
Copy link
Contributor

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.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 258470.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4846 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4846 failed.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 258985.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4855 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4855 passed.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 267570.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4924 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4924 passed.

@bradgrantham-lunarg bradgrantham-lunarg added the P1 Prevents an important capture from being replayed label Oct 7, 2024
@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 280665.

@mikes-lunarg mikes-lunarg changed the title WIP: Use libsigchain on Android Use libsigchain on Android Oct 17, 2024
@mikes-lunarg mikes-lunarg marked this pull request as ready for review October 17, 2024 15:42
@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5096 running.

@ci-tester-lunarg
Copy link

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__)
Copy link
Contributor

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.

Copy link
Contributor Author

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.
@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 292192.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5254 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5254 passed.

@mikes-lunarg mikes-lunarg merged commit 884fb85 into LunarG:dev Nov 1, 2024
9 checks passed
@mikes-lunarg mikes-lunarg deleted the use_libsigchain_on_android branch November 1, 2024 15:17
sa.sa_flags = SA_SIGINFO;
sigemptyset(&sa.sa_mask);
sa.sa_sigaction = PageGuardExceptionHandler;
static std::jmp_buf abort_env;
Copy link
Contributor

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?

Copy link
Contributor Author

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!

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 Prevents an important capture from being replayed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants