Laurent,

>>> Could you enter "thread apply all bt" into the debugger shell and paste us 
>>> the result?
>> 
>> Here it is. I don't understand much. The only information I can add is that 
>> thread 4 do not systematically appear. Besides that, the backtraces are 
>> consistent.
> [...]
> 
> I looked at your project and I was able to reproduce the crashes, which 
> smelled like memory smashers. Then, looking at the code, I saw bad usage of 
> the Pointer class.
> 
> An example:
> 
>               @light_position         = Pointer.new_with_type('f')
>               @light_position[0]      = -2.0
>               @light_position[1]      =  2.0
>               @light_position[2]      =  1.0
>               @light_position[3]      =  0.0
> 
> This is not good, because this creates a pointer to a float of 1 element 
> (exactly like malloc(sizeof(float)) in C) but then you set objects to indexes 
> (1, 2, 3) out of the pointer's bounds.
> 
> The correct code should be:
> 
>               @light_position         = Pointer.new_with_type('f', 4)
>               @light_position[0]      = -2.0
>               @light_position[1]      =  2.0
>               @light_position[2]      =  1.0
>               @light_position[3]      =  0.0
> 
> The second argument allows you to specify the number of elements the Pointer 
> will hold (by default, it's 1).
> 
> As in C, it's very easy to corrupt memory or crash the program. Sometimes we 
> get pointers from C or Objective-C, we wrap them inside Pointer objects and 
> we do not know the number of elements, but in this case, when the Pointer is 
> constructed by Ruby itself, I believe MacRuby should not let you do this and 
> appropriately raise an exception. I will fix that ASAP.
> 
> The random crashes may perhaps disappear after you fix the code.

Sorry. I should have read the source for the Pointer class. The crashes are 
gone.


>>> I'm not familiar with OpenGL but it might be a BridgeSupport problem... 
>>> What other functions using the CGLRendererInfoObj are failing?
>> 
>> Sorry, when I said all other functions, I really meant all other calls to 
>> CGLDescribeRenderer. After a series of call to CGLDescribeRenderer, the 
>> CGLRendererInfoObj is destroyed by CGLDestroyRendererInfo.
>> 
>> If I bypass this whole section of code, I get more problems with 
>> blablablaObj and sameblablablaObject pointer confusion. The documentation 
>> for those types mentions only CGLRendererInfoObj, CGLPixelFormatObj or 
>> CGLContextObj, though
> 
> Thanks, I reproduce the problem here too. Could you file a ticket on Trac, 
> this way we won't forget to fix it?

Done. Thanks.


Bonnes fĂȘtes Ă©galement !

Julien


_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to