set_exception_handler not restored if calling exit within itself
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.1k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
Description
What was fixed https://github.com/php/php-src/commit/3301d9602a2307007858c299c41795d3d95e3843 https://github.com/php/php-src/issues/13446#issuecomment-1991549384 bc it was broken from 8.3.0-8.3.4 is still broken if the exception handler itself calls exit.
https://3v4l.org/HkWfh
without exit: https://3v4l.org/FTWQf
The following code:
<?php
declare(strict_types=1);
function foo($e) {
var_dump( set_exception_handler('foo') );
restore_exception_handler();
echo "---" . PHP_EOL;
exit;
}
set_exception_handler('foo');
register_shutdown_function(function () {
var_dump( set_exception_handler(null) );
});
strlen(null);
Resulted in this output:
NULL
---
NULL
But I expected this output instead:
NULL
---
string(3) "foo"
This matters, because since PHP 8.3, the exit code of the exit() call in exception handler is used as exit code of PHP
@iluuu1994
PHP Version
PHP 8.3.0+
Operating System
No response
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il comportamento con lo script PHP fornito e confronta i casi con exit e senza exit degli esempi 3v4l collegati. Traccia l’interazione tra set_exception_handler(), restore_exception_handler(), register_shutdown_function() ed exit nel runtime PHP. Il lavoro è completato quando il callback di shutdown osserva l’handler "foo" ripristinato quando exit viene chiamato all’interno dell’exception handler.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, php
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100