Skip Menu |

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

Report information
The Basics
Id: 85526
Status: resolved
Priority: 0/
Queue: File-Map

People
Owner: Nobody in particular
Requestors: chm [...] cpan.org
Cc:
AdminCc:

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



Subject: File::Map appears to only support 32bit sizes
AFAICT, the underlying routines on 64bit OSes do support >32bit sizes and offsets.
This limitation prevents PDL from mapping files larger than 4GiB when for these
extremely large files, this is exactly where we expect the greatest benefit from mapping.

E.g., by using map_anonymous() we can avoid the perl exit on Out-of-memory problem
for extremely large memory requests.

Show quoted text
pdl> use File::Map qw(:map)

Show quoted text
pdl> map_anonymous $huge, 2_000_000_000, 'private'

Show quoted text
pdl> p length $huge
2000000000

Show quoted text
pdl> unmap $huge

Show quoted text
pdl> map_anonymous $huge, 4_000_000_000, 'private'

Show quoted text
pdl> p length $huge
4000000000

Show quoted text
pdl> unmap $huge

Show quoted text
pdl> map_anonymous $huge, 5_000_000_000, 'private'
Runtime error: Can't map: length + offset overflows at (eval 464) line 5.
Subject: Re: [rt.cpan.org #85526] File::Map appears to only support 32bit sizes
Date: Tue, 21 May 2013 23:46:30 +0200
To: bug-File-Map [...] rt.cpan.org
From: Leon Timmermans <leont [...] cpan.org>
On Tue, May 21, 2013 at 11:05 PM, Chris Marshall via RT <bug-File-Map@rt.cpan.org> wrote: Show quoted text
> AFAICT, the underlying routines on 64bit OSes do support >32bit sizes and > offsets. > This limitation prevents PDL from mapping files larger than 4GiB when for these > extremely large files, this is exactly where we expect the greatest benefit > from mapping. > > E.g., by using map_anonymous() we can avoid the perl exit on Out-of-memory > problem > for extremely large memory requests. >
> pdl> use File::Map qw(:map)
>
> pdl> map_anonymous $huge, 2_000_000_000, 'private'
>
> pdl> p length $huge
> 2000000000 >
> pdl> unmap $huge
>
> pdl> map_anonymous $huge, 4_000_000_000, 'private'
>
> pdl> p length $huge
> 4000000000 >
> pdl> unmap $huge
>
> pdl> map_anonymous $huge, 5_000_000_000, 'private'
> Runtime error: Can't map: length + offset overflows at (eval 464) line 5.
I took special care to make File::Map 64-bit safe (because of the same reasons as you provide), and I can't reproduce this issue on a 64-bit OS. On a 32 bit OS however I would expect this limitation; one can't map a file larger than one's memory space. That's a limitation of the architecture, not of my software. Leon
CC: chm [...] cpan.org
Subject: Re: [rt.cpan.org #85526] File::Map appears to only support 32bit sizes
Date: Tue, 21 May 2013 18:09:43 -0400
To: bug-File-Map [...] rt.cpan.org
From: Chris Marshall <devel.chm.01 [...] gmail.com>
Hi Leon- Here are the lines from Map.xs where the problem comes in. It appears that the test is against ULONG_MAX which is something like 2**32 where it should be against ULONGLONG_MAX or whatever is appropriate. 569 struct mmap_info* magical; 570 if (length > ULONG_MAX - correction) 571 real_croak_pv(aTHX_ "Can't map: length + offset overflows"); For reference, the File::Map test is run on win7 x64 and 64bit Strawberry Perl portable. F:\chm\perl\strawberry\v51631>perl -V Summary of my perl5 (revision 5 version 16 subversion 3) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x64-multi-thread uname='Win32 strawberry-perl 5.16.3.1 #1 Tue Mar 12 12:12:07 2013 x64' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-bitfields', optimize='-s -O2', cppflags='-DWIN32' ccversion='', gccversion='4.6.3', gccosandvers='' intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='long long', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='g++.exe', ldflags ='-s -L"F:\chm\perl\strawberry\v51631\perl\lib\CORE" -L"F:\chm\perl\strawberry\v51631\c\lib"' libpth=F:\chm\perl\strawberry\v51631\c\lib F:\chm\perl\strawberry\v51631\c\x86_64-w64-mingw32\lib libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 libc=, so=dll, useshrplib=true, libperl=libperl516.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-mdll -s -L"F:\chm\perl\strawberry\v51631\perl\lib\CORE" -L"F:\chm\perl\strawberry\v51631\c\lib"' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PL_OP_SLAB_ALLOC USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF Built under MSWin32 Compiled at Mar 12 2013 12:16:40 %ENV: PERLDOC_PAGER="less" @INC: F:/chm/perl/strawberry/v51631/perl/site/lib F:/chm/perl/strawberry/v51631/perl/vendor/lib F:/chm/perl/strawberry/v51631/perl/lib . On Tue, May 21, 2013 at 5:47 PM, Leon Timmermans via RT <bug-File-Map@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=85526 > > > On Tue, May 21, 2013 at 11:05 PM, Chris Marshall via RT > <bug-File-Map@rt.cpan.org> wrote:
>> AFAICT, the underlying routines on 64bit OSes do support >32bit sizes and >> offsets. >> This limitation prevents PDL from mapping files larger than 4GiB when for these >> extremely large files, this is exactly where we expect the greatest benefit >> from mapping. >> >> E.g., by using map_anonymous() we can avoid the perl exit on Out-of-memory >> problem >> for extremely large memory requests. >>
>> pdl> use File::Map qw(:map)
>>
>> pdl> map_anonymous $huge, 2_000_000_000, 'private'
>>
>> pdl> p length $huge
>> 2000000000 >>
>> pdl> unmap $huge
>>
>> pdl> map_anonymous $huge, 4_000_000_000, 'private'
>>
>> pdl> p length $huge
>> 4000000000 >>
>> pdl> unmap $huge
>>
>> pdl> map_anonymous $huge, 5_000_000_000, 'private'
>> Runtime error: Can't map: length + offset overflows at (eval 464) line 5.
> > I took special care to make File::Map 64-bit safe (because of the same > reasons as you provide), and I can't reproduce this issue on a 64-bit > OS. > > On a 32 bit OS however I would expect this limitation; one can't map a > file larger than one's memory space. That's a limitation of the > architecture, not of my software. > > Leon >
On Tue May 21 18:10:08 2013, devel.chm.01@gmail.com Show quoted text
> For reference, the File::Map test is run on win7 x64 and 64bit > Strawberry Perl portable.
I see, that's the crucial bit of information that I needed. I wrote that code assuming an unsigned long is a big as a pointer (such as LP64), but on Windows this is not the case (as it uses LLP64). I should base my maximum size on something else, probably hardcoded per pointer size (as in practice, I'll only have to deal with 4 and 8 byte pointers anyway). Leon
CC: chm [...] cpan.org
Subject: Re: [rt.cpan.org #85526] File::Map appears to only support 32bit sizes
Date: Tue, 21 May 2013 19:37:11 -0400
To: bug-File-Map [...] rt.cpan.org
From: Chris Marshall <devel.chm.01 [...] gmail.com>
I suggest using $Config{ivtype} and $Config{ivsize} since an IV is supposed to be big enough (by construction) to hold a pointer. --Chris On Tue, May 21, 2013 at 6:55 PM, Leon Timmermans via RT <bug-File-Map@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=85526 > > > On Tue May 21 18:10:08 2013, devel.chm.01@gmail.com
>> For reference, the File::Map test is run on win7 x64 and 64bit >> Strawberry Perl portable.
> > I see, that's the crucial bit of information that I needed. > > I wrote that code assuming an unsigned long is a big as a pointer (such as LP64), but on Windows this is not the case (as it uses LLP64). > > I should base my maximum size on something else, probably hardcoded per pointer size (as in practice, I'll only have to deal with 4 and 8 byte pointers anyway). > > Leon
Subject: Re: [rt.cpan.org #85526] File::Map appears to only support 32bit sizes
Date: Wed, 22 May 2013 01:54:49 +0200
To: bug-File-Map [...] rt.cpan.org
From: Leon Timmermans <leont [...] cpan.org>
On Wed, May 22, 2013 at 1:37 AM, devel.chm.01@gmail.com via RT <bug-File-Map@rt.cpan.org> wrote: Show quoted text
> Queue: File-Map > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=85526 > > > I suggest using $Config{ivtype} and $Config{ivsize} since an IV > is supposed to be big enough (by construction) to hold a pointer.
On a 32-bit perl with use64bitint defined, that would give the wrong result. I really need the size of the pointer itself. Leon
CC: chm [...] cpan.org
Subject: Re: [rt.cpan.org #85526] File::Map appears to only support 32bit sizes
Date: Tue, 21 May 2013 20:21:48 -0400
To: bug-File-Map [...] rt.cpan.org
From: Chris Marshall <devel.chm.01 [...] gmail.com>
Right, how about $Config{ptrsize} ? On Tue, May 21, 2013 at 7:55 PM, Leon Timmermans via RT <bug-File-Map@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=85526 > > > On Wed, May 22, 2013 at 1:37 AM, devel.chm.01@gmail.com via RT > <bug-File-Map@rt.cpan.org> wrote:
>> Queue: File-Map >> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=85526 > >> >> I suggest using $Config{ivtype} and $Config{ivsize} since an IV >> is supposed to be big enough (by construction) to hold a pointer.
> > On a 32-bit perl with use64bitint defined, that would give the wrong > result. I really need the size of the pointer itself. > > Leon >
Subject: Re: [rt.cpan.org #85526] File::Map appears to only support 32bit sizes
Date: Wed, 22 May 2013 02:35:13 +0200
To: bug-File-Map [...] rt.cpan.org
From: Leon Timmermans <leont [...] cpan.org>
On Wed, May 22, 2013 at 2:22 AM, devel.chm.01@gmail.com via RT <bug-File-Map@rt.cpan.org> wrote: Show quoted text
> Right, how about $Config{ptrsize} ?
Yeah, though in C that's just plain old sizeof(void*) ;-) I'm planning a new release later this week, possibly tomorrow. Leon
On Tue May 21 18:55:55 2013, LEONT wrote: Show quoted text
> On Tue May 21 18:10:08 2013, devel.chm.01@gmail.com
> > For reference, the File::Map test is run on win7 x64 and 64bit > > Strawberry Perl portable.
> > I see, that's the crucial bit of information that I needed. > > I wrote that code assuming an unsigned long is a big as a pointer > (such as LP64), but on Windows this is not the case (as it uses > LLP64). > > I should base my maximum size on something else, probably hardcoded > per pointer size (as in practice, I'll only have to deal with 4 and 8 > byte pointers anyway). > > Leon
This should be resolved in 0.57. Leon