-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
add missing sigemptyset() to init sigset_t #29554
base: main
Are you sure you want to change the base?
Conversation
If that's the case, shouldn't we be removing the |
In |
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.) |
I was refering to the book "The Linux programming interface". Relevent quotes:
|
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. |
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 |
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. |
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. |
I would say finally let s go with memset + sigemptyset @bnoordhuis made a valid point. |
src/node.cc
Outdated
@@ -176,6 +176,8 @@ void WaitForInspectorDisconnect(Environment* env) { | |||
#if defined(__POSIX__) && !defined(NODE_SHARED_MODE) | |||
struct sigaction act; | |||
memset(&act, 0, sizeof(act)); | |||
sigemptyset(&act.sa_mask); | |||
act.sa_flags = 0; |
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.
Explicitly zeroing the sa_flags
field isn't necessary with the memset() back.
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.
But indicates that we haven't forgotten about it / reminds reader about this field. Should I remove it?
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's superfluous so yes please.
@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
905dcc9
Compare
8ae28ff
to
2935f72
Compare
@mcpiroman Can you rebase again please? |
heya @mcpiroman, any chance you'd be able to address the above requests? Would love to get this merged if possible. |
@bnb Not soon, at best after 3 weeks. But github now allows 'changes from the maintainers' so trival changes you may attempt to do yourself. |
905dcc9
to
5c29eda
Compare
@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. |
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 f9c16b8...905dcc9. |
sigfillset(&sa.sa_mask); | ||
sa.sa_flags = reset_handler ? SA_RESETHAND : 0; |
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.
Could you please clarify why it's moved below sigfillset
?
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesThis conforms to posix saying that
sigset_t
cannot be initialized throughmemset
but rathersigemptyset()
orsigfillset()