Skip Menu |

This queue is for tickets about the File-Map CPAN distribution.

Report information
The Basics
Id: 132877
Status: open
Priority: 0/
Queue: File-Map

People
Owner: Nobody in particular
Requestors: marc.ballarin [...] ionos.com
Cc:
AdminCc:

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



Subject: Segfault on repeated, empty mappings
Date: Thu, 25 Jun 2020 18:36:06 +0200
To: <bug-file-map [...] rt.cpan.org>
From: Marc Ballarin <marc.ballarin [...] ionos.com>
Hi, I am observing a segfault in File::Map 0.66 on Perl 5.28/Debian Buster. The problem does not appear in File::Map 0.64 on Perl 5.24/Debian Stretch. The problem only occurs when attempting to map an empty file (i.e. no actual call to mmap() is done). To reproduce: Create an empty file named "empty". Run: #!/usr/bin/perl use strict; use warnings; use File::Map qw(map_file); for (1,2) { map_file my $data, 'empty'; } This segfaults on the second call to maptest()/map_file() on 0.66, but not on 0.64. strace looks like this: openat(AT_FDCWD, "empty", O_RDONLY|O_CLOEXEC) = 3 ioctl(3, TCGETS, 0x7ffe3c4a9080) = -1 ENOTTY (Inappropriate ioctl for device) lseek(3, 0, SEEK_CUR) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 close(3) = 0 openat(AT_FDCWD, "empty", O_RDONLY|O_CLOEXEC) = 3 ioctl(3, TCGETS, 0x7ffe3c4a9080) = -1 ENOTTY (Inappropriate ioctl for device) lseek(3, 0, SEEK_CUR) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} --- +++ killed by SIGSEGV +++ AFAICT, your test/10-empty.t is supposed to catch this, but the test seems buggy, as it uses $0 as file name (and $0 is not empty). Regards, Marc
Subject: Re: [rt.cpan.org #132877] Segfault on repeated, empty mappings
Date: Fri, 26 Jun 2020 00:40:32 +0200
To: bug-File-Map [...] rt.cpan.org
From: Leon Timmermans <fawaka [...] gmail.com>
On Thu, Jun 25, 2020 at 6:40 PM Marc Ballarin via RT <bug-File-Map@rt.cpan.org> wrote: Show quoted text
> Hi, > > I am observing a segfault in File::Map 0.66 on Perl 5.28/Debian Buster. > > The problem does not appear in File::Map 0.64 on Perl 5.24/Debian Stretch. > > The problem only occurs when attempting to map an empty file (i.e. no > actual call to mmap() is done). > > To reproduce: > Create an empty file named "empty". > > Run: > #!/usr/bin/perl > > use strict; > use warnings; > use File::Map qw(map_file); > > for (1,2) { > map_file my $data, 'empty'; > } > > This segfaults on the second call to maptest()/map_file() on 0.66, but > not on 0.64. > > strace looks like this: > openat(AT_FDCWD, "empty", O_RDONLY|O_CLOEXEC) = 3 > ioctl(3, TCGETS, 0x7ffe3c4a9080) = -1 ENOTTY (Inappropriate ioctl > for device) > lseek(3, 0, SEEK_CUR) = 0 > fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 > fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 > fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 > close(3) = 0 > openat(AT_FDCWD, "empty", O_RDONLY|O_CLOEXEC) = 3 > ioctl(3, TCGETS, 0x7ffe3c4a9080) = -1 ENOTTY (Inappropriate ioctl > for device) > lseek(3, 0, SEEK_CUR) = 0 > fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 > fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 > fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 > --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} --- > +++ killed by SIGSEGV +++
Thanks for the clear bug report, it enabled me to identify and fix the issue pretty quickly. I've released a new version Show quoted text
> AFAICT, your test/10-empty.t is supposed to catch this, but the test > seems buggy, as it uses $0 as file name (and $0 is not empty).
Yeah, I'm not sure what I was thinking when I wrote that, I'll probably end up rewriting that part of the test completely. Leon
Subject: Re: [rt.cpan.org #132877] Segfault on repeated, empty mappings
Date: Fri, 26 Jun 2020 12:31:37 +0200
To: <bug-File-Map [...] rt.cpan.org>
From: Marc Ballarin <marc.ballarin [...] ionos.com>
Hi, thanks for the quick fix. Works fine now. Regards, Marc Am 26.06.2020 um 00:41 schrieb Leon Timmermans via RT: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=132877 > > > On Thu, Jun 25, 2020 at 6:40 PM Marc Ballarin via RT > <bug-File-Map@rt.cpan.org> wrote:
>> Hi, >> >> I am observing a segfault in File::Map 0.66 on Perl 5.28/Debian Buster. >> >> The problem does not appear in File::Map 0.64 on Perl 5.24/Debian Stretch. >> >> The problem only occurs when attempting to map an empty file (i.e. no >> actual call to mmap() is done). >> >> To reproduce: >> Create an empty file named "empty". >> >> Run: >> #!/usr/bin/perl >> >> use strict; >> use warnings; >> use File::Map qw(map_file); >> >> for (1,2) { >> map_file my $data, 'empty'; >> } >> >> This segfaults on the second call to maptest()/map_file() on 0.66, but >> not on 0.64. >> >> strace looks like this: >> openat(AT_FDCWD, "empty", O_RDONLY|O_CLOEXEC) = 3 >> ioctl(3, TCGETS, 0x7ffe3c4a9080) = -1 ENOTTY (Inappropriate ioctl >> for device) >> lseek(3, 0, SEEK_CUR) = 0 >> fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 >> fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 >> fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 >> close(3) = 0 >> openat(AT_FDCWD, "empty", O_RDONLY|O_CLOEXEC) = 3 >> ioctl(3, TCGETS, 0x7ffe3c4a9080) = -1 ENOTTY (Inappropriate ioctl >> for device) >> lseek(3, 0, SEEK_CUR) = 0 >> fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 >> fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 >> fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 >> --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} --- >> +++ killed by SIGSEGV +++
> > Thanks for the clear bug report, it enabled me to identify and fix the > issue pretty quickly. I've released a new version >
>> AFAICT, your test/10-empty.t is supposed to catch this, but the test >> seems buggy, as it uses $0 as file name (and $0 is not empty).
> > Yeah, I'm not sure what I was thinking when I wrote that, I'll > probably end up rewriting that part of the test completely. > > Leon >
-- Marc Ballarin Senior Anti-Abuse Software Engineer Hosting Security 1&1 IONOS Service GmbH | Brauerstraße 50 | 76135 Karlsruhe | Germany Phone: +49 721 91374-6774 E-Mail: marc.ballarin@ionos.com | Web: www.ionos.de Hauptsitz Montabaur, Amtsgericht Montabaur, HRB 20141 Geschäftsführer: Michael Fromm, Christoph Steger Member of United Internet