caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Heap corruption in C binding when callback raises exception
@ 2017-01-18 10:15 Richard W.M. Jones
  2017-01-18 10:21 ` Richard W.M. Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Richard W.M. Jones @ 2017-01-18 10:15 UTC (permalink / raw)
  To: caml-list


https://github.com/libguestfs/libguestfs/blob/master/mllib/visit-c.c

This code wraps a C function which recurses over a directory
structure, calling back into OCaml code for every file seen.

If the OCaml callback raises an exception then it's supposed to stop
the recursion and re-raise the exception in the main function.

This all works fine except when the OCaml callback raises an exception
on aarch64 (not x86_64).  The exception is re-raised fine, but a
subsequent call to Gc.compact dies in caml_oldify_local_roots.
Presumably something corrupts the local roots in some way (the stack
trace in gdb is unfortunately quite useless).

Can someone see what I'm doing wrong in the exception catching /
re-raising code or elsewhere?

The C function and callback are defined here:
https://github.com/libguestfs/libguestfs/blob/master/cat/visit.h

Rich.

-- 
Richard Jones

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Heap corruption in C binding when callback raises exception
  2017-01-18 10:15 [Caml-list] Heap corruption in C binding when callback raises exception Richard W.M. Jones
@ 2017-01-18 10:21 ` Richard W.M. Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Richard W.M. Jones @ 2017-01-18 10:21 UTC (permalink / raw)
  To: caml-list

On Wed, Jan 18, 2017 at 10:15:33AM +0000, Richard W.M. Jones wrote:
> 
> https://github.com/libguestfs/libguestfs/blob/master/mllib/visit-c.c

Bleah, of course it's the "naked" call to return -1 in the
callback function :-(

Rich.

-- 
Richard Jones

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-18 10:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 10:15 [Caml-list] Heap corruption in C binding when callback raises exception Richard W.M. Jones
2017-01-18 10:21 ` Richard W.M. Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).