Bug#886496: libopengl-perl: glutTimerFunc: Segmentation fault

Thomas Kremer bugs.debian at xorg.c-informatik.de
Wed Jan 23 03:44:42 GMT 2019


tag 886496 patch
thanks.


On 07.01.2019 18:50, Bernhard Übelacker wrote:
> Dear Maintainer,
> I tried to have a look at this segfault.
> 
> It seems this is a case of pointer truncation.

Thanks for finding the problem!

Now that I knew where to look, I made a patch to store the pointer in a
separate array and only pass an index into that array to the backend.
With an error message if the array exceeds the maximum size
representable by an int...

I tested it in the stable package and so far it worked.

I used these for testing (particularly against memory leaks):

perl -e 'use OpenGL ":all"; glutInit(); glutCreateWindow("title"); sub
queue { my ($time,$id) = @_; glutTimerFunc($time,sub{ print $id,"\n";
queue($time,$id); }); } for (1..1000) { queue(sqrt($_),$_); }
glutMainLoop();'

---> using "top", check that resident set size stops growing.


perl -e '$|=1; use List::Util "shuffle"; use OpenGL ":all"; glutInit();
glutCreateWindow("title"); my @arr = shuffle(1..1000); for my $x (@arr)
{ glutTimerFunc($x*10,sub{ print $x,"\n"; }); } glutMainLoop();' | tee
foo.txt

perl -ne 'BEGIN{$i=0} print if $_ != ($i+1); $i = $_' < foo.txt

---> check, that the callbacks are not mixed up. (There may be
irregularities if the event times are close to each other)


perl -e 'use OpenGL ":all"; glutInit(); glutCreateWindow("title"); for
my $x (0..66553) { glutTimerFunc(1000,sub{ print $x,"\n"; }); }
glutMainLoop();'

---> Many concurrent timers need a lot of time and memory, but I think
that is more due to the backend than due to my array... Also, it's still
linear time and memory.


One of these days, someone's got to show me how to work *with* quilt
rather than against it...


Yours
Thomas


-- 
OpenPGP Key ID: 0x6BFFE5CF3C7720398928CE741F2DAE97486A60BF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-glutTimerFunc-pointer-truncation.patch
Type: text/x-patch
Size: 2263 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-perl-maintainers/attachments/20190123/3c8dd54c/attachment.bin>


More information about the pkg-perl-maintainers mailing list