-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Closing UDP socket with abort signal can lead to uncaught exception #46750
Labels
dgram
Issues and PRs related to the dgram subsystem / UDP.
good first issue
Issues that are suitable for first-time contributors.
Comments
VoltrexKeyva
added
the
dgram
Issues and PRs related to the dgram subsystem / UDP.
label
Feb 21, 2023
Should be fixable with this diff: diff --git a/lib/dgram.js b/lib/dgram.js
index 4d87299046d..854fc238066 100644
--- a/lib/dgram.js
+++ b/lib/dgram.js
@@ -139,7 +139,7 @@ function Socket(type, listener) {
const { signal } = options;
validateAbortSignal(signal, 'options.signal');
const onAborted = () => {
- this.close();
+ if (this[kStateSymbol].handle) this.close();
};
if (signal.aborted) {
onAborted(); Pull request welcome. |
bnoordhuis
added
the
good first issue
Issues that are suitable for first-time contributors.
label
Feb 21, 2023
I'll work on this issue. |
vramana
added a commit
to vramana/node
that referenced
this issue
Feb 22, 2023
vramana
added a commit
to vramana/node
that referenced
this issue
Feb 22, 2023
vramana
added a commit
to vramana/node
that referenced
this issue
Feb 23, 2023
nodejs-github-bot
pushed a commit
that referenced
this issue
Feb 25, 2023
Fixes: #46750 PR-URL: #46770 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
targos
pushed a commit
that referenced
this issue
Mar 13, 2023
Fixes: #46750 PR-URL: #46770 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
danielleadams
pushed a commit
that referenced
this issue
Apr 11, 2023
Fixes: #46750 PR-URL: #46770 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
dgram
Issues and PRs related to the dgram subsystem / UDP.
good first issue
Issues that are suitable for first-time contributors.
Version
v18.14.1
Platform
Darwin ***.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
Subsystem
dgram
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
Socket is closed, no errors.
What do you see instead?
Additional information
The code in dgram.js (https://github.com/nodejs/node/blob/main/lib/dgram.js#L148) tries to make
aborting an already-closed socket a no-op. I think what's happening is that
socket.close()
closes the socket but emitting theclose
event happens asynchronously - so it's possibleonAborted
gets run before the event, and tries to close the socket again (which fails).Maybe just add try-catch to
onAborted
, ignoring any exceptions thrown bysocket.close()
?The text was updated successfully, but these errors were encountered: