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

Failed test '$! is set to EISDIR' #20

Open
eserte opened this Issue Nov 10, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@eserte

eserte commented Nov 10, 2018

This seems to happen sometimes on FreeBSD systems (non-zfs!, seen on FreeBSD versions from 9 to 11):

    # Failed test '$! is set to EISDIR'
    # at t/unlink.t line 39.
    # +-----+----+-------+
    # | GOT | OP | CHECK |
    # +-----+----+-------+
    # | 1   | eq | 21    |
    # +-----+----+-------+

# Failed test 'unlink on a existing directory'
# at t/unlink.t line 46.
# Seeded srand with seed '20181108' from local date.
t/unlink.t .............. 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/4 subtests 
@toddr

This comment has been minimized.

Member

toddr commented Nov 13, 2018

1 would be EPERM instead of EISDIR.

I'm getting this on centos. What do you get?

$>perl -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); unlink $t; print "Got: " . ($! +0) . " - $!\n"' 
Got: 21 - Is a directory

Is it possible your /tmp is setup wrong or that $TMP is set to something funny?

@eserte

This comment has been minimized.

eserte commented Nov 14, 2018

I have now a truss log of a failed run. The interesting lines:

71712: 0.356629683 0.000124038 mkdir("/tmp/7EjVXM5y2G",0700) = 0 (0x0)
71712: 0.356824121 0.000006146 stat("/tmp/7EjVXM5y2G",{ mode=drwx------ ,inode=81848,size=512,blksize=32768 }) = 0 (0x0)
71712: 0.367991462 0.000013130 unlink("/tmp/7EjVXM5y2G") ERR#1 'Operation not permitted'

That's correct, unlink on directories is forbidden. From the unlink(2) manpage:

     [EPERM]            The named file is a directory.
@toddr

This comment has been minimized.

Member

toddr commented Nov 16, 2018

I'm trying to decide how big of a problem this is going to be. If it's going to be a frequent problem, then I have to determine what these values will be at Makfile.PL time and then bake it into the module.

My other option would be to do a one off exception for $^X eq 'freebsd' but it sounds like you're saying only very specific versions of freebsd behave this way?

@toddr

This comment has been minimized.

Member

toddr commented Nov 16, 2018

Let's try 1e18f8a for a fix in 0.012

@eserte

This comment has been minimized.

eserte commented Nov 17, 2018

Hmmm, I still get the same errors in 0.012.

And it seems that this problem is not freebsd-specific --- the same failure happens also on other BSD systems (NetBSD), and even Debian with FreeBSD kernel (see http://matrix.cpantesters.org/?dist=Test-MockFile%200.011 ). Also, there are no reports at all for recent Test-MockFile versions on darwin --- I guess it could happen there, too.

@eserte

This comment has been minimized.

eserte commented Nov 17, 2018

BTW, the oneliner above prints also errno 21 on a FreeBSD 13 system with perl 5.26.2:

$ perl -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); warn "about to unlink\n"; unlink $t; warn "Got: " . ($! +0) . " - $!\n"' 
about to unlink
Got: 21 - Is a directory

But the truss log is interesting:

59591: 0.215535940 0.000123740 write(2,"about to unlink\n",16) = 16 (0x10)
59591: 0.215628960 0.000020820 fstatat(AT_FDCWD,"/tmp/rpFZl9wT6c",{ mode=drwx------ ,inode=212,size=2,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
59591: 0.215732180 0.000035070 fstatat(AT_FDCWD,"/usr/share/nls/C/libc.cat",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.215795310 0.000018940 fstatat(AT_FDCWD,"/usr/share/nls/libc/C",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.215857350 0.000020320 fstatat(AT_FDCWD,"/usr/local/share/nls/C/libc.cat",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.215917220 0.000018780 fstatat(AT_FDCWD,"/usr/local/share/nls/libc/C",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.216081980 0.000097270 write(2,"Got: 21 - Is a directory\n",25) = 25 (0x19)

So it looks like unlink() isn't called at all, but only a stat call instead; maybe the result of this call is inspected and turned into an "artificial" errno 21.

@eserte

This comment has been minimized.

eserte commented Nov 17, 2018

The behavior changed between perl 5.18 and 5.20. On a freebsd 9 system:

for i in /usr/perl*/bin/perl; do env LC_ALL=C $i -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); unlink $t; warn "$]: Got: " . ($! +0) . " - $!\n"'; done
5.010001: Got: 1 - Operation not permitted
5.014004: Got: 1 - Operation not permitted
5.016003: Got: 1 - Operation not permitted
5.018002: Got: 1 - Operation not permitted
5.020000: Got: 21 - Is a directory
5.008009: Got: 1 - Operation not permitted

And on a freebsd 10 system:

for i in /usr/perl*/bin/perl; do env LC_ALL=C $i -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); unlink $t; warn "$]: Got: " . ($! +0) . " - $!\n"'; done
5.018004: Got: 1 - Operation not permitted
5.020001: Got: 21 - Is a directory
5.020001: Got: 21 - Is a directory
5.020002: Got: 21 - Is a directory
5.020003: Got: 21 - Is a directory
5.022000: Got: 21 - Is a directory
5.022001: Got: 21 - Is a directory
5.022002: Got: 21 - Is a directory
5.022002: Got: 21 - Is a directory
5.022003: Got: 21 - Is a directory
5.022004: Got: 21 - Is a directory
5.024000: Got: 21 - Is a directory
5.024001: Got: 21 - Is a directory
5.024002: Got: 21 - Is a directory
5.024003: Got: 21 - Is a directory
5.026000: Got: 21 - Is a directory
5.026001: Got: 21 - Is a directory
5.027010: Got: 21 - Is a directory
5.027011: Got: 21 - Is a directory
5.027006: Got: 21 - Is a directory
5.027007: Got: 21 - Is a directory
5.027008: Got: 21 - Is a directory
5.027009: Got: 21 - Is a directory
5.028000: Got: 21 - Is a directory
@eserte

This comment has been minimized.

eserte commented Nov 17, 2018

Also, there are no reports at all for recent Test-MockFile versions on darwin --- I guess it could happen there, too.

Yes. EPERM is also returned on Mac systems with system perl (currently 5.18.2), see https://travis-ci.org/eserte/sandbox/jobs/456396139
Test script was: https://github.com/eserte/sandbox/blob/daea395b488369cc935392025ebc3f75927e2cfe/t/unlink-dir.t#L19

@toddr

This comment has been minimized.

Member

toddr commented Nov 17, 2018

Yeah this was just a test. I’ve already concluded that I’m going to have to template the module before install

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