PerlFFI / FFI-Platypus

Write Perl bindings to non-Perl libraries with FFI. No XS required.
89 stars 23 forks source link

Test failures on CentOS 6..8 #287

Closed toddr closed 3 years ago

toddr commented 3 years ago

I'm seeing the following failures trying to build FFI::Platypus on CentOS 6..8

$>prove -wbvm t/ffi_platypus_record_meta.t
t/ffi_platypus_record_meta.t .. 
Name "FFI::Platypus::TypeParser::ffi_type" used only once: possible typo at /usr/local/cpanel/3rdparty/perl/530/lib/perl5/5.30.0/x86_64-linux-64int/DynaLoader.pm line 207.
Name "FFI::Platypus::keep" used only once: possible typo at /usr/local/cpanel/3rdparty/perl/530/lib/perl5/5.30.0/x86_64-linux-64int/DynaLoader.pm line 207.
# Subtest: basic
    ok 1 - An object of class 'FFI::Platypus::Record::Meta' isa 'FFI::Platypus::Record::Meta'
    ok 2 - meta->ffi_type = 21684448
    ok 3 - meta->size
    not ok 4 - meta->alignment

    #   Failed test 'meta->alignment'
    #   at t/ffi_platypus_record_meta.t line 19.
    #          got: '851968'
    #     expected: '0'
    ok 5 - meta->element_pointers
    1..5
    # Looks like you failed 1 test of 5.
not ok 1 - basic

#   Failed test 'basic'
#   at t/ffi_platypus_record_meta.t line 29.
# Subtest: bogus types
    ok 1
    ok 2
    1..2
ok 2 - bogus types
1..2
# Looks like you failed 1 test of 2.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests 

Test Summary Report
-------------------
t/ffi_platypus_record_meta.t (Wstat: 256 Tests: 2 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=1, Tests=2,  0 wallclock secs ( 0.04 usr  0.00 sys +  0.10 cusr  0.01 csys =  0.15 CPU)
Result: FAIL
Perl Info ``` $>perl -V Summary of my perl5 (revision 5 version 30 subversion 0) configuration: Platform: osname=linux osvers=3.10.0-123.20.1.el7.x86_64 archname=x86_64-linux-64int uname='linux rpmbuild-64-centos-7.dev.cpanel.net 3.10.0-123.20.1.el7.x86_64 #1 smp thu jan 29 18:05:33 utc 2015 x86_64 x86_64 x86_64 gnulinux ' config_args='-des -Dusedevel -Darchname=x86_64-linux-64int -Dcc=/usr/bin/gcc -Dcpp=/usr/bin/cpp -Dusemymalloc=n -DDEBUGGING=none -Doptimize=-Os -Accflags=-m64 -Dccflags=-DPERL_DISABLE_PMC -fPIC -DPIC -Duseshrplib -Duselargefiles=yes -Duseposix=true -Dhint=recommended -Duseperlio=yes -Dprefix=/usr/local/cpanel/3rdparty/perl/530 -Dsiteprefix=/opt/cpanel/perl5/530 -Dsitebin=/opt/cpanel/perl5/530/bin -Dsitelib=/opt/cpanel/perl5/530/site_lib -Dusevendorprefix=true -Dvendorbin=/usr/local/cpanel/3rdparty/perl/530/bin -Dvendorprefix=/usr/local/cpanel/3rdparty/perl/530/lib/perl5 -Dvendorlib=/usr/local/cpanel/3rdparty/perl/530/lib/perl5/cpanel_lib -Dprivlib=/usr/local/cpanel/3rdparty/perl/530/lib/perl5/5.30.0 -Dman1dir=none -Dman3dir=none -Dscriptdir=/usr/local/cpanel/3rdparty/perl/530/bin -Dscriptdirexp=/usr/local/cpanel/3rdparty/perl/530/bin -Dsiteman1dir=none -Dsiteman3dir=none -Dinstallman1dir=none -Dversiononly=no -Dinstallusrbinperl=no -Dcf_by=cPanel -Dmyhostname=localhost -Dperladmin=root@localhost -Dcf_email=support@cpanel.net -DDB_File=true -Ud_dosuid -Uuserelocatableinc -Umad -Uusethreads -Uusemultiplicity -Uusesocks -Uuselongdouble -Duse64bitint -Uuse64bitall' hint=recommended useposix=true d_sigaction=define useithreads=undef usemultiplicity=undef use64bitint=define use64bitall=undef uselongdouble=undef usemymalloc=n default_inc_excludes_dot=define bincompat5005=undef Compiler: cc='/usr/bin/gcc' ccflags ='-DPERL_DISABLE_PMC -fPIC -DPIC -m64 -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2' optimize='-Os' cppflags='-DPERL_DISABLE_PMC -fPIC -DPIC -m64 -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include' ccversion='' gccversion='4.8.2 20140120 (Red Hat 4.8.2-16)' gccosandvers='' intsize=4 longsize=8 ptrsize=8 doublesize=8 byteorder=12345678 doublekind=3 d_longlong=define longlongsize=8 d_longdbl=define longdblsize=16 longdblkind=3 ivtype='long' ivsize=8 nvtype='double' nvsize=8 Off_t='off_t' lseeksize=8 alignbytes=8 prototype=define Linker and Libraries: ld='/usr/bin/gcc' ldflags =' -fstack-protector-strong -L/usr/local/lib' libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64 libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.17.so so=so useshrplib=true libperl=libperl.so gnulibc_version='2.17' Dynamic Linking: dlsrc=dl_dlopen.xs dlext=so d_dlsymun=undef ccdlflags='-Wl,-E -Wl,-rpath,/usr/local/cpanel/3rdparty/perl/530/lib/perl5/5.30.0/x86_64-linux-64int/CORE' cccdlflags='-fPIC' lddlflags='-shared -Os -L/usr/local/lib -fstack-protector-strong' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_COPY_ON_WRITE PERL_DISABLE_PMC PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP PERL_OP_PARENT PERL_PRESERVE_IVUV PERL_USE_DEVEL USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO USE_PERL_ATOF Locally applied patches: cPanel - disable man installs cPanel - cPanel INC PATH cPanel - Avoid importing symbols unless requested cPanel - Disable termcap warning when TERM is unset cPanel - Do not warn when close fails because the file handle is bad. cPanel - COW Static support cPanel - Use dup2 from Cpanel::POSIX::Tiny cPanel - Disable 14fileno.t tests since Cpanel::POSIX::Tiny is not cPanel - Avoid use vars when our will do in Core Perl cPanel - add Perl_DeclareStaticMemory cPanel - Disable xs handshake cPanel - Provide a way to clear swash invlists for B::C cPanel - Switch several CPAN modules to XSLoader cPanel - BC Static shared memory for single malloc cPanel - Hard code frequent Config checks so it's not needed cPanel - Storable do not load Fcntl cPanel - Optimize File::Find performance for backup metadata building cPanel - Reduce Scalar::Utils regex overhead cPanel - skip shadow call when euid > 0 on linux cPanel - Fix warning from Memoize::Expire cPanel - Remove use vars from Digest:: cPanel - Remove launcher regex in Config.pm cPanel - BC extra protection in Perl_sv_vcatpvfn_flags cPanel - Fix Getopt::Long version number to be 2.50 not 2.5 cPanel - Reduce startup size of PL_strtab cPanel - add test for CVE-2018-12015 (RT #133250) cPanel - CPAN::Config use manual install as default for root cPanel - Avoid a warning when prompting install_help intro cPanel - Avoid a warning from cpan when run with warnings cPanel - Pass the canonical signal name to the signal handler when it cPanel - Advertise Perl 5.30.3 as 5.30.0 cPanel - die_unwind(): global destruction Built under linux Compiled at Aug 21 2020 15:13:57 %ENV: PERL_HTTP_TINY_IPV4_ONLY="1" PERL_USE_UNSAFE_INC="0" @INC: /usr/local/cpanel /usr/local/cpanel/3rdparty/perl/530/lib/perl5/cpanel_lib/x86_64-linux-64int /usr/local/cpanel/3rdparty/perl/530/lib/perl5/cpanel_lib /usr/local/cpanel/3rdparty/perl/530/lib/perl5/5.30.0/x86_64-linux-64int /usr/local/cpanel/3rdparty/perl/530/lib/perl5/5.30.0 /opt/cpanel/perl5/530/site_lib/x86_64-linux-64int /opt/cpanel/perl5/530/site_lib ```
toddr commented 3 years ago

In case you need it, this is diag output:

t/00_diag.t .............................. 1/1 # 
# 
# 
# HARNESS_ACTIVE=1
# HARNESS_VERSION=3.42
# LANG=en_US.UTF-8
# PERL5LIB=/root/projects/FFI-Platypus/blib/lib:/root/projects/FFI-Platypus/blib/arch
# PERL_DL_NONLAZY=1
# PERL_HTTP_TINY_IPV4_ONLY=1
# PERL_USE_UNSAFE_INC=0
# SHELL=/bin/zsh
# 
# 
# 
# PERL5LIB path
# /root/projects/FFI-Platypus/blib/lib
# /root/projects/FFI-Platypus/blib/arch
# 
# 
# 
# perl                5.030000 linux x86_64-linux-64int
# Alien::Base         1.89
# Capture::Tiny       0.48
# Devel::Hide         -
# ExtUtils::CBuilder  0.280231
# ExtUtils::MakeMaker 7.34
# ExtUtils::ParseXS   3.40
# FFI::CheckLib       0.25
# IPC::Cmd            1.02
# JSON::PP            4.02
# List::Util          1.5
# Math::LongDouble    -
# PkgConfig           -
# Test::More          1.302171
# constant            1.33
# forks               0.36
# 
# 
# 
# mode : system
# Alien::FFI::pkgconfig->VERSION      = undef
# Alien::FFI::pkgconfig->install_type = system
# Alien::FFI::pkgconfig->cflags       =  
# Alien::FFI::pkgconfig->libs         = -lffi  
# Alien::FFI::pkgconfig->version      = 3.0.13
# 
# 
# 
# ffi.platypus.memory.strdup_impl =libc
# ffi.platypus.memory.strndup_impl=libc
# 
# 
# 
# Types:
#   double   : double, float complex
#   float    : float
#   longdouble : double complex, long double, long double complex
#   sint16   : int16_t, short, signed short
#   sint32   : int, int32_t, senum, signed int, wchar_t
#   sint64   : blkcnt_t, blksize_t, int64_t, intptr_t, long, long long, off_t, ptrdiff_t, signed long, signed long long, ssize_t, time_t
#   sint8    : char, int8_t, signed char
#   uint16   : uint16_t, unsigned short, ushort
#   uint32   : enum, gid_t, mode_t, uid_t, uint, uint32_t, unsigned int, wint_t
#   uint64   : dev_t, ino_t, nlink_t, size_t, uint64_t, uintptr_t, ulong, unsigned long, unsigned long long
#   uint8    : bool, uchar, uint8_t, unsigned char
# 
# 
# 
# ABIs:
#   default_abi          2
#   sysv                 1
#   unix64               2
# 
# 
# 
# Probes:
#   bigendian            0
#   variadic             1
#   longdouble           1
#   bigendian64          0
#   alloca               1
#   abi                  1
#   recordvalue          1
# 
# 
# 
# CPU Info:
#   model name  : Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)
#   flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm ssbd ibrs ibpb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust smep erms xsaveopt arat spec_ctrl
#   address sizes   : 40 bits physical, 48 bits virtual
# 
# 
# 
# LSB Version:  :core-4.1-amd64:core-4.1-noarch
# Distributor ID:   CentOS
# Description:  CentOS Linux release 7.8.2003 (Core)
# Release:  7.8.2003
# Codename: Core
# 
# 
# 
# [PLATFORM]
# osname            : linux
# cc                : /usr/bin/gcc
# cxx               : /usr/bin/g++
# for               : ---
# ld                : /usr/bin/gcc
# ccflags           : -fPIC -DPERL_DISABLE_PMC -fPIC -DPIC -m64 -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -Os -I/root/projects/FFI-Platypus/blib/lib/auto/share/dist/FFI-Platypus/include
# ldflags           : -shared -Os -L/usr/local/lib -fstack-protector-strong
# object suffix     : .o
# library prefix    : lib
# library suffix    : .so
# cc mm works       : -MM
# 
# 
# 
plicease commented 3 years ago

thanks for the diagnostic i was just about to ask for that. will take a look when I have a chance.

plicease commented 3 years ago

I wasn't able to reproduce this in a docker CentOS 6 container locally (although I didn't have 5.30 handy there), but it looks like the function signature for alignment is wrong. Can you try applying this patch and let me know if that helps or not:

✅ doublethink% git diff
diff --git a/lib/FFI/Platypus/Record/Meta.pm b/lib/FFI/Platypus/Record/Meta.pm
index dc915e8..1cce80c 100644
--- a/lib/FFI/Platypus/Record/Meta.pm
+++ b/lib/FFI/Platypus/Record/Meta.pm
@@ -69,7 +69,7 @@ the public interface to Platypus records.

   $ffi->attach( ffi_type         => ['meta_t'] => 'ffi_type'   );
   $ffi->attach( size             => ['meta_t'] => 'size_t'     );
-  $ffi->attach( alignment        => ['meta_t'] => 'uint'       );
+  $ffi->attach( alignment        => ['meta_t'] => 'ushort'     );
   $ffi->attach( element_pointers => ['meta_t'] => 'ffi_type[]' );

   $ffi->attach( DESTROY          => ['meta_t'] => 'void'       );

I also think I mistook your 6..8 to be a typo of 6.8, but are you reporting this for versions 6 to 8?

toddr commented 3 years ago

That clears the test. WHAT DOES IT MEAN?!?!?!? 😄

toddr commented 3 years ago

This patch now allows all of my platforms to pass tests.

plicease commented 3 years ago

That clears the test. WHAT DOES IT MEAN?!?!?!?

It creates a binding to this C function: https://github.com/PerlFFI/FFI-Platypus/blob/4ac951d6a34cbb39d78a151c4157cbf94d908867/ffi/record_meta.c#L64-L66 which was returning a different type (I had it as an unsigned int and it should have been unsigned short int); I must have made a mistake when I was writing this binding.

This patch now allows all of my platforms to pass tests.

:tada:

toddr commented 3 years ago

Thank you @plicease !

plicease commented 3 years ago

I will merge #288 and release as soon as it clears CI.

plicease commented 3 years ago

fixed in 1.34.