[cffi-devel] Interface problem in LispWorks but not in SBCL

Sascha Van Cauwelaert sascha.vancauwelaert at gmail.com
Wed Nov 23 15:20:51 UTC 2011


Thank you for your answer.

Actually, I have an additional clue, which make me think that it is not related with garbage collection. If, in Lispworks,  I use a wrapped function on the pointer to the C object (e.g. to get the arity), it works fine ! 

It seems that I just can't call a function which print some information about the object in a C++ function, wrapped to be used in LispWorks ... If I do it, I get the error :

lispworks-personal-6-0-1-macos-universal(49641,0xb0314000) malloc: *** error for object 0x17bfc0f8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

I don't get how it can work in SBCL and not in LispWorks, and I have no clue because I don't know the internal implementation of LispWorks.

I would really appreciate a little bit of your help.

Regards,

Sascha Van Cauwelaert


Le 22 nov. 2011 à 21:16, Martin Simmons a écrit :

>>>>>> On Mon, 21 Nov 2011 10:28:56 +0100, Sascha Van Cauwelaert said:
>> 
>> Hello everybody,
>> 
>> I am using SWIG to generate CFFI code to be used into LispWorks 6. The
>> interface is between C++ and Common Lisp. Then, I try to call that function
>> from LispWorks :
>> 
>> std::string  test() {
>> 	freopen ("/tmp/mystdout.txt","w",stdout);
>> 	freopen ("/tmp/mystderr.txt","w",stderr);
>> 	std::cout << "Redirected stdout." << std::endl;
>> 	std::cerr << "Redirected stderr." << std::endl;
>> 	
>> 	GRelation testgr(3);
>> 
>> 	std::cout << "test ! " << std::endl;
>> 	std::cerr << "test cerr! " << std::endl;
>> 	std::cout << testgr.arity() << std::endl;
>> 	std::cerr << testgr.arity() << std::endl;	
>> 	std::cout << "test after! " << std::endl;
>> 	std::cerr << "test cerr after! " << std::endl;
>> 	std::stringstream os;
>> 	os << testgr << std::endl ;
>> 	return os.str();
>> }
>> 
>> As you can see, I just create one object and print lots of stuff, including
>> an object attribute. Everything I print before trying to print the attribute
>> prints ok in the redirected outputs. The attribute is not printed and
>> nothing else afterwards. I also get the following error when I add testgr to
>> the stringstream os :
>> 
>> lispworks-personal-6-0-1-macos-universal(52881,0xb0314000) malloc: *** error for object 0x17be20f8: pointer being freed was not allocated
>> 
>> This is what happen in LispWorks. If I compile directly in C++, no
>> problem. If I use SBCL (other Common Lisp implementation) instead of
>> LispWorks, everything works correctly ! The problem is that I have to use
>> LispWorks ...
>> 
>> Does anybody has had a similar problem ? I guess I am not the only one who
>> tried to call some C++ from LispWorks. Any clue is very welcome. I think
>> maybe the problem can be linked to the garbage collection from LispWorks but
>> I don't know much about this.
>> 
>> I thank you in advance for your help, I am really stuck here. 
> 
> I don't see how garbage collection can cause it, because malloc is not
> affected by the LispWorks GC (unless something is doing bad things with
> finalization routines).
> 
> -- 
> Martin Simmons
> LispWorks Ltd
> http://www.lispworks.com/
> 
> _______________________________________________
> cffi-devel mailing list
> cffi-devel at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel





More information about the cffi-devel mailing list