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

cmd/vet: tests require Perl for errchk and fail with latest Perl #20007

Closed
genehack opened this issue Apr 17, 2017 · 12 comments
Closed

cmd/vet: tests require Perl for errchk and fail with latest Perl #20007

genehack opened this issue Apr 17, 2017 · 12 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@genehack
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8.1 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/genehack/go"
GORACE=""
GOROOT="/opt/go"
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build831712468=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

Grabbed the source tarball. Grabbed go-1.4 binary tarball and expanded under $HOME. Built 1.8.1 source per instructions (cd src; ./all.bash). Got test suite failure due to a change in regex syntax that became a fatal error in 5.24. (I'm running perl-5.25.11, currently; once I submit this I will replicate with 5.24, 5.22, and (hopefully!) not replicate with 5.20.)

What did you expect to see?

Fully passing test suite.

What did you see instead?

ok      cmd/vendor/golang.org/x/arch/x86/x86asm 0.195s
--- FAIL: TestVet (1.40s)
    --- FAIL: TestVet/5 (0.24s)
        vet_test.go:114: files: ["testdata/copylock_func.go" "testdata/nilfunc.go" "testdata/unsafeptr.go"]
        vet_test.go:163: vet output:
                Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/call of fntab.0. copies lock value: struct{ <-- HERE lock sync.Mutex} contains sync.Mutex/ at /opt/go/test/errchk line 128.
        vet_test.go:164: exit status 1
@genehack
Copy link
Author

genehack commented Apr 17, 2017

Update: I read the perldelta wrong: unescaped left-brace is only deprecated in 5.24. It will become fatal in 5.26 (which is expected out soon, within a few months). So, currently, this bug will only show up for folks running Perls from the 5.25.x development releases.

@bradfitz bradfitz changed the title Build fails tests with newer Perls due to regex syntax change cmd/vet: tests require Perl for errchk and fail with latest Perl Apr 17, 2017
@bradfitz bradfitz added help wanted Testing An issue that has been verified to require only test changes, not just a test failure. NeedsFix The path to resolution is known, but the work has not been done. labels Apr 17, 2017
@bradfitz bradfitz added this to the Go1.9Maybe milestone Apr 17, 2017
@ianlancetaylor ianlancetaylor changed the title cmd/vet: tests require Perl for errchk and fail with latest Perl cmd/vet: fails tests with newer Perls due to regex syntax change Apr 17, 2017
@ianlancetaylor
Copy link
Contributor

The actual use of perl is in the script test/errchk.

@bradfitz
Copy link
Contributor

@ianlancetaylor, we have a Go version of errchk already in test/run.go. (hence my longer title about one view of the bug being that we depend on Perl)

@bradfitz
Copy link
Contributor

bradfitz commented Apr 17, 2017

That said, it might be just changing:

    $regexp = "$`$file:$n$'";

to:

    $regexp = "\\Q$`\\E$file:$n$'";

(or quotameta)

@ianlancetaylor
Copy link
Contributor

Sorry, our subject line editing collided. I never saw yours.

@ianlancetaylor ianlancetaylor changed the title cmd/vet: fails tests with newer Perls due to regex syntax change cmd/vet: tests require Perl for errchk and fail with latest Perl Apr 17, 2017
@Leont
Copy link

Leont commented Apr 17, 2017

Quite frankly, this entire test suite is confused whether the error lines it's dealing with are plain strings or regexes.

This particular error is caused by this line. This is clearly meant to be matched stringwise, as are many other strings (that work fine most of the time because the meta-character . matches itself as literal character .).

Do you really need these to be regexes? If not I would recommend just quotemeta()ing it early (this may involve unquoting a few cases that are currently hand-quoted, for example because they contain a *).

If you do need it, I would recommend consistently quoting all error strings.

One possible intermediate solution is to add a new syntax that will explicitly enable the regular expression syntax. Something like:

  foo(1) // ERROR /some \d+ regexp/

All of this you really want to fix regardless of what perl is doing.

@ianlancetaylor
Copy link
Contributor

In general the ERROR lines that appear in the files in the test directory are always intended to be regular expressions. I am less familiar with the use in vet, but if vet wants to match the way that the test directory works then the ERROR lines there should also always be regexps. Thanks for identifying the line; probably the right solution is to backslash-quote the . characters.

@Leont
Copy link

Leont commented Apr 17, 2017

Thanks for identifying the line; probably the right solution is to backslash-quote the . characters.

The primary problem here isn't the . characters, but the {s

@josharian
Copy link
Contributor

My attempts to install a dev version of perl failed. Can someone confirm that CL 40950 fixes the immediate problem? Thanks.

@bradfitz
Copy link
Contributor

Here's a Debian jessie environment with Perl 5.25. You can build it and docker run it with some -v flags to bind mount your $GOROOT and $GOROOT_BOOTSTRAP to reproduce.

FROM buildpack-deps
MAINTAINER Peter Martini <PeterCMartini@GMail.com>

RUN apt-get update \
    && apt-get install -y curl procps \
        && rm -fr /var/lib/apt/lists/*

RUN mkdir /usr/src/perl
WORKDIR /usr/src/perl

RUN curl -SL https://cpan.metacpan.org/authors/id/S/SH/SHAY/perl-5.25.3.tar.bz2 -o perl-5.25.3.tar.bz2 \
        && tar --strip-components=1 -xjf perl-5.25.3.tar.bz2 -C /usr/src/perl \
            && rm perl-5.25.3.tar.bz2 \
                    && ./Configure -Duse64bitall -Duseshrplib -Dusedevel  -des \
                        && make -j$(nproc) \
                            && TEST_JOBS=$(nproc) make test_harness \
                                && make install \
                                    && cd /usr/src \
                                        && curl -LO https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm \
                                            && chmod +x cpanm \
                                                && ./cpanm App::cpanminus \
                                                    && rm -fr ./cpanm /root/.cpanm /usr/src/perl /tmp/*

WORKDIR /root

@navytux
Copy link
Contributor

navytux commented Oct 9, 2017

FYI Latest go18 (go1.8.4-0-gf5bcb9b8fe) fails to bootstrap on Debian 9 because of this bug:

ok      cmd/vendor/golang.org/x/arch/x86/x86asm 0.140s
--- FAIL: TestVet (0.84s)
    --- FAIL: TestVet/1 (0.06s)
        vet_test.go:114: files: ["testdata/atomic.go" "testdata/copylock_func.go" "testdata/lostcancel.go" "testdata/rangeloop.go" "testdata/unsafeptr.go"]
        vet_test.go:163: vet output:
                Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/call of f copies lock value: struct{ <-- HERE lock sync.Mutex} contains sync.Mutex/ at /home/kirr/src/tools/go/go18/test/errchk line 128.
        vet_test.go:164: exit status 1
FAIL
FAIL    cmd/vet 1.581s

Go18 should be still supported according to release poilcy, thus it is better to backport 2e45310 there.

Latest Go14 bootstraps ok.

@navytux
Copy link
Contributor

navytux commented Oct 26, 2017

FYI Latest go18 (go1.8.4-0-gf5bcb9b8fe) fails to bootstrap on Debian 9 because of this bug:
...

@rsc you probably overlooked this while backporting patches to go1.8.5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

7 participants