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

test t/io/sem fails on Mac PPC64 #22415

Closed
gsteemso opened this issue Jul 18, 2024 · 26 comments
Closed

test t/io/sem fails on Mac PPC64 #22415

gsteemso opened this issue Jul 18, 2024 · 26 comments

Comments

@gsteemso
Copy link

Description
It was easy enough, with minor tweaks to CFLAGS, to build Perl in 64-bit mode on my Power Mac G5 – but something is not quite right in the semaphore handling. Running the test suite produces failures with no obvious cause at steps 6, 7, and 9 of t/io/sem.t. The exact output is:


# Failed test 6 - Checking value of semaphore 3 at io/sem.t line 70
#      got "0"
# expected "192"
# Failed test 7 - Check value via GETVAL at io/sem.t line 73
#      got "0 but true"
# expected "192"
# Failed test 9 - Checking value of semaphore 3 after fetch into originally UTF-8 buffer at io/sem.t line 82
#      got "0"
# expected "192"
FAILED at test 6

Steps to Reproduce
From the top-level directory,


cd t
./perl -I../lib harness io/sem.t

Expected behavior
All three sub-tests are apparently supposed to return the value 192.

Perl configuration


Nosferalto:perl-5.40.0 gsteemso$ ./perl -Ilib -V
Summary of my perl5 (revision 5 version 40 subversion 0) configuration:
   
  Platform:
    osname=darwin
    osvers=9.8.0
    archname=darwin-thread-multi-2level
    uname='darwin nosferalto.local 9.8.0 darwin kernel version 9.8.0: wed jul 15 16:57:01 pdt 2009; root:xnu-1228.15.4~1release_ppc power macintosh powerpc '
    config_args='-des -Dprefix=/Users/Shared/Brewery/Cellar/perl/5.40.0 -Uvendorprefix= -Dprivlib=/Users/Shared/Brewery/Cellar/perl/5.40.0/lib -Darchlib=/Users/Shared/Brewery/Cellar/perl/5.40.0/lib -Dman1dir=/Users/Shared/Brewery/Cellar/perl/5.40.0/share/man/man1 -Dman3dir=/Users/Shared/Brewery/Cellar/perl/5.40.0/share/man/man3 -Dman3ext=3pl -Dsitelib=/Users/Shared/Brewery/Cellar/perl/5.40.0/lib/site_perl -Dsitearch=/Users/Shared/Brewery/Cellar/perl/5.40.0/lib/site_perl -Dsiteman1dir=/Users/Shared/Brewery/Cellar/perl/5.40.0/share/man/man1 -Dsiteman3dir=/Users/Shared/Brewery/Cellar/perl/5.40.0/share/man/man3 -Dperladmin=none -Dstartperl='#!/usr/local/opt/perl/bin/perl' -Duseshrplib -Duselargefiles -Dusenm -Dusethreads -Acppflags=-m64 -Duse64bitall'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-std=gnu99 -fno-common -DPERL_DARWIN -mmacosx-version-min=10.5 -DNO_THREAD_SAFE_QUERYLOCALE -DNO_POSIX_2008_LOCALE -arch ppc64 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_FORTIFY_SOURCE=2'
    optimize='-O3'
    cppflags='-arch ppc64 -m64 -std=gnu99 -fno-common -DPERL_DARWIN -mmacosx-version-min=10.5 -DNO_THREAD_SAFE_QUERYLOCALE -DNO_POSIX_2008_LOCALE -arch ppc64 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion=''
    gccversion='4.2.1 (Apple Inc. build 5666) (dot 3)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=87654321
    doublekind=4
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=6
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc -arch ppc64'
    ldflags =' -mmacosx-version-min=10.5 -arch ppc64 -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-lpthread -ldbm -ldl -lm -lutil -lc
    perllibs=-lpthread -ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib
    so=dylib
    useshrplib=true
    libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=10.5 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
  Built under darwin
  Compiled at Jul 18 2024 08:47:34
  @INC:
    /Users/Shared/Brewery/Cellar/perl/5.40.0/lib/site_perl
    /Users/Shared/Brewery/Cellar/perl/5.40.0/lib


@jkeenan
Copy link
Contributor

jkeenan commented Jul 20, 2024

Description It was easy enough, with minor tweaks to CFLAGS, to build Perl in 64-bit mode on my Power Mac G5 – but something is not quite right in the semaphore handling. Running the test suite produces failures with no obvious cause at steps 6, 7, and 9 of t/io/sem.t. The exact output is:


