Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
add missing sigemptyset() to init sigset_t#29554
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Conversation
mcpiroman commented Sep 14, 2019 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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 |
devnexen commented Sep 16, 2019 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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. |
src/node.cc Outdated
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.
addaleax commented Nov 30, 2019
@mcpiroman This needs to be rebased against Node.js master |
BridgeAR commented Jan 12, 2020 • edited by aduh95
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by aduh95
Uh oh!
There was an error while loading. Please reload this page.
@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? |
mcpiroman commented Jan 17, 2022
@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 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. |
aduh95 commented Mar 7, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
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_tcannot be initialized throughmemsetbut rathersigemptyset()orsigfillset()