On Mon, 10 Oct 2022 04:43:03 GMT, David Holmes <dhol...@openjdk.org> wrote:

>> No, don't do this.  The code is just wrong, and should be fixed.
>> 
>> We have a struct sigaction.  We've set the sa_flags member to a value that
>> includes SA_SIGINFO.  That means the 3 argument sa_sigaction handler is
>> supposed to be invoked.
>> 
>> We're storing the SR_handler (cast to a value matching the type of the
>> sa_handler member of the sigaction). This is "working" purely by accident.
>> Apparently on all POSIX platforms we support, the sa_handler and sa_sigaction
>> occupy the same memory (being in a union, which is permitted by the spec).
>> 
>> The signature for SR_handler should be changed from
>> void SR_handler(int, siginfo_t*, ucontext_t*)
>> to
>> void SR_handler(int, siginfo_t*, void*)
>> and adjust the code to deal with the change to the type of the 3rd parameter.
>> 
>> Then we can just assign the sa_sigaction member to SR_handler without any 
>> casts.
>
> But this is how POSIX specifies it: `sigaction.sa_handler` is declared as 
> `void(*) (int)` - so that is what we have to use when storing the handler 
> address. But the handler itself has to be the three arg version because that 
> is how it will be called.

Oh! Sorry I wasn't reading the `sigaction` definition properly I missed it 
contains two "handler" slots and we are using the wrong one!

-------------

PR: https://git.openjdk.org/jdk/pull/10494

Reply via email to