# Failed test 6 - Checking value of semaphore 3 at io/sem.t line 70
#      got "0"
# expected "192"
# Failed test 7 - Check value via GETVAL at io/sem.t line 73
#      got "0 but true"
# expected "192"
# Failed test 9 - Checking value of semaphore 3 after fetch into originally UTF-8 buffer at io/sem.t line 82
#      got "0"
# expected "192"
FAILED at test 6

Steps to Reproduce From the top-level directory,


cd t
./perl -I../lib harness io/sem.t

Expected behavior All three sub-tests are apparently supposed to return the value 192.

Perl configuration


Nosferalto:perl-5.40.0 gsteemso$ ./perl -Ilib -V
Summary of my perl5 (revision 5 version 40 subversion 0) configuration:
   
  Platform:
    osname=darwin
    osvers=9.8.0
    archname=darwin-thread-multi-2level
    uname='darwin nosferalto.local 9.8.0 darwin kernel version 9.8.0: wed jul 15 16:57:01 pdt 2009; root:xnu-1228.15.4~1release_ppc power macintosh powerpc '
    config_args='-des -Dprefix=/Users/Shared/Brewery/Cellar/perl/5.40.0 -Uvendorprefix= -Dprivlib=/Users/Shared/Brewery/Cellar/perl/5.40.0/lib -Darchlib=/Users/Shared/Brewery/Cellar/perl/5.40.0/lib -Dman1dir=/Users/Shared/Brewery/Cellar/perl/5.40.0/share/man/man1 -Dman3dir=/Users/Shared/Brewery/Cellar/perl/5.40.0/share/man/man3 -Dman3ext=3pl -Dsitelib=/Users/Shared/Brewery/Cellar/perl/5.40.0/lib/site_perl -Dsitearch=/Users/Shared/Brewery/Cellar/perl/5.40.0/lib/site_perl -Dsiteman1dir=/Users/Shared/Brewery/Cellar/perl/5.40.0/share/man/man1 -Dsiteman3dir=/Users/Shared/Brewery/Cellar/perl/5.40.0/share/man/man3 -Dperladmin=none -Dstartperl='#!/usr/local/opt/perl/bin/perl' -Duseshrplib -Duselargefiles -Dusenm -Dusethreads -Acppflags=-m64 -Duse64bitall'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-std=gnu99 -fno-common -DPERL_DARWIN -mmacosx-version-min=10.5 -DNO_THREAD_SAFE_QUERYLOCALE -DNO_POSIX_2008_LOCALE -arch ppc64 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_FORTIFY_SOURCE=2'
    optimize='-O3'
    cppflags='-arch ppc64 -m64 -std=gnu99 -fno-common -DPERL_DARWIN -mmacosx-version-min=10.5 -DNO_THREAD_SAFE_QUERYLOCALE -DNO_POSIX_2008_LOCALE -arch ppc64 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion=''
    gccversion='4.2.1 (Apple Inc. build 5666) (dot 3)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=87654321
    doublekind=4
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=6
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc -arch ppc64'
    ldflags =' -mmacosx-version-min=10.5 -arch ppc64 -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-lpthread -ldbm -ldl -lm -lutil -lc
    perllibs=-lpthread -ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib
    so=dylib
    useshrplib=true
    libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=10.5 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
  Built under darwin
  Compiled at Jul 18 2024 08:47:34
  @INC:
    /Users/Shared/Brewery/Cellar/perl/5.40.0/lib/site_perl
    /Users/Shared/Brewery/Cellar/perl/5.40.0/lib

Can you determine at what commit or release of Perl this test failure first appeared on your machine?

@tonycoz
Copy link
Contributor

tonycoz commented Jul 22, 2024

Do you see these failures in older perls?

There hasn't been a substantive change here since November 2020.

@sisyphus
Copy link
Contributor

I notice that the OP's system is big-endian, and wonder whether the problem is somehow related to the "64 bit big-endian semctl SETVAL bug" mentioned a few lines earlier (line 53) in t/io/sem.t.
Annoyingly my PPC64 box died a few years ago.

@gsteemso
Copy link
Author

I had noticed that same remark, but have not yet had time to dig into this any further. Given how long it takes to build stuff on a 2GHz machine from 20 years ago, I'd like to strategically build as few distinct versions of Perl as I can to get the answer to jkeenan's and tonycoz' questions above. Does anyone know offhand where I'd look to find out what version of Perl was being worked on when those last substantive changes were made? And do you want to hear about odd-numbered development releases or just the even-numbered production releases?

