You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1644 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
OCaml systhread implementation use a code like the following to create new
threads:
try
fn arg; ()
with Thread_exit -> ...
where Thread_exit is an exception hidden from Thread.mli. Thread.exit
implementation is therefore simply:
let exit () = raise Thread_exit
This choices makes really dangerous every "try ... with _ -> ..." usage in
thread code (yes, I know that this is a bad(TM) programming style). I've just
spent a lot of time debugging a problem like this one. Even worst most of the
"with _" weren't in my code but in other ocaml libraries code.
Another problem with this approach is the wrapping of exceptions in other
exception, a commonly used approach (e.g. Pxp_types.At exception of the PXP
parser, but I'm almost sure there is something like that in camlp4 code).
Now, I know that this is not an OCaml bug, but is really annoying for thread
programmers. I'm wondering if there are other possible solutions.
Is it possible to implement the Thread.exit function so that it doesn't raise an
exception but invoke directy pthread_exit and perform the needed clean up?
As a quick fix solution, exporting Thread_exit exception in thread.mli can
permit the programmer to write something like:
try
...
with
| Thread_exit as e -> raise e
| _ -> ...
Thanks in advance,
Cheers
The text was updated successfully, but these errors were encountered:
Original bug ID: 1644
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Stefano Zacchiroli
Version: 3.06
OS: linux
Submission from: n32d125.cs.unibo.it (130.136.32.125)
OCaml systhread implementation use a code like the following to create new
threads:
try
fn arg; ()
with Thread_exit -> ...
where Thread_exit is an exception hidden from Thread.mli. Thread.exit
implementation is therefore simply:
let exit () = raise Thread_exit
This choices makes really dangerous every "try ... with _ -> ..." usage in
thread code (yes, I know that this is a bad(TM) programming style). I've just
spent a lot of time debugging a problem like this one. Even worst most of the
"with _" weren't in my code but in other ocaml libraries code.
Another problem with this approach is the wrapping of exceptions in other
exception, a commonly used approach (e.g. Pxp_types.At exception of the PXP
parser, but I'm almost sure there is something like that in camlp4 code).
Now, I know that this is not an OCaml bug, but is really annoying for thread
programmers. I'm wondering if there are other possible solutions.
Is it possible to implement the Thread.exit function so that it doesn't raise an
exception but invoke directy pthread_exit and perform the needed clean up?
As a quick fix solution, exporting Thread_exit exception in thread.mli can
permit the programmer to write something like:
try
...
with
| Thread_exit as e -> raise e
| _ -> ...
Thanks in advance,
Cheers
The text was updated successfully, but these errors were encountered: