Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shmget limited to 32 bit segment size on 64 bit OS #9685

Closed
p5pRT opened this issue Mar 16, 2009 · 14 comments
Closed

shmget limited to 32 bit segment size on 64 bit OS #9685

p5pRT opened this issue Mar 16, 2009 · 14 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 16, 2009

Migrated from rt.perl.org#63924 (status was 'resolved')

Searchable as RT63924$

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

From @mhx

Created by mhx@cpan.org

This was originally reported as cpan #44182 for IPC​::SysV. But the
underlying problem is that the perl core doesn't support more than
31 bits in the size argument to shmget(), as n in Perl_do_ipcget()
is declared as I32. However, the size parameter of shmget() is of
type size_t, which can be larger (and is unsigned).

Quoting the original bug report​:

I installed IPC-SysV 2.0.0 on CentOs 5.1 x86_x64 bit version.
Perl version is v5.8.8

I tested with "shmsizetest.pl" script, varing $shmsize from 1G~4G

It was successful to create 1 G byte shared memory,
but 2G, 3G, 4G were failed. (1G=1x1024x1024x1024)
And Errno(=$!) was "Invalide Argument"
Parameters related to SysV shared memory are
-----------------------------------------------
max number of segments = 4096
max seg size (kbytes) = 67108864
max total shared memory (kbytes) = 17179869184
min seg size (bytes) = 1
-----------------------------------------------
So I think no problem to get 4G byte at SysV shared memory
(C was successful to create 4G shared memory, using shmget function)

I wander IPC​::SharedMem is not supporting 64 bit os?

Actually is the argument $SIZE of IPC​::SharedMem limited as 4byte
signed integer?

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.11.0:

Configured by mhx at Sun Mar 15 04:46:39 MET 2009.

Summary of my perl5 (revision 5 version 11 subversion 0 patch GitLive-blead-774-g78b3516) configuration:
  Snapshot of: 78b3516b6c02d638c0127c4ce6ebe476158c5545
  Platform:
    osname=linux, osvers=2.6.26.7mhx, archname=i686-linux-thread-multi-64int-ld
    uname='linux r2d2 2.6.26.7mhx #1 smp thu nov 27 21:45:03 met 2008 i686 intel(r) core(tm)2 cpu t7400 @ 2.16ghz genuineintel gnulinux '
    config_args='-des -Uinstallusrbinperl -Dusethreads -Duse64bitint -Duselongdouble -Dcf_email=mhx@cpan.org -Dcc=gcc -DDEBUGGING=both -Doptimize=-ggdb3 -Dprefix=/home/mhx/perl/blead-debug -Dusedevel -Uversiononly -Aappend:ccflags= -DPERL_GLOBAL_STRUCT_PRIVATE -DPL_OP_SLAB_ALLOC -W -Wall '
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DPERL_GLOBAL_STRUCT_PRIVATE -DPL_OP_SLAB_ALLOC -W -Wall -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-ggdb3',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_GLOBAL_STRUCT_PRIVATE -DPL_OP_SLAB_ALLOC -W -Wall -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='4.3.2', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.6.1.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.6.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -ggdb3 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    PERL_GIT_UNPUSHED_COMMITS    	/* do not remove this line */
    PERL_GIT_UNCOMMITTED_CHANGES	/* do not remove this line */


@INC for perl 5.11.0:
    /home/m5/sw/tool/src_general/tparser/lib
    /home/mhx/perl/blead-debug/lib/site_perl/5.11.0/i686-linux-thread-multi-64int-ld
    /home/mhx/perl/blead-debug/lib/site_perl/5.11.0
    /home/mhx/perl/blead-debug/lib/5.11.0/i686-linux-thread-multi-64int-ld
    /home/mhx/perl/blead-debug/lib/5.11.0
    /home/mhx/perl/blead-debug/lib/site_perl
    .


Environment for perl 5.11.0:
    HOME=/home/mhx
    LANG=de_DE.utf8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/trolltech/qt/bin:/home/mhx/apps/bin/ccache:/usr/bin/ccache:/home/mhx/apps/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/avr/gcc-bin/4.3.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.2:/opt/intel/cc/10.1.018/bin:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin:/opt/vmware/workstation/bin:/opt/SnapshotCM/bin:/home/m5/sw/tool/bin:/users/patient_data/tool/bin/scripts
    PERL5LIB=/home/m5/sw/tool/src_general/tparser/lib
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

@mhx - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

@mhx - Status changed from 'open' to 'new'

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

@mhx - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

@mhx - Status changed from 'open' to 'new'

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

From @mhx

Attaching test script from original report.

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

From @mhx

shmsizetest.pl

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

From @mhx

Could you please try to build the development version of perl
with the attached patch applied on top of it and see if that
fixes your problem? I don't have a system where I could test
this right now. You can get the development version either
by git or by rsync. For details, see​:

  http​://perl5.git.perl.org/perl.git/blob/HEAD​:/pod/perlhack.pod

Thanks,
Marcus

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

From @mhx

doio.c.diff
--- doio.c.orig	2009-03-16 10:25:55.000000000 +0100
+++ doio.c	2009-03-16 10:28:46.000000000 +0100
@@ -1981,7 +1981,7 @@
 {
     dVAR;
     const key_t key = (key_t)SvNVx(*++mark);
-    const I32 n = (optype == OP_MSGGET) ? 0 : SvIVx(*++mark);
+    SV *nsv = optype == OP_MSGGET ? NULL : *++mark;
     const I32 flags = SvIVx(*++mark);
 
     PERL_ARGS_ASSERT_DO_IPCGET;
@@ -1996,11 +1996,11 @@
 #endif
 #ifdef HAS_SEM
     case OP_SEMGET:
-	return semget(key, n, flags);
+	return semget(key, (int) SvIV(nsv), flags);
 #endif
 #ifdef HAS_SHM
     case OP_SHMGET:
-	return shmget(key, n, flags);
+	return shmget(key, (size_t) SvUV(nsv), flags);
 #endif
 #if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
     default:

@p5pRT
Copy link
Author

p5pRT commented Mar 16, 2009

@mhx - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 24, 2009

From ssgo@strastar.com

Dear Marcus

I had compiled perl development version 5.11 with patch file which you gave
me,

and test again with "shmsizetest.pl" script which make more than 2G byte
shared memory on 64bit OS.

It was successfull to create 20G byte with default configuration of SysV on
CentOS x86_64 (RedHat version 5.1 x64)

Thanks your patch

Best regards
Sangsun Go

-----Original Message-----
From​: Marcus Holland-Moritz via RT [mailto​:perlbug-followup@​perl.org]
Sent​: Monday, March 16, 2009 7​:01 PM
Cc​: ssgo@​strastar.com
Subject​: [perl #63924] shmget limited to 32 bit segment size on 64 bit OS

Could you please try to build the development version of perl with the
attached patch applied on top of it and see if that fixes your problem? I
don't have a system where I could test this right now. You can get the
development version either by git or by rsync. For details, see​:

  http​://perl5.git.perl.org/perl.git/blob/HEAD​:/pod/perlhack.pod

Thanks,
Marcus

@p5pRT
Copy link
Author

p5pRT commented Mar 24, 2009

From ssgo@strastar.com

shmsizetest.pl

@p5pRT
Copy link
Author

p5pRT commented Mar 24, 2009

From @mhx

Fixed by the following change​:

http​://perl5.git.perl.org/perl.git/commitdiff/c331296618a8003690577e0901fd07183a76094e

@p5pRT
Copy link
Author

p5pRT commented Mar 24, 2009

@mhx - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant