develooper Front page | perl.perl5.porters | Postings from May 2015

[perl #125240] POSIX.pm does not guard against ctermid() being unavailable (as it is on Android 5+)

From:
Max Maischein
Date:
May 23, 2015 16:42
Subject:
[perl #125240] POSIX.pm does not guard against ctermid() being unavailable (as it is on Android 5+)
Message ID:
rt-4.0.18-15260-1432399347-693.125240-75-0@perl.org
# New Ticket Created by  Max Maischein 
# Please include the string:  [perl #125240]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=125240 >


This is a bug report for perl from corion@cpan.org,
generated with the help of perlbug 1.40 running under perl 5.22.0.


-----------------------------------------------------------------

The Configure script probes for termios.h being available and
also probes for the C< ctermid() > function being available.
Perl is compiled accordingly, but POSIX.pm only has guards
against C< termios.h > not being available wholesale, but not
for C< termios.h > being available but C< ctermid() > not being
available. This is for example the case on Android 5
(Cyanogenmod 12 in this case). Android 4.4 seems to either
not have C< termios.h > at all or seems to implement
C< ctermid() >.

This leads to perl building but failing all tests that directly
or indirectly load POSIX.xs, because the dynamic reference
to ctermid() cannot be resolved.

The long term fix (5.23+) would be to add compile guards
around ctermid() and also pass the information from
Configure to POSIX.xs , possibly through d_ctermid .

The short term fix for 5.22 is to add a compile-time
check in the Android hints ( hints/linux-android.sh ) that
tries to compile a C program which uses ctermid() and
disables usage/presence of C< termios.h > alltogether
if compiling that program fails. The following lines
are my feeble attempt to create the appropriate CBU
in hints/linux-android.sh:

$cat > try.c << 'EOM'
#include <termios.h>
int main() { (void) ctermid(0); return(0); }
EOM
$cc $ccflags try.c -o try
android_warn=`$run ./try 2>&1 | $egrep "$android_stub"`
if test "X$?" != X0; then
    # This should be respected by POSIX.xs, but isn't
    d_ctermid="$undef"
    # So we disable the whole of termios.h
    i_termios="$undef"
fi
if test "X$android_warn" != X; then
    # This should be respected by POSIX.xs, but isn't
    d_ctermid="$undef"
    # So we disable the whole of termios.h
    i_termios="$undef"
fi

-max
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
     category=library
     severity=low
     module=POSIX
---
Site configuration information for perl 5.22.0:

Configured by unknown at Sat May 23 07:05:41 UTC 2015.

Summary of my perl5 (revision 5 version 22 subversion 0) configuration:

   Platform:
     osname=android, osvers=5.0.2, archname=armv7l-linux-android
     uname='linux localhost 3.10.33 #1 smp preempt fri apr 17 07:07:43 
cest 2015 armv7l gnulinux '
     config_args='-Duserelocatableinc -Dusedevel 
-Dprefix=/data/local/perl 
-Dsysroot=/data/data/com.pdaxrom.cctools/root/cctools 
-Alibpth=/system/lib /vendor/lib -Dman1dir=none -Dman3dir=none 
-Dsite1man=none -Dsite3man=none -Dvendorman1=none -Dvendorman3=none -des'
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=undef, usemultiplicity=undef
     use64bitint=undef, use64bitall=undef, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
     optimize='-O2',
     cppflags='-fno-strict-aliasing -pipe -fstack-protector'
     ccversion='', gccversion='4.8', gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234, 
doublekind=3
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8, 
longdblkind=0
     ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=4
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =' -L/system/lib -fstack-protector'
     libpth=/system/lib /vendor/lib 
/data/data/com.pdaxrom.cctools/root/cctools/bin/../lib/gcc/arm-linux-androideabi/4.8/include-fixed 
/data/data/com.pdaxrom.cctools/root/cctools/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/lib 
/data/data/com.pdaxrom.cctools/root/cctools/lib /system/lib /vendor/lib 
/system/lib /vendor/lib /system/lib /vendor/lib /system/lib /vendor/lib 
/system/lib /vendor/lib
     libs=-ldl -lm -lc
     perllibs=-ldl -lm -lc
     libc=/system/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
     cccdlflags='-fPIC 
--sysroot=/data/data/com.pdaxrom.cctools/root/cctools', 
lddlflags='-shared -O2 --sysroot 
/data/data/com.pdaxrom.cctools/root/cctools -L/system/lib -fstack-protector'

Locally applied patches:
     RC2

---
@INC for perl 5.22.0:
     lib
     ./../lib/site_perl/5.22.0/armv7l-linux-android
     ./../lib/site_perl/5.22.0
     ./../lib/5.22.0/armv7l-linux-android
     ./../lib/5.22.0
     .

---
Environment for perl 5.22.0:
     HOME=/
     LANG (unset)
     LANGUAGE (unset)
 
LD_LIBRARY_PATH=/data/data/com.pdaxrom.cctools/root/cctools/lib:/data/local/perl-5.22.0-RC2:/data/local/perl-5.22.0-RC2/lib:/data/local/perl-5.22.0-RC2/lib/auto:
     LOGDIR (unset)
 
PATH=/data/data/com.pdaxrom.cctools/root/cctools/sbin:/data/data/com.pdaxrom.cctools/root/cctools/bin:/system/xbin:/system/bin:/data/data/com.pdaxrom.cctools/root/cctools/bin:/data/data/com.pdaxrom.cctools/root/cctools/sbi
     PERL_BADLANG (unset)
     SHELL=/system/bin/sh




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About