Segfault when calling loadPlugin from a scripting language
Posted: Wed Dec 10, 2008 9:02 am
Hi all,
This could very well be a Lisp question but I chose to ask it here first. I've also Googled and searched this forum for answers and did find some threads but none solved my problem.
I'm trying to create a language binding for Ogre from Common Lisp (ECL specifically at the moment) and Ogre segfaults after calling loadPlugin. This also happened with Swig bindings I created on SBCL (CL implementation). It does not happen when I call loadPlugin from a small test C++ program.
Also, when I use a plugins.cfg everything loads fine so there's a workaround but I still want to know why this happens since I'll probably run into it again at a later point.
At the moment I'm not at the machine I'm developing the bindings on so I can't get you gdb or strace output unfortunately. I did use them though (although I'm not very familiar with them.. though I probably will be in the near future ). Ogre.log shows the same (can't get at it atm either) except it complains it can't find a plugins.cfg.
Fun fact: it did infact load the plugin once succesfully when running ECL from strace ("strace ecl") but I wasn't able to reproduce it. ("strace -e trace=open ecl" always gave the same error like below)
I'm basically hoping someone else who'se made language bindings has run into this same problem and knows the solution.
Note: The pastes below use Ogre 1.6.0 which I decided to try yesterday but I had the same problem with 1.4.9. There's also some commented out code and random Ogre::String stuff since I was trying out different things.
Here's the C++ program and its output:
Here's the ECL binding and its output:
The ECL error message isn't very useful. They need to work on that
This could very well be a Lisp question but I chose to ask it here first. I've also Googled and searched this forum for answers and did find some threads but none solved my problem.
I'm trying to create a language binding for Ogre from Common Lisp (ECL specifically at the moment) and Ogre segfaults after calling loadPlugin. This also happened with Swig bindings I created on SBCL (CL implementation). It does not happen when I call loadPlugin from a small test C++ program.
Also, when I use a plugins.cfg everything loads fine so there's a workaround but I still want to know why this happens since I'll probably run into it again at a later point.
At the moment I'm not at the machine I'm developing the bindings on so I can't get you gdb or strace output unfortunately. I did use them though (although I'm not very familiar with them.. though I probably will be in the near future ). Ogre.log shows the same (can't get at it atm either) except it complains it can't find a plugins.cfg.
Fun fact: it did infact load the plugin once succesfully when running ECL from strace ("strace ecl") but I wasn't able to reproduce it. ("strace -e trace=open ecl" always gave the same error like below)
I'm basically hoping someone else who'se made language bindings has run into this same problem and knows the solution.
Note: The pastes below use Ogre 1.6.0 which I decided to try yesterday but I had the same problem with 1.4.9. There's also some commented out code and random Ogre::String stuff since I was trying out different things.
Here's the C++ program and its output:
Code: Select all
// ogre-test.cpp
//
// Compile with: g++ `pkg-config --cflags --libs OGRE` ogre-test.cpp
#include "Ogre.h"
int main (int argc, char *argv[])
{
//Ogre::Root* ogre = new Ogre::Root( "", "" );
Ogre::Root* ogre = new Ogre::Root();
ogre->loadPlugin(Ogre::String("RenderSystem_GL"));
return 0;
}
Code: Select all
$ ./a.out
Creating resource group General
Creating resource group Internal
Creating resource group Autodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
OverlayElementFactory for type Panel registered.
OverlayElementFactory for type BorderPanel registered.
OverlayElementFactory for type TextArea registered.
Registering ResourceManager for type Font
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
FreeImage version: 3.10.0
This program uses FreeImage, a free, open source image library supporting all common bitmap
formats. See http://freeimage.sourceforge.net for details
Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,
pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,
xbm,xpm,gif,hdr,g3,sgi,exr,j2k,j2c,jp2
DDS codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
plugins.cfg not found, automatic plugin loading disabled.
*-*-* OGRE Initialising
*-*-* Version 1.6.0 (Shoggoth)
Loading library RenderSystem_GL
Installing plugin: GL RenderSystem
OpenGL Rendering Subsystem created.
Plugin successfully installed
Code: Select all
(defun ffi-ogre-root ()
(if *ogre*
*ogre*
(setf *ogre* (ffi:c-inline () () :pointer-void "new Ogre::Root()"
:one-liner t))))
(defun ffi-ogre-root-load-plugin (plugin)
(ffi:c-inline (*ogre* plugin) (:pointer :cstring) :void "{
Ogre::Root* ogre = (Ogre::Root*) #0;
//ogre->loadPlugin(Ogre::String(plugin));
ogre->loadPlugin(\"RenderSystem_GL\");
}"))
Code: Select all
ECL (Embeddable Common-Lisp) 0.9l (CVS 2008-06-19 17:09)
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help. Top level.
CL-USER[1]> (load "init")
;;; Loading #P"/usr/local/pub/ekwis/software/okra-0.1/init.lisp"
; loading system definition from ogre-test.asd into #<ASDF0 package>
;;; Loading "/usr/local/pub/ekwis/software/okra-0.1/ogre-test.asd"
; registering #<ASDF:SYSTEM :OGRE-TEST 163091992> as OGRE-TEST
;;; Loading "/usr/local/pub/ekwis/software/okra-0.1/specials.fas"
;;; Loading "/usr/local/pub/ekwis/software/okra-0.1/ffi.fas"
;;; Loading "/usr/local/pub/ekwis/software/okra-0.1/ogre-test.fas"
#P"/usr/local/pub/ekwis/software/okra-0.1/init.lisp"
CL-USER[2]> (ffi-ogre-root)
Creating resource group General
Creating resource group Internal
Creating resource group Autodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
OverlayElementFactory for type Panel registered.
OverlayElementFactory for type BorderPanel registered.
OverlayElementFactory for type TextArea registered.
Registering ResourceManager for type Font
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
FreeImage version: 3.10.0
This program uses FreeImage, a free, open source image library supporting all common bitmap
formats. See http://freeimage.sourceforge.net for details
Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,
pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,
xbm,xpm,gif,hdr,g3,sgi,exr,j2k,j2c,jp2
DDS codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
plugins.cfg not found, automatic plugin loading disabled.
*-*-* OGRE Initialising
*-*-* Version 1.6.0 (Shoggoth)
#<foreign :VOID 09c52008>
CL-USER[3]> (ffi-ogre-root-load-plugin "RenderSystem_GL")
Loading library RenderSystem_GL
Segmentation violation.
Broken at SI:BYTECODES.No restarts available.
Broken at SI:BYTECODES.
** BREAK [LEVEL 2] >