Skip to content

Test 14study.t fails on Ubuntu 20.04, perl version 5.30, python version 3.8.2: Test 7 got: "1" expected "3" #29

Closed

Description

@hakonhagland
  • OS: Ubuntu 20.04
  • perl version 5.30.0
  • python version 3.8.2

Commands to reproduce:

$ git clone git@github.com:niner/inline-python-pm.git
$ cd inline-python-pm
$ python --version
Python 3.8.2
$ perl --version
This is perl 5, version 30, subversion 0 (v5.30.0) built for x86_64-linux
$ perl Makefile.PL
Found these python executables on your PATH:
1. /home/hakon/.pyenv/shims/python3
2. /home/hakon/.pyenv/shims/python
3. /bin/python3
Use which? [1] 
Using /home/hakon/.pyenv/shims/python3
Using These Settings:
   Extra Libs:  -lcrypt -lpthread -ldl  -lutil -lm
   Python Lib:  -L/home/hakon/.pyenv/versions/3.8.2-debug/lib/python3.8/config-3.8d-x86_64-linux-gnu -lpython3.8d
   Includes:    -I/home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d
   Extra Flags: -DPY_MAJOR_VERSION=3
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Inline::Python
Writing MYMETA.yml and MYMETA.json
$ make
cp Python.pod blib/lib/Inline/Python.pod
cp Python.pm blib/lib/Inline/Python.pm
Running Mkbootstrap for Python ()
chmod 644 "Python.bs"
"/home/hakon/perlbrew/perls/perl-5.30.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Python.bs blib/arch/auto/Inline/Python/Python.bs 644
"/home/hakon/perlbrew/perls/perl-5.30.0/bin/perl" "/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/ExtUtils/xsubpp"  -typemap '/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/ExtUtils/typemap'  Python.xs > Python.xsc
mv Python.xsc Python.c
cc -c  -I/home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"0.56\" -DXS_VERSION=\"0.56\" -fPIC "-I/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE"  -DEXPOSE_PERL -DCREATE_PYTHON -UCREATE_PERL Python.c
In file included from /home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d/Python.h:8,
                 from Python.xs:7:
/home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d/pyconfig.h:1571: warning: "_GNU_SOURCE" redefined
 1571 | #define _GNU_SOURCE 1
      | 
In file included from /home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE/perl.h:28,
                 from Python.xs:4:
/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE/config.h:925: note: this is the location of the previous definition
  925 | #   define _GNU_SOURCE
      | 
Python.xs: In function ‘do_pyinit’:
Python.xs:52:5: warning: implicit declaration of function ‘initperl’ [-Wimplicit-function-declaration]
   52 |     initperl();
      |     ^~~~~~~~
cc -c  -I/home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"0.56\" -DXS_VERSION=\"0.56\" -fPIC "-I/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE"  -DEXPOSE_PERL -DCREATE_PYTHON -UCREATE_PERL py2pl.c
In file included from /home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d/Python.h:8,
                 from py2pl.c:5:
/home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d/pyconfig.h:1571: warning: "_GNU_SOURCE" redefined
 1571 | #define _GNU_SOURCE 1
      | 
In file included from /home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE/perl.h:28,
                 from py2pl.c:2:
/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE/config.h:925: note: this is the location of the previous definition
  925 | #   define _GNU_SOURCE
      | 
py2pl.c: In function ‘croak_python_exception’:
py2pl.c:571:36: warning: format ‘%i’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Wformat=]
  571 |             croak("%s: %s at line %i\n", ((PyTypeObject *)ex_type)->tp_name, c_ex_message, PyInt_AsLong(tb_lineno));
      |                                   ~^
      |                                    |
      |                                    int
      |                                   %li
cc -c  -I/home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"0.56\" -DXS_VERSION=\"0.56\" -fPIC "-I/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE"  -DEXPOSE_PERL -DCREATE_PYTHON -UCREATE_PERL perlmodule.c
In file included from /home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d/Python.h:8,
                 from perlmodule.c:9:
/home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d/pyconfig.h:1571: warning: "_GNU_SOURCE" redefined
 1571 | #define _GNU_SOURCE 1
      | 
In file included from /home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE/perl.h:28,
                 from perlmodule.c:6:
/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE/config.h:925: note: this is the location of the previous definition
  925 | #   define _GNU_SOURCE
      | 
cc -c  -I/home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"0.56\" -DXS_VERSION=\"0.56\" -fPIC "-I/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE"  -DEXPOSE_PERL -DCREATE_PYTHON -UCREATE_PERL util.c
In file included from /home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d/Python.h:8,
                 from util.c:9:
/home/hakon/.pyenv/versions/3.8.2-debug/include/python3.8d/pyconfig.h:1571: warning: "_GNU_SOURCE" redefined
 1571 | #define _GNU_SOURCE 1
      | 
In file included from /home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE/perl.h:28,
                 from util.c:6:
/home/hakon/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux/CORE/config.h:925: note: this is the location of the previous definition
  925 | #   define _GNU_SOURCE
      | 
rm -f blib/arch/auto/Inline/Python/Python.so
cc  -shared -O2 -L/usr/local/lib -fstack-protector-strong  Python.o py2pl.o perlmodule.o util.o  -o blib/arch/auto/Inline/Python/Python.so  \
   -L/home/hakon/.pyenv/versions/3.8.2-debug/lib/python3.8/config-3.8d-x86_64-linux-gnu -lpython3.8d -lcrypt -lpthread -ldl -lutil -lm   \
  
chmod 755 blib/arch/auto/Inline/Python/Python.so
Manifying 1 pod document

$ make test
"/home/hakon/perlbrew/perls/perl-5.30.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Python.bs blib/arch/auto/Inline/Python/Python.bs 644
PERL_DL_NONLAZY=1 "/home/hakon/perlbrew/perls/perl-5.30.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00init.t ................ ok   
t/01testpl.t .............. ok   
t/02testpl.t .............. ok   
t/03parse.t ............... ok   
t/04func.t ................ ok   
t/05JAxH.t ................ ok   
t/06dict.t ................ Unrecognized character \xDD; marked by <-- HERE after age main::<-- HERE near column 15 at (eval 66) line 1.
 at t/06dict.t line 8.
BEGIN failed--compilation aborted at t/06dict.t line 8.
# Looks like your test exited with 255 before it could output anything.
t/06dict.t ................ Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 6/6 subtests 
t/07nherit.t .............. Unrecognized character \xDD; marked by <-- HERE after age main::<-- HERE near column 15 at (eval 7) line 1.
 at t/07nherit.t line 4.
BEGIN failed--compilation aborted at t/07nherit.t line 4.
t/07nherit.t .............. Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 5/5 subtests 
t/08ipyobj.t .............. ok   
t/09bind.t ................ ok   
t/10pyeval.t .............. ok   
t/11factor.t .............. ok       
t/12evnodd.t .............. ok       
t/13fibbon.t .............. ok       
t/14study.t ............... 1/14 # Test 7 got: "1" (t/14study.t at line 30)
#   Expected: "3"
#  t/14study.t line 30 is: ok(scalar keys %{$n{classes}}, 3);
# Test 8 got: "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" (t/14study.t at line 32)
#   Expected: "bone"
#  t/14study.t line 32 is: ok($cls[0], 'bone');
# Test 9 got: <UNDEF> (t/14study.t at line 33)
#   Expected: "comp"
#  t/14study.t line 33 is: ok($cls[1], 'comp');
# Test 10 got: <UNDEF> (t/14study.t at line 34)
#    Expected: "zone"
#  t/14study.t line 34 is: ok($cls[2], 'zone');
# Test 11 got: "0" (t/14study.t at line 37)
#    Expected: "3"
#  t/14study.t line 37 is: ok(scalar @{$n{classes}{comp}}, 3);
# Test 12 got: <UNDEF> (t/14study.t at line 39)
#    Expected: "__init__"
#  t/14study.t line 39 is: ok($fns[0], '__init__');
# Test 13 got: <UNDEF> (t/14study.t at line 40)
#    Expected: "bar"
#  t/14study.t line 40 is: ok($fns[1], 'bar');
# Test 14 got: <UNDEF> (t/14study.t at line 41)
#    Expected: "foo"
#  t/14study.t line 41 is: ok($fns[2], 'foo');
t/14study.t ............... Failed 8/14 subtests 
t/15anon.t ................ ok   
t/16evalpy.t .............. ok     
t/17once.t ................ ok   
t/18newclass.t ............ Unrecognized character \xDD; marked by <-- HERE after age main::<-- HERE near column 15 at (eval 7) line 1.
 at t/18newclass.t line 4.
BEGIN failed--compilation aborted at t/18newclass.t line 4.
t/18newclass.t ............ Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 5/5 subtests 
t/19testref.t ............. ok     
t/20unicode.t ............. ok   
t/21arrayref.t ............ ok     
t/22int.t ................. ok   
t/23getattr.t ............. ok   
t/24getitem.t ............. ok   
t/25py_sub.t .............. Unrecognized character \xDD; marked by <-- HERE after age main::<-- HERE near column 15 at (eval 71) line 1.
 at t/25py_sub.t line 5.
BEGIN failed--compilation aborted at t/25py_sub.t line 5.
# Looks like your test exited with 255 before it could output anything.
t/25py_sub.t .............. Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 17/17 subtests 
t/26undef.t ............... ok   
t/27pyattrs.t ............. Unrecognized character \xDD; marked by <-- HERE after age main::<-- HERE near column 15 at (eval 63) line 1.
 at t/27pyattrs.t line 5.
BEGIN failed--compilation aborted at t/27pyattrs.t line 5.
# Looks like your test exited with 255 before it could output anything.
t/27pyattrs.t ............. Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 14/14 subtests 
t/28exception.t ........... Unrecognized character \xDD; marked by <-- HERE after age main::<-- HERE near column 15 at (eval 69) line 1.
 at t/28exception.t line 7.
BEGIN failed--compilation aborted at t/28exception.t line 7.
# Looks like your test exited with 255 before it could output anything.
t/28exception.t ........... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 9/9 subtests 
t/29named_params.t ........ ok   
t/30floats.t .............. ok   
t/31stringification.t ..... Unrecognized character \xDD; marked by <-- HERE after age main::<-- HERE near column 15 at (eval 64) line 1.
 at t/31stringification.t line 7.
BEGIN failed--compilation aborted at t/31stringification.t line 7.
# Looks like your test exited with 255 before it could output anything.
t/31stringification.t ..... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 3/3 subtests 
t/32boolean.t ............. ok     
t/33reinit.t .............. ok     
t/34env.t ................. ok   
t/35dictunicodememleak.t .. ok   
t/36utfstring.t ........... ok   
t/cmp.t ................... ok   