@tonycoz
Copy link
Contributor

tonycoz commented Jul 22, 2024

Does anyone know offhand where I'd look to find out what version of Perl was being worked on when those last substantive changes were made?

The change I was thinking of was d43c116 which was first in 5.34.

And do you want to hear about odd-numbered development releases or just the even-numbered production releases?

5.even.0 seems reasonable to me. If you're working from a git checkout

I notice that the OP's system is big-endian, and wonder whether the problem is somehow related to the "64 bit big-endian semctl SETVAL bug" mentioned a few lines earlier (line 53) in t/io/sem.t.

I don't think so, with the change that fixed that (64d7628 first in 5.20.0) we always go through the val member of union semun for SETVAL, and we use either the system defined union semun or one that matches the man semctl pages for Linux, current OS X and FreeBSD.

@gsteemso
Copy link
Author

I have now verified that 5.34.0 produces the same result. Currently waiting for free time in which to test 5.32.1.

@gsteemso
Copy link
Author

(A comment on my earlier concern about build times... I found that the actual builds go quite quickly indeed; but the tests, on the other hand, take a very long time simply because there are so many of them.)

@gsteemso
Copy link
Author

gsteemso commented Jul 26, 2024

Differing somewhat from 5.34.0, 5.32.1 produces similar results to every subsequent version, but the specifics of the failure are different:

# Failed test 6 - Checking value of semaphore 3 at io/sem.t line 66
# got "0"
# expected "17"
# Failed test 7 - Checking value via GETVAL at io/sem.t line 69
# got "0 but true"
# expected "17"
FAILED at test 6

Further investigation reveals that the difference in expected values was merely a change in the constants in the test file, and test 9 didn't fail because it didn't exist yet. Ultimately, there was in fact no change.

I will continue testing my way backwards in time to see if this ever does change at any point. My immediately-next tests will be of 5.20.0 and 5.18.0, bracketing when that big-endian-64-bit bug was stated to have been addressed... assuming that the test existed at that time. If it didn't, I will copy the version from 5.34.0 (which is identical to the current one, save for using slightly older syntax at the Config import).

At some version, I will not be able to go further backwards, as 64-bit Mac OS was not a thing before a certain point and I can't see how Perl could have been ready to compile for it in advance. “No time machines were harmed in the making of this software”, etc. ...It will be interesting to see just how far it can be pushed back, around or even past that point in history.

@gsteemso
Copy link
Author

Well, 5.18.0 suffers a wide array of failures in this test, as well as raising numerous compiler warnings that were improved away in later editions of Perl. (I did indeed need to copy the t/io/sem.t from Perl 5.34, as well as editing it to set @INC directly rather than through a convenience function.) The failures were in tests 9-11, 13, 17-20, and 22. It also complained of malformed UTF-8 at line 81. This shows that, as annoying as the current test failure is, it used to be so much worse! I also find it interesting that tests 6 and 7 passed on that elderly version of Perl, but fail on more modern ones.

@tonycoz
Copy link
Contributor

tonycoz commented Jul 29, 2024

You can run just the io/sem.t test:

make test TEST_FILES=io/sem.t

If you've already built perl you can just do:

./perl t/io/sem.t

which is safe for this test (but not all tests)

You might be running into the limits of testing older versions.

With blead or 5.40, please add the two lines as follows:

diff --git a/t/io/sem.t b/t/io/sem.t
index 30beafabfd..7d3637970a 100644
--- a/t/io/sem.t
+++ b/t/io/sem.t
@@ -63,6 +63,8 @@ $SIG{__WARN__} = sub { push @warnings, "@_"; print STDERR @_; };
     ok(semctl($id, $ignored, GETALL, $semvals),
        'Get current semaphore values');
 
+    use Devel::Peek;
+    Dump($semvals);
     my @semvals = unpack("s!*", $semvals);
     is(scalar(@semvals), $nsem, 
        "Make sure we get back statuses for all $nsem semaphores");

and run:

./perl t/io/sem.t

The result should include a dump of $semvals, something like:

...
ok 4 - Get current semaphore values
SV = PV(0x55b8fdc2e1f0) at 0x55b8fdeab450
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x55b8fdebc2d0 "\x00\x00\x00\x00\x00\x00\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\0
  CUR = 20
  LEN = 22
