Hello!
Am I right in assuming OpenGL::Array is not thread safe? It looks like the underlying data storage is not duplicated when object is cloned, but DESTROY {} tries to free it twice.
The following workaround should be enough:
*OpenGL::Array::CLONE_SKIP = sub { 1 };
I don't see a duplicate free() in the DESTROY() call for OpenGL::Array objects. This is for the current release version 0.6703. It is possible that the code is not thread safe but I don't think there are tests for that. Could you give a link/line number or more detail for what you see?
Thanks,
Chris
Oh, it's very easy to reproduce:
my $array = OpenGL::Array->new(4, GL_FLOAT);
threads->create(sub { $array })->join;
perl(65121,0x313540) malloc: *** error for object 0x544540: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Double free() happens because both threads call $array->DESTROY().
See http://perldoc.perl.org/perlmod.html#Making-your-module-threadsafe
I think a CLONE_SKIP { 1 } would be the best choice for OpenGL::Array.
Thanks, I see what you mean. It is definitely not
thread safe then. I'll add that work around and info
to the release.
-chm
On Sat, May 3, 2014 at 5:17 AM, Alessandro Ranellucci
alexrj@users.sf.netwrote:
Hello Chris, any update on this?
Thank you!
Where does the fix line go? Patches against git welcome.
It looks like this has already been applied to git master.
Could you please verify that everything builds, runs, and
looks ok and I'll push a new CPAN release as soon as I get
confirmation from you.
Thanks,
Chris