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
"at_exit" function run twice with cleanup-at-exit runtime option #7796
Comments
Comment author: @xavierleroy It seems that all "at_exit" functions are run TWICE if cleanup-at-exit is set. This is a serious mistake. |
Comment author: @nojb at_exit functions are called from caml_shutdown https://github.com/ocaml/ocaml/blob/trunk/byterun/startup_aux.c#L159 (caml_shutdown is called if cleanup_on_exit is set), but if the program finished normally, they would also have been called via std_exit. |
Comment author: @nojb The change to call at_exit functions from caml_shutdown was thread-related: commit a6cad36
|
Comment author: @xavierleroy I agree that caml_shutdown should run the at-exit functions. This is especially true if the OCaml code is embedded as a library in a larger program. I also think that we should not run the at-exit functions twice, and will propose a GPR for that. |
Comment author: @xavierleroy Proposed fix at #1783 . |
Comment author: @xavierleroy |
Comment author: @xavierleroy Merged #1790 |
Original bug ID: 7796
Reporter: @xavierleroy
Assigned to: @xavierleroy
Status: resolved (set by @xavierleroy on 2018-05-23T17:51:00Z)
Resolution: fixed
Priority: normal
Severity: major
Platform: x86-64
OS: Ubuntu Linux 16.04
Version: 4.07.0+dev/beta2/rc1/rc2
Target version: 4.07.0+dev/beta2/rc1/rc2
Fixed in version: 4.07.0+dev/beta2/rc1/rc2
Category: runtime system and C interface
Related to: #7178 #7253
Monitored by: @nojb @gasche @dbuenzli
Bug description
When "c=1" is put in OCAMLRUNPARAM, text printed to standard output in an at_exit function ends up written twice to standard output.
~/caml/devel$ cat foo.ml
let _ =
at_exit (fun () -> print_endline "\nAll tests succeeded.")
~/caml/devel$ boot/ocamlrun ./ocamlc -I ./stdlib -o foo.byte foo.ml
~/caml/devel$ byterun/ocamlrun foo.byte
All tests succeeded.
~/caml/devel$ OCAMLRUNPARAM=c=1 byterun/ocamlrun foo.byte
All tests succeeded.
All tests succeeded.
~/caml/devel$
Among other ill effects, this causes many tests in the test suite to fail when run with OCAMLRUNPARAM="c=1".
The text was updated successfully, but these errors were encountered: