-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
crypto.generatePrime seems have much higher priority over than process.exit which results in stuck #56449
Comments
@nodejs/crypto |
The key challenge is that openssl does not implement a standard interrupt for this operation. It does allow passing a callback that can be used to interrupt it but we are not currently using it. A fix would be to implement that callback, have it check for pending exit on each call and have it interrupt the operation to generate/check the primes |
The `generatePrime` and `checkPrime` functions in the `crypto` module are only somewhat interruptible. This change makes it possible to interrupt these more reliably. Note that generating overly large primes can still take a long time and may not be interruptible as this mechanism relies on a callback to check for stopping conditions but OpenSSL may perform a long running operation without calling the callback right away. Fixes: nodejs#56449
Ok, I've got a fix PR here: #56460 ... Note that this only partially addresses the issue as openssl will still become unresponsive when generating overly large primes. The key issue is that the generation method performs a certain amount of work before it invokes the callback we can use to check to see if we should continue. But, for reasonably sized primes, this allows the operation to be more readily interupted. |
The `generatePrime` and `checkPrime` functions in the `crypto` module are only somewhat interruptible. This change makes it possible to interrupt these more reliably. Note that generating overly large primes can still take a long time and may not be interruptible as this mechanism relies on a callback to check for stopping conditions but OpenSSL may perform a long running operation without calling the callback right away. Fixes: nodejs#56449
The `generatePrime` and `checkPrime` functions in the `crypto` module are only somewhat interruptible. This change makes it possible to interrupt these more reliably. Note that generating overly large primes can still take a long time and may not be interruptible as this mechanism relies on a callback to check for stopping conditions but OpenSSL may perform a long running operation without calling the callback right away. Fixes: nodejs#56449
The `generatePrime` and `checkPrime` functions in the `crypto` module are only somewhat interruptible. This change makes it possible to interrupt these more reliably. Note that generating overly large primes can still take a long time and may not be interruptible as this mechanism relies on a callback to check for stopping conditions but OpenSSL may perform a long running operation without calling the callback right away. Fixes: nodejs#56449
The `generatePrime` and `checkPrime` functions in the `crypto` module are only somewhat interruptible. This change makes it possible to interrupt these more reliably. Note that generating overly large primes can still take a long time and may not be interruptible as this mechanism relies on a callback to check for stopping conditions but OpenSSL may perform a long running operation without calling the callback right away. Fixes: nodejs#56449
The `generatePrime` and `checkPrime` functions in the `crypto` module are only somewhat interruptible. This change makes it possible to interrupt these more reliably. Note that generating overly large primes can still take a long time and may not be interruptible as this mechanism relies on a callback to check for stopping conditions but OpenSSL may perform a long running operation without calling the callback right away. Fixes: nodejs#56449
The `generatePrime` and `checkPrime` functions in the `crypto` module are only somewhat interruptible. This change makes it possible to interrupt these more reliably. Note that generating overly large primes can still take a long time and may not be interruptible as this mechanism relies on a callback to check for stopping conditions but OpenSSL may perform a long running operation without calling the callback right away. Fixes: #56449 PR-URL: #56460 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
The `generatePrime` and `checkPrime` functions in the `crypto` module are only somewhat interruptible. This change makes it possible to interrupt these more reliably. Note that generating overly large primes can still take a long time and may not be interruptible as this mechanism relies on a callback to check for stopping conditions but OpenSSL may perform a long running operation without calling the callback right away. Fixes: nodejs#56449 PR-URL: nodejs#56460 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Version
v22.11.0
Platform
Subsystem
crypto
What steps will reproduce the bug?
Setup a node instance,
and run the following javascript code.
The node instance cannot be closed using process.exit() or with double Ctl-C or Ctl-D.
Note that if we don't execute
process.exit()
but run other code, it works.How often does it reproduce? Is there a required condition?
This issue can always be triggered following the steps above.
What is the expected behavior? Why is that the expected behavior?
I don't know if this is a bug.
The documentation of process.exit() says
The process.exit() method instructs Node.js to terminate the process **synchronously**. Calling process.exit() will force the process to exit as quickly as possible even if there are still asynchronous operations pending that have not yet completed fully, including I/O operations to process.stdout and process.stderr.
However, the above code cannot close the node instance immediately, leading to the node server being stuck.
What do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: