-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Acquisition of runtime lock #4787
Description
Original bug ID: 4787
Reporter: @mmottl
Status: closed (set by @mshinwell on 2016-12-07T13:27:32Z)
Resolution: won't fix
Priority: normal
Severity: feature
Version: 3.11.0
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @ygrek @glondu @Chris00 @mmottl
Bug description
I have run into a problem that seems extremely hard to fix without support in the runtime, but adding this feature to the OCaml runtime is probably quite easy.
A library I have created bindings for supports callbacks from C, which I would like to pass on to OCaml. The thread executing this callback comes from OCaml, but unfortunately I cannot tell beforehand whether it still holds the OCaml-lock at the time of the callback, because there is a large number of entry points, only some release it, and the thread does not hold information as to from which entry point it was coming from.
caml_leave_blocking_section cannot be called when the runtime lock is still being held (-> deadlock) and not calling it if it isn't (-> race) is also not an option so I am stuck. There is currently no exported functionality in the runtime to discover whether the executing thread holds the runtime lock.
Would it be possible to either support recursive acquisitions of the runtime lock or provide for a way to determine whether the running thread holds it? Thanks!