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

t/io/errno.t failures with stdio layer in IRIX #14557

Closed
p5pRT opened this issue Mar 4, 2015 · 9 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Mar 4, 2015

Migrated from rt.perl.org#123977 (status was 'resolved')

Searchable as RT123977$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Mar 4, 2015

From @jhi

(IRIX 6.5 IRIX64)

There's something fishy about the stdio layer. The 'stdio' half of t/io/errno.t fails,
but only under certain circumstances. What works is e.g. "make minitest" or "make test".
And the 'perlio' half of the test always seems to work.

But what fails, for example, is​:

cd t
../perl -I../lib io/errno.t

(which is what t/harness does, basicallt) which fails with​:

...
not ok 9 - Wrong errno, PERLIO=stdio stdin='test\n',
# got "test\nNo such file or directory"
# expected "test\n"
not ok 10 - Wrong errno, PERLIO=stdio stdin='test\n', $/=undef
# Failed test 10 - Wrong errno, PERLIO=stdio stdin='test\n', $/=undef at io/errno.t line 44
# got "test\nNo such file or directory"
# expected "test\n"
not ok 11 - Wrong errno, PERLIO=stdio stdin='test\n', $/=\2
# Failed test 11 - Wrong errno, PERLIO=stdio stdin='test\n', $/=\2 at io/errno.t line 44
# got "test\nNo such file or directory"
# expected "test\n"
not ok 12 - Wrong errno, PERLIO=stdio stdin='test\n', $/=\1024
# Failed test 12 - Wrong errno, PERLIO=stdio stdin='test\n', $/=\1024 at io/errno.t line 44
# got "test\nNo such file or directory"
# expected "test\n"
not ok 13 - Wrong errno, PERLIO=stdio stdin='test',
# Failed test 13 - Wrong errno, PERLIO=stdio stdin='test', at io/errno.t line 44
# got "testNo such file or directory"
# expected "test"
not ok 14 - Wrong errno, PERLIO=stdio stdin='test', $/=undef
# Failed test 14 - Wrong errno, PERLIO=stdio stdin='test', $/=undef at io/errno.t line 44
# got "testNo such file or directory"
# expected "test"
not ok 15 - Wrong errno, PERLIO=stdio stdin='test', $/=\2
# Failed test 15 - Wrong errno, PERLIO=stdio stdin='test', $/=\2 at io/errno.t line 44
# got "testNo such file or directory"
# expected "test"
not ok 16 - Wrong errno, PERLIO=stdio stdin='test', $/=\1024
# Failed test 16 - Wrong errno, PERLIO=stdio stdin='test', $/=\1024 at io/errno.t line 44
# got "testNo such file or directory"
# expected "test"

Just guessing but some well-placed SETERRNO(0,0) is missing, to zap the obvious ENOENT?

(as of blead http​://perl5.git.perl.org/perl.git/commit/94a0894418670e8bdd2c1d63e76a77225365995d)

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 8, 2015

From @jhi

Notice the "cousin" error in openbsd​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=126306

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 8, 2015

From [Unknown Contact. See original ticket]

Notice the "cousin" error in openbsd​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=126306

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 17, 2015

From @jhi

Some more debugging. Here's a minimal failure case (run in the t subdirectory)​:

jhi@​irix$ echo test | env PERLIO=stdio ../perl -I../lib -e '<>; print $!'
No such file or directoryjhi@​irix$

Here's a minimal success case​:

jhi@​irix$ echo test | env PERLIO=stdio ../perl -e '<>; print $!'
jhi@​irix$

Curious, isn't it? The -I../lib is necessary.

Also needed are PERLIO=stdio, and the <>.

(One can do undef $! or $!=0 before the <>, but it makes no difference.)

So I did some system call tracing, par(1) in IRIX. The logs attached.

It seems that with the -Ilib there are two groups of open() calls that fail and set the errno​:

...
  8mS[ 0] : stat("../lib/5.23.4/IP35-irix", 0x7fff28d0) errno = 2 (No such file or directory)
  8mS[ 0] : stat("../lib/5.23.4", 0x7fff28d0) errno = 2 (No such file or directory)
  8mS[ 0] : stat("../lib/IP35-irix", 0x7fff28d0) errno = 2 (No such file or directory)
...
  11mS[ 0] : stat("/usr/lib/locale/C/LC_MESSAGES/uxsyserr", 0x7fff26a0) errno = 2 (No such file or directory)
  11mS[ 0] : stat("/usr/lib/locale/C/Xopen/LC_MESSAGES/uxsyserr", 0x7fff26a0) errno = 2 (No such file or directory)
  11mS[ 0] : stat("/usr/lib/locale/C/LC_MESSAGES/uxsyserr.cat", 0x7fff26a0) errno = 2 (No such file or directory)

The read(0, ...) from stdin (the readline) happens just before the second group of open() calls.

(The first group is obviously some -I magic, checking whether per-version per-arch dirs exist.)

But the second group is equally obviously locale-related.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 17, 2015

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 17, 2015

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 17, 2015

From @jhi

...
11mS[ 0] :
stat("/usr/lib/locale/C/LC_MESSAGES/uxsyserr", 0x7fff26a0) errno = 2
(No such file or directory)
11mS[ 0] :
stat("/usr/lib/locale/C/Xopen/LC_MESSAGES/uxsyserr", 0x7fff26a0) errno
= 2 (No such file or directory)
11mS[ 0] :
stat("/usr/lib/locale/C/LC_MESSAGES/uxsyserr.cat", 0x7fff26a0) errno =
2 (No such file or directory)

...

But the second group is equally obviously locale-related.

Not that it's anything to with Perl's locale-code, mind. It seems to be trying to open some operating system level message catalog, for some unknown reason, because the previous system call looks like
it succeeded​:

  11mS[ 0] : syssgi(0x5c, 0x1, 0, 0x2f, 0x101d7ea0, 0x101d7ebb) = 0

syssgi(0x5c, ...) seems to be gloriously undocumented... but purely guessing by its name

#define SGI_RXEV_GET 92

it could be to do with the par(1) tracing itself. But in any case, it returned zero.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 18, 2015

From @jhi

Looks like the stat() calls were red herrings; they were not setting the errno.

What was setting it is something in the IRIX stdio implementation. The rabbit hole was

pp_readline -> do_readline -> sv_gets -> PerlIO_getc -> PerlIO_read -> PerlIOStdio_read

And in the PerlIOStdio_read both the branches​:

* the count == 1 branch which uses stdio fgetc()

* the non-1-else branch which uses stdio fread()

got their errno=0 stomped on with errno=2 (ENOENT) with fgetc() and fread() respectively,
using the minimized test code originally from t/io/errno.t​:

  echo | env PERLIO=stdio ../perl -I../lib -e '<>; print $!'

or

  echo test | env PERLIO=stdio ../perl -I../lib -e '<>; print $!'

Now worked around with commit bdae417. Before the change "No such file or directory" got printed, after, not.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 18, 2015

@jhi - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.