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

IO::Handle.open does not work on symlinks under certain circumstances (CWD?) #3603

Closed
p6rt opened this issue Dec 10, 2014 · 5 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 10, 2014

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

Searchable as RT123406$

@p6rt
Copy link
Author

p6rt commented Dec 10, 2014

From maxim.vuets@gmail.com

Rakudo+MoarVM dies on attempt to open a symlink​:

  ~$ ls -l /etc/system-release
  lrwxrwxrwx. 1 root root 14 Mar 30 2014 /etc/system-release -> fedora-release

  ~$ ls -l /etc/fedora-release
  -rw-r--r--. 1 root root 30 Feb 19 2014 /etc/fedora-release

  ~$ cat /etc/system-release
  Fedora release 20 (Heisenbug)

  ~$ perl6 -e 'say open("/etc/system-release").get;'
  Failed to stat in filehandle​: no such file or directory
  in method eof at src/gen/m-CORE.setting​:15551
  in method get at src/gen/m-CORE.setting​:15555
  in block <unit> at -e​:1

slurp() works though​:

  ~$ perl6 -e 'say slurp("/etc/system-release")'
  Fedora release 20 (Heisenbug)

**NB.** It is tricky to reproduce, it has to do something with CWD​:

  ~$ cd /tmp
  /tmp$ pwd
  /tmp
  /tmp$ echo hi >file
  /tmp$ ln -s file link
  /tmp$ perl6 -e 'say open("link").get'
  hi
  /tmp$ perl6 -e 'say open("/tmp/link").get'
  hi
  /tmp$ cd /
  /$ perl6 -e 'say open("/tmp/link").get'
  Failed to stat in filehandle​: no such file or directory
  in method eof at src/gen/m-CORE.setting​:15551
  in method get at src/gen/m-CORE.setting​:15555
  in block <unit> at -e​:1

Here's hoelzro++ input​:

I know why
it reads the link with readlink
and then it tries to stat *that*
if it's a relative path (which is resolved by the kernel as relative to the *symlink*, not the CWD)
perl6 freaks out!
I'm wondering why the hell it's stat'ing
esp. based on the *filename*
that's a race condition waiting to happen

This is perl6 version 2014.11-75-gc91a583 built on MoarVM version 2014.11-66-g23f2089

@p6rt
Copy link
Author

p6rt commented Dec 11, 2014

From @hoelzro

Corresponding issue in MoarVM, with a bit of digging​: MoarVM/MoarVM#160

On Wed Dec 10 13​:02​:27 2014, maxim.vuets@​gmail.com wrote​:

Rakudo+MoarVM dies on attempt to open a symlink​:

~$ ls -l /etc/system-release
lrwxrwxrwx. 1 root root 14 Mar 30 2014 /etc/system-release -> fedora-
release

~$ ls -l /etc/fedora-release
-rw-r--r--. 1 root root 30 Feb 19 2014 /etc/fedora-release

~$ cat /etc/system-release
Fedora release 20 (Heisenbug)

~$ perl6 -e 'say open("/etc/system-release").get;'
Failed to stat in filehandle​: no such file or directory
in method eof at src/gen/m-CORE.setting​:15551
in method get at src/gen/m-CORE.setting​:15555
in block <unit> at -e​:1

slurp() works though​:

~$ perl6 -e 'say slurp("/etc/system-release")'
Fedora release 20 (Heisenbug)

**NB.** It is tricky to reproduce, it has to do something with CWD​:

~$ cd /tmp
/tmp$ pwd
/tmp
/tmp$ echo hi >file
/tmp$ ln -s file link
/tmp$ perl6 -e 'say open("link").get'
hi
/tmp$ perl6 -e 'say open("/tmp/link").get'
hi
/tmp$ cd /
/$ perl6 -e 'say open("/tmp/link").get'
Failed to stat in filehandle​: no such file or directory
in method eof at src/gen/m-CORE.setting​:15551
in method get at src/gen/m-CORE.setting​:15555
in block <unit> at -e​:1

Here's hoelzro++ input​:

I know why
it reads the link with readlink
and then it tries to stat *that*
if it's a relative path (which is resolved by the kernel as relative
to the *symlink*, not the CWD)
perl6 freaks out!
I'm wondering why the hell it's stat'ing
esp. based on the *filename*
that's a race condition waiting to happen

This is perl6 version 2014.11-75-gc91a583 built on MoarVM version
2014.11-66-g23f2089

@p6rt
Copy link
Author

p6rt commented Dec 11, 2014

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

@p6rt
Copy link
Author

p6rt commented Dec 11, 2014

From @hoelzro

Fixed in MoarVM 3851372

On Wed Dec 10 21​:09​:21 2014, rob@​hoelz.ro wrote​:

Corresponding issue in MoarVM, with a bit of digging​:
MoarVM/MoarVM#160

On Wed Dec 10 13​:02​:27 2014, maxim.vuets@​gmail.com wrote​:

Rakudo+MoarVM dies on attempt to open a symlink​:

~$ ls -l /etc/system-release
lrwxrwxrwx. 1 root root 14 Mar 30 2014 /etc/system-release ->
fedora-
release

~$ ls -l /etc/fedora-release
-rw-r--r--. 1 root root 30 Feb 19 2014 /etc/fedora-release

~$ cat /etc/system-release
Fedora release 20 (Heisenbug)

~$ perl6 -e 'say open("/etc/system-release").get;'
Failed to stat in filehandle​: no such file or directory
in method eof at src/gen/m-CORE.setting​:15551
in method get at src/gen/m-CORE.setting​:15555
in block <unit> at -e​:1

slurp() works though​:

~$ perl6 -e 'say slurp("/etc/system-release")'
Fedora release 20 (Heisenbug)

**NB.** It is tricky to reproduce, it has to do something with CWD​:

~$ cd /tmp
/tmp$ pwd
/tmp
/tmp$ echo hi >file
/tmp$ ln -s file link
/tmp$ perl6 -e 'say open("link").get'
hi
/tmp$ perl6 -e 'say open("/tmp/link").get'
hi
/tmp$ cd /
/$ perl6 -e 'say open("/tmp/link").get'
Failed to stat in filehandle​: no such file or directory
in method eof at src/gen/m-CORE.setting​:15551
in method get at src/gen/m-CORE.setting​:15555
in block <unit> at -e​:1

Here's hoelzro++ input​:

I know why
it reads the link with readlink
and then it tries to stat *that*
if it's a relative path (which is resolved by the kernel as
relative
to the *symlink*, not the CWD)
perl6 freaks out!
I'm wondering why the hell it's stat'ing
esp. based on the *filename*
that's a race condition waiting to happen

This is perl6 version 2014.11-75-gc91a583 built on MoarVM version
2014.11-66-g23f2089

@p6rt p6rt closed this as completed Dec 11, 2014
@p6rt
Copy link
Author

p6rt commented Dec 11, 2014

@hoelzro - Status changed from 'open' to 'resolved'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant