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

Sascha Van Cauwelaert sascha.vancauwelaert at gmail.com
Mon Nov 21 09:28:56 UTC 2011


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. 

Regards,

Sascha



More information about the cffi-devel mailing list