Uh oh!
There was an error while loading. Please reload this page.
add missing sigemptyset() to init sigset_t - #29554
Conversation
mscdex
commented
Sep 14, 2019
If that's the case, shouldn't we be removing the |
mcpiroman
commented
Sep 14, 2019
In |
bnoordhuis
commented
Sep 15, 2019
Where in the spec does it say that? Leaving out the memset() leaves other fields uninitialized. That's probably going to cause trouble sooner or later. (I fixed a bug to that effect years ago but I can't find the commit anymore.) |
mcpiroman
commented
Sep 15, 2019
I was refering to the book "The Linux programming interface". Relevent quotes:
|
bnoordhuis
commented
Sep 16, 2019
Ah, okay. I wouldn't equate TLPI with POSIX but POSIX.2008 mentions that:
So okay, from a correctness perspective, sigemptyset() is an improvement over memset(). This however:
Assumes that |
That is pretty unusual honestly, seems "overdoing" to me, but I won't argue if it gets the upper vote. |
bnoordhuis
commented
Sep 16, 2019
The same can be said about changing memset() to sigemptyset(). There's no platform we support where it makes a functional difference. Not properly initializing all |
mcpiroman
commented
Sep 16, 2019
If it contains additional fields, then how do you know that 0 is the right value for them? Unless posix says to initialize them to 0 if not used, then such implementation would be non-conformant. However I'll restore
We support right now + implementations are free to change this (not that it's very likely but save than sorry story).
Actually TLPI just quotes sus so ~ posix. |
bnoordhuis
commented
Sep 16, 2019
I'd say the odds are > 50% that 0 is more likely to do the right thing than whatever random value is on the stack at the time of the call. :-) If nothing else, it stops tools like valgrind from overzealously complaining about uninitialized padding. |
devnexen
commented
Sep 16, 2019
I would say finally let s go with memset + sigemptyset @bnoordhuis made a valid point. |
There was a problem hiding this comment.
Explicitly zeroing the sa_flags field isn't necessary with the memset() back.
There was a problem hiding this comment.
But indicates that we haven't forgotten about it / reminds reader about this field. Should I remove it?
addaleax
commented
Nov 30, 2019
@mcpiroman This needs to be rebased against Node.js master |
@mcpiroman would you be so kind and rebase and force push instead of merging? Our CI does not work otherwise. You can do that along of these commands:
|
1cf5dcc to
905dcc9Compare8ae28ff to
2935f72Compareaduh95
commented
Oct 19, 2020
@mcpiroman Can you rebase again please? |
905dcc9 to
5c29edaComparenodejs-github-bot
commented
Feb 11, 2022
aduh95
commented
Feb 19, 2022
@mcpiroman can you have a look to make sure the rebase I made aligns with what you had in mind for this PR? I'd like to have at least another pair of eyes validating the code before merging in case I made a mistake. |
mcpiroman
commented
Mar 7, 2022
Otherwise LGTM, though I it looks like force push covered my original commit and I don't remember that closely how it looked. |
Your original commits were f9c16b87eff60858efa0b6977fa1d253be538589...905dcc90a7e5e9cad3cf8db72bfcede4ba66e975. |
| sa.sa_sigaction = handler; | ||
| sa.sa_flags = reset_handler ? SA_RESETHAND : 0; | ||
| sigfillset(&sa.sa_mask); | ||
| sa.sa_flags = reset_handler ? SA_RESETHAND : 0; |
There was a problem hiding this comment.
Could you please clarify why it's moved below sigfillset?
This pull request has been marked as stale due to 90 days of inactivity. |
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesThis conforms to posix saying that
sigset_tcannot be initialized throughmemsetbut rathersigemptyset()orsigfillset()