add missing sigemptyset() to init sigset_t#29554
add missing sigemptyset() to init sigset_t#29554mcpiroman wants to merge 1 commit intonodejs:mainfrom
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
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?
There was a problem hiding this comment.
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? |
|
@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. |
| 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?
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesThis conforms to posix saying that
sigset_tcannot be initialized throughmemsetbut rathersigemptyset()orsigfillset()