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

Problem with semctl() on Perl 5.8.6, 64-bit build, HP-UX 11i #8025

Open
p5pRT opened this issue Jul 18, 2005 · 7 comments
Open

Problem with semctl() on Perl 5.8.6, 64-bit build, HP-UX 11i #8025

p5pRT opened this issue Jul 18, 2005 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 18, 2005

Migrated from rt.perl.org#36588 (status was 'open')

Searchable as RT36588$

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2005

From novotny.petr@volny.cz

Created by petrn@amdocs.com

Hi,

I ran into a problem with semctl() on our Perl 5.8.6. SETVAL does
not seem to do the right thing. The call suceeds, but subsequent
calls to GETVAL and GETALL return 0, and an attempt to lock waits
forever. The code snippet below prints correct "1" on 32-bit build
of Perl 5.6.1, but prints incorrect "0" on 64-bit build of Perl
5.8.6.

use strict;
use IPC​::SysV qw(IPC_NOWAIT SEM_UNDO S_IRWXU IPC_CREAT IPC_EXCL
SETVAL GETALL); my $InstanceLock = semget( 123456, 1,
S_IRWXU|IPC_CREAT|IPC_EXCL ); unless ($InstanceLock) { die "Failed
to create new semaphore​: $!\n"; } print "Created new semaphore\n";
unless (semctl($InstanceLock,0,SETVAL,1)) { die "Failed to setval​:
$!\n"; } my $data = ""; unless
(semctl($InstanceLock,0,GETALL,$data)) { die "Failed to getval​:
$!\n"; } my @​getall = unpack("s!*",$data); print @​getall,"\n";

Output from 5.6.1 (32-bit)​:
Created new semaphore
1

Output from 5.8.6 (64-bit)​:
Created new semaphore
0

(Of course, I called ipcrm between the two tests to delete the
semaphore. I'm saying this just in case :-))

Thanks,

  Petr Novotny
  petrn@​amdocs.com

Perl Info

Flags:
    category=core
    severity=high

Site configuration information for perl v5.8.6:

Configured by urbang at Tue May 31 11:37:17 METDST 2005.

Summary of my perl5 (revision 5 version 8 subversion 6)
configuration:   Platform:
    osname=hpux, osvers=11.11, archname=PA-RISC2.0-LP64
    uname='hp-ux hpl2pdc b.11.11 u 9000800 179404641 unlimited-user
license '     config_args='-A prepend:libswanted=cl pthread 
-Duse64bitall'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef     useperlio=define d_sfio=undef
uselargefiles=define usesocks=undef     use64bitint=define
use64bitall=define uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags =' -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings
+DD64 -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 ',     optimize='+O2 +Onolimit',
    cppflags='-Aa -D__STDC_EXT__ -D_HPUX_SOURCE -Ae -D_HPUX_SOURCE
-Wl,+vnocompatwarnings +DD64 -I/usr/local/include'    
ccversion='B.11.11.08', gccversion='', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8,
byteorder=87654321     d_longlong=define, longlongsize=8,
d_longdbl=define, longdblsize=16     ivtype='long', ivsize=8,
nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8    
alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/usr/bin/ld', ldflags =' +DD64 -L/usr/local/lib
-L/lib/pa20_64'     libpth=/usr/local/lib /lib/pa20_64 /lib
/usr/lib /usr/ccs/lib
    libs=-lcl -lpthread -lnsl -lnm -ldl -ldld -lm -lsec -lc
    perllibs=-lcl -lpthread -lnsl -lnm -ldl -ldld -lm -lsec -lc
    libc=/lib/pa20_64/libc.sl, so=sl, useshrplib=true,
libperl=libperl.sl     gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E
-Wl,-B,deferred '     cccdlflags='+Z', lddlflags='-b
+vnocompatwarnings -L/usr/local/lib -L/lib/pa20_64'

Locally applied patches:
    


@INC for perl v5.8.6:
    /usr/local/perl586/lib/5.8.6/PA-RISC2.0-LP64
    /usr/local/perl586/lib/5.8.6
    /usr/local/perl586/lib/site_perl/5.8.6/PA-RISC2.0-LP64
    /usr/local/perl586/lib/site_perl/5.8.6
    /usr/local/perl586/lib/site_perl
    .


Environment for perl v5.8.6:
    HOME=/pneusr.l2pdc/pne/dev/petrne
    LANG (unset)
    LANGUAGE (unset)
   
LD_LIBRARY_PATH=/pneusr.l2pdc/pne/dev/petrne/proj/cmf550V64/lib:/pnechome/pne/ccpne/ccpne/proj/cmf550V64/lib:/usr/local64/gmp-4.1.2/lib::/oravl01/oracle/9.2.0.6/lib:/opt/cobol/cobdir/coblib:/opt/syncsort64.3.4/lib:/usr/lib/pa20_64:/usr/lib:/opt/TimesTen/tt5034_64/lib
    LOGDIR (unset)
   
PATH=/usr/local/ccmngr_p/ccgnrl/v10/bin:/opt/imake/bin:/opt/java1.4/bin:/pnechome/pne/ccpne/ccpne/proj/gatl550V64/bin:/pnechome/pne/ccpne/ccpne/proj/ginftl550V64/bin:/oravl01/oracle/9.2.0.6:/oravl01/oracle/9.2.0.6/bin:/pneusr.l2pdc/pne/dev/petrne/proj/cmf550V64/bin:/pnechome/pne/ccpne/ccpne/proj/cmf550V64/bin:/pneusr.l2pdc/pne/dev/petrne/proj/gmf550V64/bin:/pnechome/pne/ccpne/ccpne/proj/gmf550V64/bin:/pnechome/pne/ccpne/ccpne/proj/ggen550V64/bin:/pneusr.l2pdc/pne/dev/petrne/proj/mfgdd550V64/bin:/pnechome/pne/ccpne/ccpne/proj/mfgdd550V64/bin:/usr/local/ccmngr_p/ccgnrl/v10/bin:/oravl01/oracle/9.2.0.6:/oravl01/oracle/9.2.0.6/bin:/pnechome/pne/ccpne/ccpne/proj/gatl550/bin:/pnechome/pne/ccpne/ccpne/proj/ginftl550/bin:/usr/local/bin:/opt/ansic/bin:/usr/bin:/usr/contrib/bin:/usr/contrib/bin/X11:/usr/vue/bin:/usr/bin/X11:/bin:/opt/langtools/bin:/usr/ccs/bin:/opt/perf/bin:/etc:/usr/local/ccmngr_p/bin:/pneusr.l2pdc/pne/dev/petrne/bin:/opt/softbench/bin:/usr/sbin:.:/opt/syncsort64.3.4/b
 in:/usr/local/xerces-c2_1_0_32b:/opt/syncsort64.3.4/bin
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh


-----


@p5pRT
Copy link
Author

p5pRT commented Jul 19, 2005

From @nwc10

On Mon, Jul 18, 2005 at 07​:04​:03AM -0700, novotny. petr @​ volny. cz wrote​:

Output from 5.6.1 (32-bit)​:
Created new semaphore
1

Output from 5.8.6 (64-bit)​:
Created new semaphore
0

(Of course, I called ipcrm between the two tests to delete the
semaphore. I'm saying this just in case :-))

That's useful, as it's the sort of thing that people forget.
(Well, I would)

Are you able to build 5.8.5 32-bit on your machine? This would make it clear
whether it's a 5.6 -> 5.8 issue, or a 32 bit / 64 bit issue.

My hunch is that it's something to do with big endian 64 bit builds (and
pack templates or maybe structure alignment) but it would be good to test
this.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jul 19, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 19, 2005

From novotny.petr@volny.cz

Hi,

your guess matches my guess.

Generally speaking, I can compile small snippets of C code without
problem, but I'm going to run into resource limits if I try to
build something as big as Perl. (If you know of a 32-bit 5.8.x Perl
build in an HP-UX depot, I will ask our admin to install it,
though.)

What I thought I'd try is to take a look at the Perl code handling
the sem*() calls. Haven't do that yet...

I'll keep you updated.

----- PŮVODNÍ ZPRÁVA -----
Od​: "Nicholas Clark via RT" <perlbug-followup@​perl.org>
Komu​: novotny.petr@​volny.cz
Předmět​: Re​: [perl #36588] Problem with semctl() on Perl 5.8.6,
Datum​: 19.7.2005 - 12​:09​:18

On Mon, Jul 18, 2005 at 07​:04​:03AM -0700, novotny. petr @​
volny. cz wrote​:

Output from 5.6.1 (32-bit)​:
Created new semaphore
1

Output from 5.8.6 (64-bit)​:
Created new semaphore
0

(Of course, I called ipcrm between the two tests to delete
the
semaphore. I'm saying this just in case :-))

That's useful, as it's the sort of thing that people forget.
(Well, I would)

Are you able to build 5.8.5 32-bit on your machine? This would
make it clear
whether it's a 5.6 -> 5.8 issue, or a 32 bit / 64 bit issue.

My hunch is that it's something to do with big endian 64 bit
builds (and
pack templates or maybe structure alignment) but it would be
good to test
this.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jul 19, 2005

From @nwc10

On Tue, Jul 19, 2005 at 04​:55​:25PM +0200, novotny.petr@​volny.cz wrote​:

Hi,

your guess matches my guess.

Generally speaking, I can compile small snippets of C code without
problem, but I'm going to run into resource limits if I try to
build something as big as Perl. (If you know of a 32-bit 5.8.x Perl
build in an HP-UX depot, I will ask our admin to install it,
though.)

I can only find gcc built perls for HP-UX

What I thought I'd try is to take a look at the Perl code handling
the sem*() calls. Haven't do that yet...

I can't replicate the problem with 5.8.6 built with 64 bit ints on OS X
(So it's not a general big endian problem)

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jul 20, 2005

From novotny.petr@volny.cz

Hi,

I'd hate to be wrong, but I think I can see the error in doio.c​:

The code performs INT2PTR on "a", enlarging it to a 64-bit char*.
Since we're on a big-Endian machine, it means it is padded with
zeroes on the left side. Then it moves "a" into "union semun".buf.
However, SETVAL works in the "val" member of "union semun". Since
this "val" is 32-bit and since we are on big-Endian, this "val" is
always going to be zero. Quod erad demonstrandum :-)

I wouldn't go so far as to suggest you a fix, but I think that
you'll need a special branch for SETVAL (the only semctl() case
that actually works on "union semun".val.

Please comment.

Regards,
  Petr Novotny
  petrn@​amdocs.com

----- PŮVODNÍ ZPRÁVA -----
Od​: "Nicholas Clark via RT" <perlbug-followup@​perl.org>
Komu​: novotny.petr@​volny.cz
Předmět​: Re​: [perl #36588] Problem with semctl() on Perl 5.8.6,
Datum​: 19.7.2005 - 12​:09​:18

On Mon, Jul 18, 2005 at 07​:04​:03AM -0700, novotny. petr @​
volny. cz wrote​:

Output from 5.6.1 (32-bit)​:
Created new semaphore
1

Output from 5.8.6 (64-bit)​:
Created new semaphore
0

(Of course, I called ipcrm between the two tests to delete
the
semaphore. I'm saying this just in case :-))

That's useful, as it's the sort of thing that people forget.
(Well, I would)

Are you able to build 5.8.5 32-bit on your machine? This would
make it clear
whether it's a 5.6 -> 5.8 issue, or a 32 bit / 64 bit issue.

My hunch is that it's something to do with big endian 64 bit
builds (and
pack templates or maybe structure alignment) but it would be
good to test
this.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jul 20, 2005

From novotny.petr@volny.cz

It's a problem on big-Endian when sizeof(int)!=sizeof(short*). HP-UX
has 32-bit integer and 64-bit pointers, therefore the failure.

----- PŮVODNÍ ZPRÁVA -----
Od​: "Nicholas Clark via RT" <perlbug-followup@​perl.org>
Komu​: novotny.petr@​volny.cz
Předmět​: Re​: [perl #36588] Problem with semctl() on Perl 5.8.6,
Datum​: 19.7.2005 - 23​:09​:30

On Tue, Jul 19, 2005 at 04​:55​:25PM +0200, novotny.petr@​volny.cz
wrote​:

Hi,

your guess matches my guess.

Generally speaking, I can compile small snippets of C code
without
problem, but I'm going to run into resource limits if I try
to
build something as big as Perl. (If you know of a 32-bit
5.8.x Perl
build in an HP-UX depot, I will ask our admin to install it,
though.)

I can only find gcc built perls for HP-UX

What I thought I'd try is to take a look at the Perl code
handling
the sem*() calls. Haven't do that yet...

I can't replicate the problem with 5.8.6 built with 64 bit ints
on OS X
(So it's not a general big endian problem)

Nicholas Clark

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

2 participants