garrigue / lablgtk

LablGTK 2 and 3: an interface to the GIMP Tool Kit
https://garrigue.github.io/lablgtk
Other
89 stars 40 forks source link

On MacOS, lablgtk2 runs OCaml code inside a blocking section, causing a crash in caml_memprof_handle_postponed_exn #141

Closed btj closed 2 years ago

btj commented 2 years ago

Since recently, I am seeing my VeriFast application (using lablgtk2) crash sometimes on MacOS in caml_memprof_handle_postponed_exn. See https://github.com/verifast/verifast/issues/252 .

The chain of events is as follows:

So, while I believe lablgtk is not "to blame" for this bug, any help or advice would of course be appreciated.

One (hacky) solution would be to add code to marshal to check if we are in a blocking section and, if so, temporarily exit it. Would that make sense?

I am curious as to why I am seeing these crashes only now. One recent change is that I recently switched from OCaml 4.6 to OCaml 4.13. Perhaps 4.13 is more sensitive to calling into OCaml while inside a blocking section?

btj commented 2 years ago

I just realized that this bug could cause not just crashes, but data races as well, in multithreaded programs. (VeriFast is not multithreaded but there may be multithreaded lablgtk2 apps out there.)