[gambit-list] executable works, loadable module segfaults
mikael.rcv at gmail.com
Fri Sep 28 05:40:18 EDT 2012
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
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?).
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.
Well just a wild guess.
What about adding Lots of debug printf:s in string_to_SCMOBJ as to check
that it produces the right thing.
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()?
That's not the right thing right, you'd want C++' delete or sth..?
Also why is not the string type you use pointered? Please correct me on
2012/9/28 REPLeffect <repleffect at gmail.com>
> I came across a strange behavior with Gambit Scheme on Windows (XP, in
> this case). I wrote a module to convert C++ std::string types to
> Gambit char-strings. I wanted to use that in a loadable module. This
> all works fine on Linux, but I also need to use it on Windows. I'm
> using MinGW's C++ compiler (g++ version 4.6.2 -- which I also used to
> compile Gambit). And I'm still on version 4.6.5 of Gambit Scheme.
> I've attached a zipped tar file with an example (6 files, including a
> build.windows script and a build.linux script).
> When I load the shared module in gsi on Windows XP, it segfaults in
> ___garbage_collect(long) -- I believe it was in the call to
> ___alloc_scmobj. When I load it on Linux it works just fine. The
> executable built by the scripts on both platforms works just fine.
> I would love to know what is causing this. I've spent many hours
> trying to find the source of the problem, and finally narrowed it down
> to this.
> Any help/explanations/suggestions would be much appreciated.
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gambit-list