Test Summary Report
-------------------
t/06dict.t              (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 6 tests but ran 0.
t/07nherit.t            (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 5 tests but ran 0.
t/14study.t             (Wstat: 0 Tests: 14 Failed: 8)
  Failed tests:  7-14
t/18newclass.t          (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 5 tests but ran 0.
t/25py_sub.t            (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 17 tests but ran 0.
t/27pyattrs.t           (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 14 tests but ran 0.
t/28exception.t         (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 9 tests but ran 0.
t/31stringification.t   (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 3 tests but ran 0.
Files=38, Tests=783, 16 wallclock secs ( 0.09 usr  0.02 sys + 14.84 cusr  0.47 csys = 15.42 CPU)
Result: FAIL
Failed 8/38 test programs. 8/783 subtests failed.
make: *** [Makefile:1069: test_dynamic] Error 255

I choose to focus on the first test failure in this issue:

t/14study.t ............... 1/14 # Test 7 got: "1" (t/14study.t at line 30)
#   Expected: "3"
#  t/14study.t line 30 is: ok(scalar keys %{$n{classes}}, 3);

By adding debug print statement in 14study.t I can see that py_study_package on line 16 returns the following hash:

{
    classes     {
        �������������   [
            [0] "__init__",
            [1] "foo",
            [2] "bar"
        ]
    },
    functions   [
        [0] "Foo",
        [1] "bar"
    ]
}

Where the key of the sub hash classes can be printed using printf "%vX\n", $key. This shows that the key contains the bytes:

DD.DD.DD.DD.DD.DD.DD.DD.DD.DD.DD.DD.DD.DD.DD.DD

Activity

  1. niner commented on Jan 8, 2021

    @niner
    Owner

    This is very odd. Those 0xDD seem to appear in many places in that output (like 06dict.t) but the whole distribution doesn't contain a single one of them:

    inline-python-pm (master=)> find . -type f | grep -v '\.git' | xargs hexdump -e '8/1 "%02x_L[red:0xDD] " "\n"' | grep dd
    

    Can you try a different user or machine? Maybe it's something in your environment.

  2. hakonhagland commented on Jan 8, 2021

    @hakonhagland
    ContributorAuthor

    Yes this works fine on a fresh Ubuntu 20.04 VM:

    $ git clone https://github.com/niner/inline-python-pm.git
    $ cd inline-python-pm
    $ perl --version
    This is perl 5, version 30, subversion 0 (v5.30.0) built for x86_64-linux-gnu-thread-multi
    $ python3 --version
    Python 3.8.2
    $ sudo apt-get update
    $ sudo apt-get install python3-dev cpanminus
    $ sudo cpanm --installdeps .
    $ sudo cpanm Parse::RecDescent
    $ perl Makefile.PL
    Found these python executables on your PATH:
    1. /usr/bin/python3
    2. /usr/bin/python
    Using the only python 3 executable I could find even though python 2 was also found
    Set the INLINE_PYTHON_EXECUTABLE environment variable to the full path to your python executable to override this selection.
    Using /usr/bin/python3
    Using These Settings:
       Extra Libs:  -lcrypt -lpthread -ldl  -lutil -lm
       Python Lib:  -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8
       Includes:    -I/usr/include/python3.8
       Extra Flags: -DPY_MAJOR_VERSION=3
    Checking if your kit is complete...
    Looks good
    Generating a Unix-style Makefile
    Writing Makefile for Inline::Python
    Writing MYMETA.yml and MYMETA.json
    $ make
    cp Python.pm blib/lib/Inline/Python.pm
    cp Python.pod blib/lib/Inline/Python.pod
    Running Mkbootstrap for Python ()
    chmod 644 "Python.bs"
    "/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Python.bs blib/arch/auto/Inline/Python/Python.bs 644
    "/usr/bin/perl" "/usr/share/perl/5.30/ExtUtils/xsubpp"  -typemap '/usr/share/perl/5.30/ExtUtils/typemap'  Python.xs > Python.xsc
    mv Python.xsc Python.c
    x86_64-linux-gnu-gcc -c  -I/usr/include/python3.8 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"0.56\" -DXS_VERSION=\"0.56\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.30/CORE"  -DEXPOSE_PERL -DCREATE_PYTHON -UCREATE_PERL Python.c
    Python.xs: In function ‘do_pyinit’:
    Python.xs:52:5: warning: implicit declaration of function ‘initperl’ [-Wimplicit-function-declaration]
       52 |     initperl();
          |     ^~~~~~~~
    x86_64-linux-gnu-gcc -c  -I/usr/include/python3.8 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"0.56\" -DXS_VERSION=\"0.56\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.30/CORE"  -DEXPOSE_PERL -DCREATE_PYTHON -UCREATE_PERL py2pl.c
    py2pl.c: In function ‘croak_python_exception’:
    py2pl.c:571:36: warning: format ‘%i’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Wformat=]
      571 |             croak("%s: %s at line %i\n", ((PyTypeObject *)ex_type)->tp_name, c_ex_message, PyInt_AsLong(tb_lineno));
          |                                   ~^
          |                                    |
          |                                    int
          |                                   %li
    x86_64-linux-gnu-gcc -c  -I/usr/include/python3.8 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"0.56\" -DXS_VERSION=\"0.56\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.30/CORE"  -DEXPOSE_PERL -DCREATE_PYTHON -UCREATE_PERL perlmodule.c
    x86_64-linux-gnu-gcc -c  -I/usr/include/python3.8 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"0.56\" -DXS_VERSION=\"0.56\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.30/CORE"  -DEXPOSE_PERL -DCREATE_PYTHON -UCREATE_PERL util.c
    rm -f blib/arch/auto/Inline/Python/Python.so
    LD_RUN_PATH="/usr/lib/python3.8/config-3.8-x86_64-linux-gnu" x86_64-linux-gnu-gcc  -shared -L/usr/local/lib -fstack-protector-strong  Python.o py2pl.o perlmodule.o util.o  -o blib/arch/auto/Inline/Python/Python.so  \
       -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm   \
      
    chmod 755 blib/arch/auto/Inline/Python/Python.so
    Manifying 1 pod document
    $ make test
    "/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Python.bs blib/arch/auto/Inline/Python/Python.bs 644
    PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
    t/00init.t ................ ok   
    t/01testpl.t .............. ok   
    t/02testpl.t .............. ok   
    t/03parse.t ............... ok   
    t/04func.t ................ ok   
    t/05JAxH.t ................ ok   
    t/06dict.t ................ ok   
    t/07nherit.t .............. ok   
    t/08ipyobj.t .............. ok   
    t/09bind.t ................ ok   
    t/10pyeval.t .............. ok   
    t/11factor.t .............. ok       
    t/12evnodd.t .............. ok       
    t/13fibbon.t .............. ok       
    t/14study.t ............... ok     
    t/15anon.t ................ ok   
    t/16evalpy.t .............. ok     
    t/17once.t ................ ok   
    t/18newclass.t ............ ok   
    t/19testref.t ............. ok     
    t/20unicode.t ............. ok   
    t/21arrayref.t ............ ok     
    t/22int.t ................. ok   
    t/23getattr.t ............. ok   
    t/24getitem.t ............. ok   
    t/25py_sub.t .............. ok     
    t/26undef.t ............... ok   
    t/27pyattrs.t ............. ok     
    t/28exception.t ........... ok   
    t/29named_params.t ........ ok   
    t/30floats.t .............. ok   
    t/31stringification.t ..... ok   
    t/32boolean.t ............. ok     
    t/33reinit.t .............. ok     
    t/34env.t ................. ok   
    t/35dictunicodememleak.t .. ok   
    t/36utfstring.t ........... ok   
    t/cmp.t ................... ok   
    All tests successful.
    Files=38, Tests=842,  7 wallclock secs ( 0.10 usr  0.04 sys +  6.43 cusr  0.47 csys =  7.04 CPU)
    Result: PASS
    
  3. niner commented on Jan 8, 2021

    @niner
    Owner

    Ok, then it really is no issue with Inline::Python but some weirdness in the environment that manages to mightily confuse Perl. Closing.

  4. hakonhagland commented on May 27, 2021

    @hakonhagland
    ContributorAuthor

    Hi. I investigated this a little bit more. I think it could be related to that I use pyenv. It seems that the problem is that the generated shared object Python.so is linked statically with libpython3.9d.a instead of dynamically with libpython3.9d.so when I use the pyenv python. I notice from the output of make that
    if I use the pyenv installed Python 3.9.3, Python.so is generated by the command:

    cc  -shared -O2 -L/usr/local/lib -fstack-protector-strong  Python.o py2pl.o perlmodule.o util.o  \
       -o blib/arch/auto/Inline/Python/Python.so   \
       -L/home/hakon/.pyenv/versions/3.9.3-debug/lib/python3.9/config-3.9d-x86_64-linux-gnu \
       -lpython3.9d -lcrypt -lpthread -ldl -lutil -lm
    

    If I instead use the system python 3.9.4, Python.so is generated using:

    LD_RUN_PATH="/usr/lib/python3.9/config-3.9-x86_64-linux-gnu" cc  -shared -O2 -L/usr/local/lib \
       -fstack-protector-strong  Python.o py2pl.o perlmodule.o util.o  -o blib/arch/auto/Inline/Python/Python.so  \
       -L/usr/lib/python3.9/config-3.9-x86_64-linux-gnu -lpython3.9 -lcrypt -lpthread -ldl -lutil -lm 
    

    Now, there is an interesting difference in the above to library paths:

    • -L/home/hakon/.pyenv/versions/3.9.3-debug/lib/python3.9/config-3.9d-x86_64-linux-gnu, and
    • -L/usr/lib/python3.9/config-3.9-x86_64-linux-gnu

    In the first case there is no shared object libpython3.9d.so in the given path, but for the second case (the system python), there is a shared object /usr/lib/python3.9/config-3.9-x86_64-linux-gnu/libpython3.9.so in the path.

    I think that in the first case, since the .so is missing, the cc command is using the static library /home/hakon/.pyenv/versions/3.9.3-debug/lib/python3.9/config-3.9d-x86_64-linux-gnu/libpython3.9d.a instead.

    I checked Makefile.PL, and I see that on line 154 it is using the config variable LIBPL to locate the directory of libpython.so. However, there is another config variable called LIBDIR, see this Q&A, which works correctly for me. Compare
    for the pyenv python:

    $ python3 -c "from distutils import sysconfig; print('LIBDIR={}'.format(sysconfig.get_config_var('LIBDIR'))); print('LIBPL={}'.format(sysconfig.get_config_var('LIBPL')))"
    LIBDIR=/home/hakon/.pyenv/versions/3.9.3-debug/lib
    LIBPL=/home/hakon/.pyenv/versions/3.9.3-debug/lib/python3.9/config-3.9d-x86_64-linux-gnu
    

    and for the system python:

    $ python3 -c "from distutils import sysconfig; print('LIBDIR={}'.format(sysconfig.get_config_var('LIBDIR'))); print('LIBPL={}'.format(sysconfig.get_config_var('LIBPL')))"
    LIBDIR=/usr/lib/x86_64-linux-gnu
    LIBPL=/usr/lib/python3.9/config-3.9-x86_64-linux-gnu
    

    In both cases above, the shared object exists in LIBDIR. Maybe Makefile.PL needs to be patched to use LIBDIR instead of LIBPL ?

  5. added a commit that references this issue on Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions