From 07edf1161a3312c1814724b1860ccd55ee428da8 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Wed, 30 Oct 2024 23:03:19 -0400 Subject: [PATCH] docs: update to note fixed `IA2_DEFINE_SIGHANDLER` usage `IA2_DEFINE_SIGHANDLER` usage fixed in https://github.com/immunant/dav1d/commit/a3a757fd7451f3edae12a855e41777047b9b3a74. --- docs/compartmentalizing_dav1d.md | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/docs/compartmentalizing_dav1d.md b/docs/compartmentalizing_dav1d.md index 7a96f7b6b..251b02d69 100644 --- a/docs/compartmentalizing_dav1d.md +++ b/docs/compartmentalizing_dav1d.md @@ -284,14 +284,13 @@ use macros like `IA2_IGNORE`, which will work with the A similar things occurs with signal handlers, as they are function pointers passed to `sigaction`. -To fix this, we are supposed to wrap the function pointer in `IA2_SIGHANDLER` -and to call `IA2_DEFINE_SIGHANDLER(signal_handler, PKEY)` +To fix this, we can wrap the function pointer in `IA2_SIGHANDLER` +and call `IA2_DEFINE_SIGHANDLER(signal_handler, PKEY)` with the compartment/pkey that the signal handler should run in. -However, as we'll get to later, this leads to a segfault, -so the installation of the signal handler is skipped entirely, -as the signal handler is not very critical to `dav1d` in the first place. -This is something we should fix, though. - +Importantly, `IA2_DEFINE_SIGHANDLER` must be called outside of any functions. +It defines a function itself, and nested functions aren't allowed in C, +so it must be in the global scope. Otherwise, it will segfault. + #### Rewrites in Macros There are some rewrites that happen in macros, @@ -576,13 +575,3 @@ This can be fixed by using `shared_malloc` from `partition-alloc` instead, but since all of these stack variables in `dav1d` were declared in `main`, we just made them globals instead, where we can use `IA2_SHARED_DATA` to move them into their own shared section. - -### `IA2_DEFINE_SIGHANDLER` - -As mentioned before, calling `IA2_DEFINE_SIGHANDLER` resulted in a segfault. -I haven't figured out exactly why yet, or if I was calling it correctly. -But since the signal handler is not very important in the first place, -we just commented out the whole signal handler installation code -and now `dav1d` just works. - -Fixing this is tracked in [#459](https://github.com/immunant/IA2-Phase2/issues/459).