Skip Menu |

This queue is for tickets about the UUID CPAN distribution.

Report information
The Basics
Id: 101137
Status: resolved
Worked: 1 min
Priority: 0/
Queue: UUID

People
Owner: JRM [...] cpan.org
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.19



Subject: Don't call free() in do_uuid (UUID-0.18)
The free() call in https://metacpan.org/source/JRM/UUID-0.18/UUID.xs#L277 looks wrong. str is created on the stack, so free() should not be called here. Actually this is causing segmentation faults when running the test suite on a freebsd system: $ valgrind /usr/perl5.20.0/bin/perl -Mblib test.pl ... ==80158== Invalid free() / delete / delete[] / realloc() ==80158== at 0x117CEDE: free (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so) ==80158== by 0x27359F3: do_uuid (in /usr/home/eserte/.cpan/build/UUID-0.18-7xMhjb/blib/arch/auto/UUID/UUID.so) ==80158== by 0x2735A79: XS_UUID_uuid (in /usr/home/eserte/.cpan/build/UUID-0.18-7xMhjb/blib/arch/auto/UUID/UUID.so) ==80158== by 0x4A6CEE: Perl_pp_entersub (in /usr/perl5.20.0/bin/perl) ==80158== by 0x4A2852: Perl_runops_standard (in /usr/perl5.20.0/bin/perl) ==80158== by 0x43C4B6: perl_run (in /usr/perl5.20.0/bin/perl) ==80158== by 0x420F85: main (in /usr/perl5.20.0/bin/perl) ==80158== Address 0x7ff000540 is on thread 1's stack ==80158==
On 2014-12-26 08:54:35, SREZIC wrote: Show quoted text
> The free() call in https://metacpan.org/source/JRM/UUID- > 0.18/UUID.xs#L277 looks wrong. str is created on the stack, so free() > should not be called here. Actually this is causing segmentation > faults when running the test suite on a freebsd system: > > $ valgrind /usr/perl5.20.0/bin/perl -Mblib test.pl > ... > ==80158== Invalid free() / delete / delete[] / realloc() > ==80158== at 0x117CEDE: free (in > /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so) > ==80158== by 0x27359F3: do_uuid (in > /usr/home/eserte/.cpan/build/UUID-0.18- > 7xMhjb/blib/arch/auto/UUID/UUID.so) > ==80158== by 0x2735A79: XS_UUID_uuid (in > /usr/home/eserte/.cpan/build/UUID-0.18- > 7xMhjb/blib/arch/auto/UUID/UUID.so) > ==80158== by 0x4A6CEE: Perl_pp_entersub (in > /usr/perl5.20.0/bin/perl) > ==80158== by 0x4A2852: Perl_runops_standard (in > /usr/perl5.20.0/bin/perl) > ==80158== by 0x43C4B6: perl_run (in /usr/perl5.20.0/bin/perl) > ==80158== by 0x420F85: main (in /usr/perl5.20.0/bin/perl) > ==80158== Address 0x7ff000540 is on thread 1's stack > ==80158==
Just noticed the comment a few lines above ("this mallocs"). So the real fix is to change the declaration in https://metacpan.org/source/JRM/UUID-0.18/UUID.xs#L271 It has to be simply "char *str;".
On Fri Dec 26 09:49:42 2014, SREZIC wrote: Show quoted text
> On 2014-12-26 08:54:35, SREZIC wrote:
> > The free() call in https://metacpan.org/source/JRM/UUID- > > 0.18/UUID.xs#L277 looks wrong. str is created on the stack, so free() > > should not be called here. Actually this is causing segmentation > > faults when running the test suite on a freebsd system: > > > > $ valgrind /usr/perl5.20.0/bin/perl -Mblib test.pl > > ... > > ==80158== Invalid free() / delete / delete[] / realloc() > > ==80158== at 0x117CEDE: free (in > > /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so) > > ==80158== by 0x27359F3: do_uuid (in > > /usr/home/eserte/.cpan/build/UUID-0.18- > > 7xMhjb/blib/arch/auto/UUID/UUID.so) > > ==80158== by 0x2735A79: XS_UUID_uuid (in > > /usr/home/eserte/.cpan/build/UUID-0.18- > > 7xMhjb/blib/arch/auto/UUID/UUID.so) > > ==80158== by 0x4A6CEE: Perl_pp_entersub (in > > /usr/perl5.20.0/bin/perl) > > ==80158== by 0x4A2852: Perl_runops_standard (in > > /usr/perl5.20.0/bin/perl) > > ==80158== by 0x43C4B6: perl_run (in /usr/perl5.20.0/bin/perl) > > ==80158== by 0x420F85: main (in /usr/perl5.20.0/bin/perl) > > ==80158== Address 0x7ff000540 is on thread 1's stack > > ==80158==
> > Just noticed the comment a few lines above ("this mallocs"). So the > real fix is to change the declaration in > https://metacpan.org/source/JRM/UUID-0.18/UUID.xs#L271 > It has to be simply "char *str;".
Thanks. Looks like this change is passing in 0.19 now. Interesting though, that the earlier broken code passed on multi-thread Perl but faults on the unthreaded model. Usually it's the other way around. Regards, Rick
On 2014-12-26 21:48:26, JRM wrote: Show quoted text
> On Fri Dec 26 09:49:42 2014, SREZIC wrote:
> > On 2014-12-26 08:54:35, SREZIC wrote:
> > > The free() call in https://metacpan.org/source/JRM/UUID- > > > 0.18/UUID.xs#L277 looks wrong. str is created on the stack, so > > > free() > > > should not be called here. Actually this is causing segmentation > > > faults when running the test suite on a freebsd system: > > > > > > $ valgrind /usr/perl5.20.0/bin/perl -Mblib test.pl > > > ... > > > ==80158== Invalid free() / delete / delete[] / realloc() > > > ==80158== at 0x117CEDE: free (in > > > /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so) > > > ==80158== by 0x27359F3: do_uuid (in > > > /usr/home/eserte/.cpan/build/UUID-0.18- > > > 7xMhjb/blib/arch/auto/UUID/UUID.so) > > > ==80158== by 0x2735A79: XS_UUID_uuid (in > > > /usr/home/eserte/.cpan/build/UUID-0.18- > > > 7xMhjb/blib/arch/auto/UUID/UUID.so) > > > ==80158== by 0x4A6CEE: Perl_pp_entersub (in > > > /usr/perl5.20.0/bin/perl) > > > ==80158== by 0x4A2852: Perl_runops_standard (in > > > /usr/perl5.20.0/bin/perl) > > > ==80158== by 0x43C4B6: perl_run (in /usr/perl5.20.0/bin/perl) > > > ==80158== by 0x420F85: main (in /usr/perl5.20.0/bin/perl) > > > ==80158== Address 0x7ff000540 is on thread 1's stack > > > ==80158==
> > > > Just noticed the comment a few lines above ("this mallocs"). So the > > real fix is to change the declaration in > > https://metacpan.org/source/JRM/UUID-0.18/UUID.xs#L271 > > It has to be simply "char *str;".
> > Thanks. Looks like this change is passing in 0.19 now. Interesting > though, that the earlier broken code passed on multi-thread Perl but > faults on the unthreaded model. Usually it's the other way around.
Thanks, looks good now. Regards, Slaven