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

sysopen (to create a lockfile) fails with inappropriate ioctl for device #9612

Closed
p5pRT opened this issue Jan 5, 2009 · 5 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Jan 5, 2009

Migrated from rt.perl.org#61964 (status was 'rejected')

Searchable as RT61964$

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2009

From mpyne@purinchu.net

Created by mpyne@purinchu.net

When running a script that I write (kdesvn-build) I noticed that a recent
change to my script to add more error checking when creating lock files was
always reporting errors. I've reduced the problem to the following test case​:

use strict;
use Fcntl;

my $file = '.lockfile';

$! = 0;
sysopen(LOCK, $file, O_CREAT|O_WRONLY|O_EXCL);
print "Result​: $!\n"; # Prints Result​: inappropriate ioctl for device
close LOCK;
unlink $file;

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

strace output (partial)​:

ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff565581b0) = -1 ENOTTY (Inappropriate ioctl for device)
lseek(5, 0, SEEK_CUR) = 0
read(5, "package Exporter;\n\nrequire 5.006;"..., 4096) = 4096
brk(0x2459000) = 0x2459000
lseek(5, 2217, SEEK_SET) = 2217
lseek(5, 0, SEEK_CUR) = 2217
close(5) = 0
stat("/usr/lib64/perl5/5.8.8/x86_64-linux/auto/Fcntl/Fcntl.so", {st_mode=S_IFREG|0555, st_size=14296, ...}) = 0
stat("/usr/lib64/perl5/5.8.8/x86_64-linux/auto/Fcntl/Fcntl.bs", {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
futex(0x34d8e0310c, FUTEX_WAKE, 2147483647) = 0
open("/usr/lib64/perl5/5.8.8/x86_64-linux/auto/Fcntl/Fcntl.so", O_RDONLY) = 5
read(5, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\v\0\0\0\0\0\0@​"..., 832) = 832
fstat(5, {st_mode=S_IFREG|0555, st_size=14296, ...}) = 0
mmap(NULL, 2109568, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0x7f234e1aa000
mprotect(0x7f234e1ad000, 2093056, PROT_NONE) = 0
mmap(0x7f234e3ac000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0x2000) = 0x7f234e3ac000
close(5) = 0
mprotect(0x7f234e3ac000, 4096, PROT_READ) = 0
read(3, ""..., 4096) = 0

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

I've tried different combinations of flags to sysopen() (O_RDWR instead of
O_WRONLY and removing O_EXCL) but the problem remains.

One thing I've noted is that exporting PERLIO=​:stdio before running the script
results in expected behavior (i.e. no errors).

I've downloaded the 5.8.8 source code and browsed through but I can't find
where sysopen is defined in order to ease stepping through in gdb. I know
that 5.8.9 is now out but it is not packaged by my distro and I was unable to
get the make to start (something about missing build rule; probably a separate
problem on my end)

My Googling around seems to indicate that the problem is still present for
some people running 5.10.0 even and perldelta-5.8.9 didn't have anything leap
out to me as probably solving the bug.

I have a debug-enabled build of perl now so I'm standing by to assist as
necessary.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.8:

Configured by Gentoo at Sun Jan  4 20:23:38 EST 2009.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.6.27.10, archname=x86_64-linux
    uname='linux midna 2.6.27.10 #1 smp preempt tue dec 23 00:05:35 est 2008 x86_64 amd athlon(tm) 64 x2 dual core processor 3800+ authenticamd gnulinux '
    config_args='-des -Darchname=x86_64-linux -Dcccdlflags=-fPIC -Dccdlflags=-rdynamic -Dcc=x86_64-pc-linux-gnu-gcc -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr -Dlocincpth=  -Doptimize=-march=athlon64 -O2 -pipe -msse3 -g -Duselargefiles -Dd_semctl_semun -Dscriptdir=/usr/bin -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dinstallman1dir=/usr/share/man/man1 -Dinstallman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dinc_version_list=5.8.0 5.8.0/x86_64-linux 5.8.2 5.8.2/x86_64-linux 5.8.4 5.8.4/x86_64-linux 5.8.5 5.8.5/x86_64-linux 5.8.6 5.8.6/x86_64-linux 5.8.7 5.8.7/x86_64-linux  -Dcf_by=Gentoo -Ud_csh -Dusenm -Di_ndbm -Di_gdbm -Di_db -DDEBUGGING -Dusrinc=/usr/include/gentoo-multilib/amd64 -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef 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='x86_64-pc-linux-gnu-gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-march=athlon64 -O2 -pipe -msse3 -g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/include/gdbm'
    ccversion='', gccversion='4.2.4 (Gentoo 4.2.4 p1.0)', 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='x86_64-pc-linux-gnu-gcc', ldflags =' -L/usr/local/lib64'
    libpth=/usr/local/lib64 /lib64 /usr/lib64
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.6.1.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.6.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64'

Locally applied patches:
    


@INC for perl v5.8.8:
    /etc/perl
    /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux
    /usr/lib64/perl5/vendor_perl/5.8.8
    /usr/lib64/perl5/vendor_perl
    /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux
    /usr/lib64/perl5/site_perl/5.8.8
    /usr/lib64/perl5/site_perl
    /usr/lib64/perl5/5.8.8/x86_64-linux
    /usr/lib64/perl5/5.8.8
    /usr/local/lib/site_perl
    .


Environment for perl v5.8.8:
    HOME=/home/kde-svn
    LANG=en_US.UTF-8
    LANGUAGE=
    LD_LIBRARY_PATH=/home/kde-svn/kde-4/lib:/home/kde-svn/qt4/lib:
    LOGDIR (unset)
    PATH=/home/kde-svn/kde4/kdesdk/scripts:/home/kde-svn/cmake/bin:/home/kde-svn/kde4/kdesdk/scripts:/usr/lib/ccache/bin:/home/kde-svn/qt4/bin:/home/kde-svn/kde-4/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.2.4:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin:/usr/games/bin:/var/qmail/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2009

From ben@morrow.me.uk

Quoth mpyne@​purinchu.net​:

When running a script that I write (kdesvn-build) I noticed that a recent
change to my script to add more error checking when creating lock files was
always reporting errors. I've reduced the problem to the following test case​:

use strict;
use Fcntl;

my $file = '.lockfile';

$! = 0;
sysopen(LOCK, $file, O_CREAT|O_WRONLY|O_EXCL);
print "Result​: $!\n"; # Prints Result​: inappropriate ioctl for device

This is not a bug. $! only has a useful value after a syscall has
failed​: to check for errors you need to check the return value of
sysopen, and only then check $!. Setting $! to 0 and checking it
afterwards is *not* sufficient.

Ben

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2009

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2016

From @dcollinsn

From perldoc perlvar​:

Many system or library calls set errno if they fail, to indicate the cause of failure. They usually do not set errno to zero if they succeed. This means errno , hence $! , is meaningful only immediately after a failure​:

Further details in the docs. sysopen() indicates failure by returning undef. If it does not return undef, $! is meaningless.

Closing rejected notabug.

--
Respectfully,
Dan Collins

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2016

@dcollinsn - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant