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

testscript: fix ptyName() returning /dev/pts/4294967296 on s390x #246

Merged
merged 1 commit into from Feb 16, 2024

Conversation

anthonyfok
Copy link
Contributor

@anthonyfok anthonyfok commented Feb 16, 2024

Use uint32 instead of uint (64-bit in Go on s390x) to store the return value of the TIOCGPTN syscall. This is to avoid the 32-bit value from being stored into a 64-bit buffer and get left-shifted by 32 when dereferencing, turning what should be e.g. /dev/pts/1 to /dev/pts/4294967296 on big-endian architectures such as s390x.

Special thanks to the explanation and a similar bug fix provided at containerd/console#51

Fixes the following TestScripts/pty error on s390x:

=== NAME  TestScripts/pty
    testscript.go:558: > [!linux] [!darwin] skip
        > [darwin] skip # https://go.dev/issue/61779
        > ttyin secretwords.txt
        > terminalprompt
        [failed to open TTY: open /dev/pts/21474836480: no such file or directory]
        FAIL: testdata/pty.txt:5: unexpected command failure

discovered by Debian autopkgtest CI for golang-github-rogpeppe-go-internal/1.12.0-1;
see log at https://ci.debian.net/packages/g/golang-github-rogpeppe-go-internal/testing/s390x/43022768/#L3047

(Hmm... I guess /dev/pts/21474836480 should have been /dev/pts/5, as 5 << 32 = 21474836480.)

Special thanks also to @kapouer for providing an interim workaround in golang-github-rogpeppe-go-internal/1.12.0-2 for Debian as 1.12.0-1 was blocked from entering "trixie (testing)" for 16 days due to test error on s390x.

Use uint32 instead of uint (64-bit in Go on s390x) to store the return
value of the TIOCGPTN syscall.  This is to avoid the 32-bit value from
being stored into a 64-bit buffer and get left-shifted by 32 when
dereferencing, turning what should be /dev/pts/1 to /dev/pts/4294967296
on big-endian architectures such as s390x.

Special thanks to the explanation and a similar bug fix provided at
containerd/console#51
Copy link
Collaborator

@mvdan mvdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Thanks for the fix.

@mvdan mvdan merged commit 8e66eb9 into rogpeppe:master Feb 16, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants