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

[perl #112866] ubuntu 12.4 sets errno for a sucessful call to pathconf

Thread Next
From:
Nicholas Clark
Date:
May 11, 2012 08:25
Subject:
[perl #112866] ubuntu 12.4 sets errno for a sucessful call to pathconf
Message ID:
rt-3.6.HEAD-4610-1336749891-434.112866-75-0@perl.org
# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #112866]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=112866 >



This is a build failure report for perl from nick@aranea.(none),
generated with the help of perlbug 1.39 running under perl 5.16.0.


-----------------------------------------------------------------
[Please describe your issue here]

This is blead on a machine upgraded to Ubuntu 12.4 only a few days ago
$ ./perl -Ilib -T ext/POSIX/t/sysconf.t | grep -v ^ok
1..87
not ok 5 - errno should be clear in all cases
#   Failed test 'errno should be clear in all cases'
#   at ext/POSIX/t/sysconf.t line 64.
#          got: 2
#     expected: 0
# $!: No such file or directory
not ok 20 - errno should be clear in all cases
#   Failed test 'errno should be clear in all cases'
#   at ext/POSIX/t/sysconf.t line 64.
#          got: 2
#     expected: 0
# $!: No such file or directory
# Looks like you failed 2 tests of 87.


Which is this:

$ ./perl -Ilib -MPOSIX -lwe '$!=0; $a = pathconf(shift, _PC_LINK_MAX); print "\$!=$!, r=$a"' .
$!=No such file or directory, r=32000


which seems to be because Ubuntu 12.4 is a special and unique snowflake, and
sets errno on a successful call to pathconf and fpathconf.

Here's my test program:

#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char **argv) {
    while (*++argv) {
	long result;
	int gotcha;
	int fd;

	errno = 0;
	result = pathconf(*argv, _PC_LINK_MAX);
	gotcha = errno;

	printf("_PC_LINK_MAX for '%s' is %ld, errno is %d\n",
	       *argv, result, gotcha);

	fd = open(*argv, O_RDONLY);
	if (fd == -1) {
	    perror(*argv);
	} else {
	    errno = 0;
	    result = fpathconf(fd, _PC_LINK_MAX);
	    gotcha = errno;

	    printf("_PC_LINK_MAX for '%s' using fd %d is %ld, errno is %d\n",
		   *argv, fd, result, gotcha);
	}
    }
    return 0;
}

On that Ubuntu machine:

$ ./pathconf /tmp ._PC_LINK_MAX for '/tmp' is 32000, errno is 2
_PC_LINK_MAX for '/tmp' using fd 3 is 32000, errno is 2
_PC_LINK_MAX for '.' is 32000, errno is 2
_PC_LINK_MAX for '.' using fd 4 is 32000, errno is 2

On a FreeBSD machine with a network mounted /home:

$ ./pathconf /tmp .
_PC_LINK_MAX for '/tmp' is 32767, errno is 0
_PC_LINK_MAX for '/tmp' using fd 3 is 32767, errno is 0
_PC_LINK_MAX for '.' is -1, errno is 22
_PC_LINK_MAX for '.' using fd 4 is -1, errno is 22

On a genuine Debian* system:

$ ./pathconf /tmp .
_PC_LINK_MAX for '/tmp' is 32000, errno is 0
_PC_LINK_MAX for '/tmp' using fd 3 is 32000, errno is 0
_PC_LINK_MAX for '.' is 32000, errno is 0
_PC_LINK_MAX for '.' using fd 4 is 32000, errno is 0

So, yes, special and unique. However, I'm told POSIX says nothing about
the value of errno after a successful call, so our tests are arguably wrong.

But, hmm, this isn't helpful.

Nicholas Clark

* well, a released Debian system. Is Ubuntu simply releasing now what Debian
  will release soon?

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=install
    severity=none
---
Site configuration information for perl 5.16.0:

Configured by nick at Fri May 11 15:36:41 BST 2012.

Summary of my perl5 (revision 5 version 16 subversion 0) configuration:
  Commit id: 7c54b938f6609d93f8920557d6cd0859571898c8
  Platform:
    osname=linux, osvers=3.2.0-24-generic, archname=x86_64-linux
    uname='linux aranea 3.2.0-24-generic #37-ubuntu smp wed apr 25 08:43:22 utc 2012 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des'
    hint=recommended, useposix=true, d_sigaction=define
    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 ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.6.3', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    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='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.15'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    RC0

---
@INC for perl 5.16.0:
    lib
    /usr/local/lib/perl5/site_perl/5.16.0/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.16.0
    /usr/local/lib/perl5/5.16.0/x86_64-linux
    /usr/local/lib/perl5/5.16.0
    .

---
Environment for perl 5.16.0:
    HOME=/home/nick
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/nick/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


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