caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Segfault in Garbage collector code: any ideas?
@ 2008-06-19 21:45 Raj Bandyopadhyay
  2008-06-19 21:51 ` [Caml-list] " Mark Shinwell
  0 siblings, 1 reply; 2+ messages in thread
From: Raj Bandyopadhyay @ 2008-06-19 21:45 UTC (permalink / raw)
  To: caml-list

Dear all

I am running a large OCaml application with a C interface, and I get  
a segfault for larger inputs. Since it seemed to be occurring in  
OCaml's garbage collector code, I  recompiled OCaml  with a '-g'  
option  and  used gdb to track  the  source of the segfault. Here's  
what I see in gdb:

<
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0075a000

caml_oldify_mopup () at minor_gc.c:201
201             Field (new_v, i) = f;

(gdb) bt
#0  caml_oldify_mopup () at minor_gc.c:201
#1  0x0011dd14 in caml_empty_minor_heap () at minor_gc.c:221
#2  0x0011de80 in caml_minor_collection () at minor_gc.c:260
#3  0x00122908 in caml_interprete (prog=0x168f0c, prog_size=7708608)  
at interp.c:538
#4  0x001171e8 in caml_callbackN_exn (closure=7602900, narg=1,  
args=0x71d004) at callback.c:82
#5  0x0011723c in caml_callback_exn (closure=7602900, arg1=7708608)  
at callback.c:109
... functions  from  my C code


1) From past  experience, this  sort  of  thing seems  to  occur when  
I forget to use a CAMLparam/local/return  macro somewhere. However, I  
have looked over my C code several times and can't find any such  
problem. Is there any other scenario where this sort of segfault can  
occur?

2) Can those macros be misused, somehow? I have used them in every  
function which is passed or returns or creates a 'value'.

Any suggestions on how I'd go about finding the source of this  
problem would be welcome.

I apologize in advance for lack of specific information about the  
application, I'm not sure what information would be useful. Please  
feel free to email me with any questions or suggestions.

Thank you
Raj


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

* Re: [Caml-list] Segfault in Garbage collector code: any ideas?
  2008-06-19 21:45 Segfault in Garbage collector code: any ideas? Raj Bandyopadhyay
@ 2008-06-19 21:51 ` Mark Shinwell
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Shinwell @ 2008-06-19 21:51 UTC (permalink / raw)
  To: Raj Bandyopadhyay; +Cc: caml-list

On Thu, Jun 19, 2008 at 04:45:27PM -0500, Raj Bandyopadhyay wrote:
> 1) From past  experience, this  sort  of  thing seems  to  occur when  
> I forget to use a CAMLparam/local/return  macro somewhere. However, I  
> have looked over my C code several times and can't find any such  
> problem. Is there any other scenario where this sort of segfault can  
> occur?

One thing worth checking is that you've used a Store_field statement
rather than attempting to use Field (...) as an lvalue.  The latter is
often unsafe (see Rule 6 of "Low-level interface" in the Interfacing C
chapter of the manual).

Mark


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

end of thread, other threads:[~2008-06-19 21:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-19 21:45 Segfault in Garbage collector code: any ideas? Raj Bandyopadhyay
2008-06-19 21:51 ` [Caml-list] " Mark Shinwell

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).