ok 5 - Make sure we get back statuses for all 10 semaphores
...

which we can use to see if any semaphore values are coming through at all.

If this isn't returning something some sort of sensible we'll need to:

  • make a simple C test case to see if it works sensibly there, if it does
  • make a simpler perl test case and debug that with gdb

@gsteemso
Copy link
Author

gsteemso commented Aug 1, 2024

Tonycoz, your suspicions were correct -- I tried your variable-dumping recommendation, using the test file from 5.40.0 with the minimum changes needed to make it parse in each case, on numerous versions of perl going back to 5.12.5; and everything since 5.20.0 seems to produce a vector composed entirely of nulls for the semaphore values. I’m pretty sure that’s not what it’s supposed to look like.
(This probably doesn’t help much, but 5.12.5 and 5.18.4 both instead produced this vector: \0\0\0\0\0\0\0\300\0\0\0\0\0\0\0\0\0\0 )
I don’t know enough about the guts of Perl to help with the C test case you mentioned, and as you may have inferred from the pace of my replies here, I don’t really have any time to read up on it. If there are any other variables I can usefully dump (or other points in time at which to dump that one) in tests such as I have been doing, please let me know.

@gsteemso
Copy link
Author

gsteemso commented Aug 1, 2024

Unsurprisingly, 5.41.2 gave exactly the same results as well.

@gsteemso
Copy link
Author

gsteemso commented Aug 4, 2024

I have also verified that 32-bit PPC builds behave correctly in this test.

@tonycoz
Copy link
Contributor

tonycoz commented Aug 5, 2024

Are you building perl from tarballs or from a git clone?

@gsteemso
Copy link
Author

Apologies, I did not see your reply until now. I had been building from tarballs, but I was recently introduced to the wonders of Porting/bisect.pl so I will be running that tonight.

@gsteemso
Copy link
Author

gsteemso commented Sep 1, 2024

I had significant delays due to an ill-advised Git upgrade that went awry, but I finally have a result here. Unsurprisingly, bisection reveals the first commit that returns all zeroes on the semaphore tests on my 64-bit Power Mac to be #64d7628235943ff18939a1ff98ace513aeb5260c, from December 2013. The log message says, “Fixes the case where on 64bit big-endian boxes, calls to semctl(id,semnum,SETVAL,$wantedval) will ignore the passed in $wantedval, and always use 0”.

The actual content of the commit is almost entirely contained in the test case. The code change to Perl itself consists of seven lines added to, and two removed from, doio.c.

The evidence suggests this fix was not entirely correct, but I do not know what details would explain how or why. I am insufficiently versed in Git to extract what doio.c looked like before vs. after that commit.

@mauke
Copy link
Contributor

mauke commented Sep 1, 2024

Putting this here to get a fancy github link: 64d7628

I am insufficiently versed in Git to extract what doio.c looked like before vs. after that commit.

To get a diff, try git show 64d7628235943ff18939a1ff98ace513aeb5260c. At least on my system, the output contains:

diff --git doio.c doio.c
index 98e2c42024..b39c5876bd 100644
--- doio.c
+++ doio.c
@@ -2155,11 +2155,16 @@ Perl_do_ipcctl(pTHX_ I32 optype, SV **mark, SV **sp)
 #ifdef Semctl
             union semun unsemds;
 
+            if(cmd == SETVAL) {
+                unsemds.val = PTR2nat(a);
+            }
+            else {
 #ifdef EXTRA_F_IN_SEMUN_BUF
-            unsemds.buff = (struct semid_ds *)a;
+                unsemds.buff = (struct semid_ds *)a;
 #else
-            unsemds.buf = (struct semid_ds *)a;
+                unsemds.buf = (struct semid_ds *)a;
 #endif
+            }
            ret = Semctl(id, n, cmd, unsemds);
 #else
            /* diag_listed_as: sem%s not implemented */

Otherwise:

git show 64d7628235943ff18939a1ff98ace513aeb5260c:doio.c >doio-after-commit.c
git show 64d7628235943ff18939a1ff98ace513aeb5260c^:doio.c >doio-before-commit.c

@tonycoz
Copy link
Contributor

tonycoz commented Sep 2, 2024

The change itself looks correct to me, though it's technically undefined behaviour (making a pointer from a random integer, even if we don't dereference it).

Before the change the integer (like the test 3) would be converted to a 64-bit pointer and stored in unsemds.buf, giving a memory layout like:

