From: Alvin Schur Date: 2004-07-15T03:59:58+09:00 Subject: Re: Bug in OpenGL module (Re: [Bug] Ruby 1.8.1 and 1.9: interactions between extensions: opengl and imlib2) Many thanks for the quick reply and patch. I see invoking ObjectSpace.garbage_collect highlights the problem as well. Alvin. On July 14, 2004 02:55 am, nobu.nokada@softhome.net wrote: > Hi, > > At Wed, 14 Jul 2004 12:39:13 +0900, > > Alvin Schur wrote in [ruby-core:03189]: > > I am trying to use the opengl and imlib2 extensions with Ruby 1.8.1 and > > 1.9. The program listed below causes a segfault in both versions of Ruby. > > The backtrace at the end of the email is for Ruby 1.9. The interesting > > lines are: > > > > def init_timer_fails > > GLUT.TimerFunc(100, handle_timer, 34) > > end > > It's a bug in rbogl, imlib2 isn't concerned with the SEGV > directly. rbogl has to mark timer_func etc. while GC. > > > --- extconf.rb~ 2003-08-17 12:04:32.000000000 +0900 > +++ extconf.rb 2004-07-14 15:47:02.000000000 +0900 > @@ -20,5 +20,6 @@ File.unlink("Makefile.glut") if (FileTes > header = nil > > -if (/cygwin/ =~ PLATFORM) > +case RUBY_PLATFORM > +when /cygwin/ > $CFLAGS="-DWIN32" > gl_libname = "opengl32" > @@ -26,5 +27,5 @@ if (/cygwin/ =~ PLATFORM) > glut_libname = "glut32" > header=["GL/gl.h", "GL/glu.h", "GL/glut.h"] > -elsif (/mswin32/ =~ PLATFORM) > +when /mswin32/ > $CFLAGS="-DWIN32" > gl_libname = "opengl32" > --- glut.c~ 2004-07-11 00:47:34.000000000 +0900 > +++ glut.c 2004-07-14 15:50:14.000000000 +0900 > @@ -1501,13 +1501,13 @@ Init_glut() > rb_define_const(mGLUT, "CURSOR_FULL_CROSSHAIR", > INT2NUM(GLUT_CURSOR_FULL_CROSSHAIR)); > > - rb_define_const(mGLUT, "BITMAP_9_BY_15", > INT2NUM(GLUT_BITMAP_9_BY_15)); - rb_define_const(mGLUT, > "BITMAP_8_BY_13", INT2NUM(GLUT_BITMAP_8_BY_13)); - > rb_define_const(mGLUT, "BITMAP_TIMES_ROMAN_10", > INT2NUM(GLUT_BITMAP_TIMES_ROMAN_10)); - rb_define_const(mGLUT, > "BITMAP_TIMES_ROMAN_24", INT2NUM(GLUT_BITMAP_TIMES_ROMAN_24)); - > rb_define_const(mGLUT, "BITMAP_HELVETICA_10", > INT2NUM(GLUT_BITMAP_HELVETICA_10)); - rb_define_const(mGLUT, > "BITMAP_HELVETICA_12", INT2NUM(GLUT_BITMAP_HELVETICA_12)); - > rb_define_const(mGLUT, "BITMAP_HELVETICA_18", > INT2NUM(GLUT_BITMAP_HELVETICA_18)); - rb_define_const(mGLUT, > "STROKE_ROMAN", INT2NUM(GLUT_STROKE_ROMAN)); - rb_define_const(mGLUT, > "STROKE_MONO_ROMAN", INT2NUM(GLUT_STROKE_MONO_ROMAN)); + > rb_define_const(mGLUT, "BITMAP_9_BY_15", > INT2NUM((VALUE)GLUT_BITMAP_9_BY_15)); + rb_define_const(mGLUT, > "BITMAP_8_BY_13", INT2NUM((VALUE)GLUT_BITMAP_8_BY_13)); + > rb_define_const(mGLUT, "BITMAP_TIMES_ROMAN_10", > INT2NUM((VALUE)GLUT_BITMAP_TIMES_ROMAN_10)); + rb_define_const(mGLUT, > "BITMAP_TIMES_ROMAN_24", INT2NUM((VALUE)GLUT_BITMAP_TIMES_ROMAN_24)); + > rb_define_const(mGLUT, "BITMAP_HELVETICA_10", > INT2NUM((VALUE)GLUT_BITMAP_HELVETICA_10)); + rb_define_const(mGLUT, > "BITMAP_HELVETICA_12", INT2NUM((VALUE)GLUT_BITMAP_HELVETICA_12)); + > rb_define_const(mGLUT, "BITMAP_HELVETICA_18", > INT2NUM((VALUE)GLUT_BITMAP_HELVETICA_18)); + rb_define_const(mGLUT, > "STROKE_ROMAN", INT2NUM((VALUE)GLUT_STROKE_ROMAN)); + > rb_define_const(mGLUT, "STROKE_MONO_ROMAN", > INT2NUM((VALUE)GLUT_STROKE_MONO_ROMAN)); > > callId = rb_intern("call"); > @@ -1539,4 +1539,8 @@ Init_glut() > WINDOW_CALLBACK_DEFINE(OverlayDisplayFunc); > WINDOW_CALLBACK_DEFINE(WindowStatusFunc); > + > + rb_gc_register_address(&idle_func); > + rb_gc_register_address(&timer_func); > + rb_gc_register_address(&menustate_func); > } > >