caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Heaps size problems with "caml_alloc_small" in foreign function interfaces
@ 2008-07-11  8:21 Sean Seefried
  2008-07-11  9:40 ` [Caml-list] " Richard Jones
  2008-07-11 14:11 ` Xavier Leroy
  0 siblings, 2 replies; 14+ messages in thread
From: Sean Seefried @ 2008-07-11  8:21 UTC (permalink / raw)
  To: caml-list

Hi,

I'm having a problem where sometimes a call to "caml_alloc_small" from  
C results in a segmentation fault. If I increase the size of the stack  
using OCAMLRUNPARAM=s=1000k then I don't get the crash anymore. It  
seems strange that I have to increase the size of the heap manually  
like this. Is this because I'm calling this function from C?

If I want to increase the size of the heap in C how do I do this?  
Could I write a "safe" caml_alloc_small which first checks to see if  
there is enough memory and then increases the heap size if not?

Sean


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [Caml-list] Heaps size problems with "caml_alloc_small" in foreign function interfaces
@ 2008-07-12  6:07 Sean Seefried
  2008-07-12  6:09 ` Sean Seefried
  2008-07-12  8:50 ` Richard Jones
  0 siblings, 2 replies; 14+ messages in thread
From: Sean Seefried @ 2008-07-12  6:07 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1293 bytes --]

Hi Xavier,

Okay, here's some further clarification and this time I'm attaching a  
file. I've had to GZip it because it's so big.

The bug in question occurs on line 4078.

I should clarify. This file becomes part of a library that is linked  
into another OCaml program.  On one input file that this OCaml program  
takes as input it fails on line 4078.  On other files it fails on  
other lines. However, the code it fails at always seems to be of the  
form:

     _v2 = camlidl_alloc_small(18, 0);
     { mlsize_t _c8;
       for (_c8 = 0; _c8 < 18; _c8++) Field(_v2, _c8) = _v3[_c8];
     }

What's strange about this is that this is automatically generated code  
from CamlIDL (with a few extra debugging messages I threw in). Xavier,  
I'm using CamlDL to write a binding to a  C front-end which has an  
absolutely huge C data structure.  I've had to write several  
extensions to CamlIDL to make this a reality, but for the moment I'm  
keeping these in my own source control mainly because your coding  
style is very clean and many of my extensions could have been done a  
lot more elegantly.

However, the code that is being generated above was already generated  
by version 1.05 of CamlIDL.


The file can be found at: http://howe.textdrive.com/~sseefried/files/test.c.gz

Sean

[-- Attachment #2: Type: text/html, Size: 2043 bytes --]

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

end of thread, other threads:[~2008-07-13 14:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-11  8:21 Heaps size problems with "caml_alloc_small" in foreign function interfaces Sean Seefried
2008-07-11  9:40 ` [Caml-list] " Richard Jones
2008-07-11  9:51   ` Richard Jones
2008-07-11 10:21   ` Sean Seefried
2008-07-11 15:56     ` Richard Jones
2008-07-11 14:11 ` Xavier Leroy
2008-07-12  3:20   ` Sean Seefried
2008-07-12  6:00   ` Sean Seefried
2008-07-12  6:07 Sean Seefried
2008-07-12  6:09 ` Sean Seefried
2008-07-12  8:50 ` Richard Jones
2008-07-13 13:25   ` Sean Seefried
2008-07-13 13:37     ` Gordon Henriksen
2008-07-13 14:03     ` Thomas Crimi

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