What inspired you to the particular design of string_to_SCMOBJ (things like ___CTOS_HEAP_OVERFLOW_ERR+arg_num;)?<br><br><div class="gmail_quote">2012/9/28 Mikael <span dir="ltr"><<a href="mailto:mikael.rcv@gmail.com" target="_blank">mikael.rcv@gmail.com</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Just to start, are you sure that when you return that string, that it remains on the C heap somewhere all until your string_to_SCMOBJ procedure digests it?<div>

<br></div><div>I mean, if it's on the stack, then probably it's overwritten by the subsequent C procedure call to string_to_SCMOBJ, which consumes stack space (the unsigned int and ___SCMOBJ in string_to_SCMOBJ should take the first positions of stack space that f1b_hello previously occupied, and thus destroy the structure?).</div>


<div><br></div><div>If it had been a char* constant you had returned instead, I suppose the C compiler would have put it in some separate, reserved area.</div><div><br></div><div>Well just a wild guess.</div><div><br></div>


<div><br></div><div>What about adding Lots of debug printf:s in string_to_SCMOBJ as to check that it produces the right thing.</div><div><br></div><div><br></div><div>Last, in your type definition (c-define-type string "string" "string_to_SCMOBJ" "SCMOBJ_to_string" #f) you use #f for release function i.e. afaik free()?</div>


<div><br></div><div>That's not the right thing right, you'd want C++' delete or sth..?</div><div><br></div><div>Also why is not the string type you use pointered? Please correct me on this one.</div><div><br>

</div>
<div>Brgds</div><div><br><div class="gmail_quote">2012/9/28 REPLeffect <span dir="ltr"><<a href="mailto:repleffect@gmail.com" target="_blank">repleffect@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div class="h5">
I came across a strange behavior with Gambit Scheme on Windows (XP, in<br>
this case).  I wrote a module to convert C++ std::string types to<br>
Gambit char-strings.  I wanted to use that in a loadable module.  This<br>
all works fine on Linux, but I also need to use it on Windows.  I'm<br>
using MinGW's C++ compiler (g++ version 4.6.2 -- which I also used to<br>
compile Gambit).  And I'm still on version 4.6.5 of Gambit Scheme.<br>
<br>
I've attached a zipped tar file with an example (6 files, including a<br>
build.windows script and a build.linux script).<br>
<br>
When I load the shared module in gsi on Windows XP, it segfaults in<br>
___garbage_collect(long) -- I believe it was in the call to<br>
___alloc_scmobj.  When I load it on Linux it works just fine.  The<br>
executable built by the scripts on both platforms works just fine.<br>
<br>
I would love to know what is causing this.  I've spent many hours<br>
trying to find the source of the problem, and finally narrowed it down<br>
to this.<br>
<br>
Any help/explanations/suggestions would be much appreciated.<br>
<span><font color="#888888"><br>
repleffect<br>
</font></span><br></div></div>_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca" target="_blank">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br>