00 00 00 00 00 00 00 03

on PPC64, but because SETVAL expects the 4 byte/32-bit val member, it would only see the 4 zeroes.

After the change it would convert the integer to a pointer and then back to and integer and store that value in val, which should be safe,

I suspect a compiler bug.

You might try:

  • build with -O2 or -O1 (-Doptimize=-O1)
  • build with debugging info and try stepping through the code to see what happens to the values of i, a and unsemfs.val, though I suspect that's outside your comfort zone.

@gsteemso
Copy link
Author

gsteemso commented Sep 2, 2024

I copied the function’s code into a new file, looked up all of the preprocessor macros and equates, and produced four copies of the function body, revealing what the C compiler actually sees for each of the four command values used by Perl. I haven't finished yet – for one thing, I have yet to produce a fifth copy following the logic if any other value is used – but already I've found two “showstopper” bugs in that commit that make it only work by accident, if it works at all. I have yet to check whether they are still present in blead. I will report further when I get it all finished.

@gsteemso
Copy link
Author

gsteemso commented Sep 3, 2024

Yup, both problems are still present in blead. First, on doio.c line 3194, the command tested for is SETVAL, rather than the expected IPC_SET. Second, on line 3195, the pointer to the SV is cast to an integer instead of an IV being extracted from the SV. From what I can see, that's not how it's supposed to work at this level of abstraction. (Compare with the similar operation at lines 3173-3176, carried out for unrecognized commands.)

@gsteemso
Copy link
Author

gsteemso commented Sep 3, 2024

Fixing both of those things caused the semaphore test to pass without a hitch. An attempt to copy the patch by hand follows:

--- old/doio.c
+++ new/doio.c
@@ -3191,8 +3191,8 @@
 #ifdef Semctl
             union semun unsemds;
 
-            if(cmd == SETVAL) {
-                unsemds.val = PTR2nat(a);
+            if(cmd == IPC_SET) {
+                unsemds.val = SvIV(a);
             }

             else {
 #ifdef EXTRA_F_IN_SEMUN_BUF

@gsteemso
Copy link
Author

gsteemso commented Sep 3, 2024

I should add that my patch-and-verify was carried out against blead. Is there a way to turn that post into a pull request without having to start over from scratch?

@gsteemso
Copy link
Author

gsteemso commented Sep 3, 2024

d'oh! That should have been SvIV(astr) rather than SvIV(a) on line 3195.

@tonycoz
Copy link
Contributor

tonycoz commented Sep 4, 2024

If you step through the original code for the mis-behaving call, does it go via the if (infosize) branch, or the code that calls SvIV_nomg()?

From my understanding of the code a is initialized:

        if (SvOK(astr)) {
            const IV i = SvIV_nomg(astr);
            a = INT2PTR(char *,i);		/* ouch */
        }
        else {
            a = NULL;
        }

If this code is being executed on your system it should be setting unsemds.val correctly.

If this code isn't being executed on your system we have another problem.

Note that this code has been tested on other 64-bit big-endian hardware.

As written your suggested change invokes magic twice on the parameter (changing your suggestion to SvIV_nomg() could still invoke overload magic a second time).

@gsteemso
Copy link
Author

gsteemso commented Sep 4, 2024

I had examined my changes in light of the way the code looked at the time of the old edit we were discussing, and in my enthusiasm did not notice just what else had changed in the rest of the function between then and now. Worse, I now see I completely misunderstood the usage of this function; the test for SETVAL was correct. I still maintain that the value in the SV was the intended operand and not its raw address, but I missed the bit you point out where it had already been extracted (a peril of getting the revisions muddled while flipping between files). Back to the drawing board.

You are completely correct that the changes I proposed should not have fixed the problem as comprehensively as is the case. I am currently investigating further.

@gsteemso
Copy link
Author

gsteemso commented Sep 7, 2024

There seems no way for me to debug this properly, as GDB does not appear to have ever been built to understand 64-bit PowerPC under Darwin – only under Linux, which apparently has different calling conventions – and I can't find mention of any other applicable debugger, but as far as I can tell, you're almost certainly right about it being a deficiency in the compiler. The only reason my "fix" seemed to work is that it covered up the compiler bug with a control-flow bug, making everything be treated as pointers regardless of what was supposed to be done, and therefore not suffering alignment issues because the sizes matched.

In short, this is not a Perl bug. Marking it closed.

@gsteemso gsteemso closed this as completed Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants