perl - Cannot open a pty

I am having trouble with 'pty' on a new jail. I upgraded the host to 13.2, and am trying to build a new 13.2 jail. For some reason, I get a error from pty_allocate(); in IO::Pty. Works on the host, works in the old jail-12.0, but does not work in the jail-13.2.

I used cpan to install the perl module. Also, I tested on two boxes -- one running 13.3-RELEASE and the other 13.2-RELEASE-p10.

Code:
host# perl -e 'use IO::Pty; new  IO::Pty && print "OK\n";'
OK

host# jexec 18
jail-13.2# perl -e 'use IO::Pty; new  IO::Pty && print "OK\n";'
Cannot open a pty at -e line 1.
jail-13.2# perl --version
This is perl 5, version 36, subversion 3 (v5.36.3) built for amd64-freebsd-thread-multi

host# jexec 5
jail-12.0# perl -e 'use IO::Pty; new  IO::Pty && print "OK\n";'
OK
jail-12.0# perl --version
This is perl 5, version 28, subversion 3 (v5.28.3) built for amd64-freebsd-thread-multi
 
Hmmm.... if I run a truss on it, i see it lookin in /dev/pt and not /dev/pty for a pty.... does that matter?
Code:
openat(AT_FDCWD,"/dev/ptyp0",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/ptyp0",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/pt/p0",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/ptyp0000",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/ptyp1",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/ptyp1",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/pt/p1",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/ptyp0001",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/ptyp2",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/ptyp2",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/dev/pt/p2",O_RDWR|O_NOCTTY,00) ERR#2 'No such file or directory'
... snip 6670 more lines of openat ...

In the working jail, I get a pty with:
Code:
posix_openpt(O_RDWR|O_NOCTTY)             = 3 (0x3)
 
Ha! If I install perl5.38.2 (perl5.36 is the standard in ports for 13.2), I do not get the error.
perl5.38.2 -e 'use POSIX; use IO::Pty; new IO::Pty && print "OK\n";'

And the 5.38.2 calls posix_openpt. Something is busted with perl 5.36.3 inside the jail. I recompiled perl 5.36 from the ports tree inside that jail and that version is busted as well.

So... the workaround is to use perl 5.38. but this makes it so all the p5-Modules packages are worthless as they are all compiled against 5.36.

c’est la vie​

 
Ha! If I install perl5.38.2 (perl5.36 is the standard in ports for 13.2), I do not get the error.
perl5.38.2 -e 'use POSIX; use IO::Pty; new IO::Pty && print "OK\n";'

And the 5.38.2 calls posix_openpt. Something is busted with perl 5.36.3 inside the jail. I recompiled perl 5.36 from the ports tree inside that jail and the PORT is just as busted as the PKG.

So... the workaround is to use perl 5.38. but this makes it so all the p5-Modules packages are worthless as they are all compiled against 5.36.

c’est la vie​

 
Our situation is odd. We found the problem on one host which was upgraded from 13.1-RELEASE-p2 to 13.3-RELEASE today.

With perl v5.36.3
Code:
# perl -e 'use POSIX; use IO::Pty; new IO::Pty && print "OK\n";'
Cannot open a pty at -e line 1.

We cannot test with perl 5.38 yet on that host.

But on another 13.3-RELEASE with perl v5.36.3 we get:

Code:
$ sudo  perl -e 'use POSIX; use IO::Pty; new IO::Pty && print "OK\n";'
OK
 
If you use truss, you can see Perl making bad choices in 13.3-RELEASE.
Code:
 truss perl -e 'use IO::Pty; print "-----------------\n\n\n\n\n\n\n\n\n\n"; new IO::Pty && print "OK\n";'
 
This is interesting. Is it the host itself?

EDIT: I have reproduced this now on two hosts

Code:
# uname -a
FreeBSD [redacted] 13.3-RELEASE-p1 FreeBSD 13.3-RELEASE-p1 GENERIC amd64

# host is on 2024Q2 ports tree.

# perl -v

This is perl 5, version 38, subversion 2 (v5.38.2) built for amd64-freebsd-thread-multi

Copyright 1987-2023, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at https://www.perl.org/, the Perl Home Page.

# perl -e 'use POSIX; use IO::Pty; new IO::Pty && print "OK\n";'
Cannot open a pty at -e line 1.
#
 
If you use truss, you can see Perl making bad choices in 13.3-RELEASE.
Code:
 truss perl -e 'use IO::Pty; print "-----------------\n\n\n\n\n\n\n\n\n\n"; new IO::Pty && print "OK\n";'
Are you using ugidfw perhaps? The problem hosts above are.

EDIT: this point is not relevant.
 
Last edited:
Back
Top