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

internal/bytealg: SIGILL on s390x #41552

Closed
richatbawag opened this issue Sep 22, 2020 · 7 comments
Closed

internal/bytealg: SIGILL on s390x #41552

richatbawag opened this issue Sep 22, 2020 · 7 comments
Labels
arch-s390x Issues solely affecting the s390x architecture. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@richatbawag
Copy link

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

$ go version
go version go1.15.2 linux/s390x

Does this issue reproduce with the latest release?

Yes (currently this is the latest release)

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

Linux Ubuntu 18.04.5 LTS, s390x

go env Output
$ go env
go version go1.15.2 linux/s390x
GO111MODULE=""
GOARCH="s390x"
GOBIN=""
GOCACHE="/home/P004995/.cache/go-build"
GOENV="/home/P004995/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="s390x"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/P004995/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/P004995/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/P004995/repos/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/P004995/repos/go/pkg/tool/linux_s390x"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -march=z196 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build060162936=/tmp/go-build -gno-record-gcc-switches"

What did you do?

cd src
./all.bash

go_1.15.2_build_form_source_tests_fail_s390x.txt

What did you expect to see?

ALL TESTS PASSED
exit status 0

What did you see instead?

FAIL
go tool dist: Failed: exit status 1
@ianlancetaylor
Copy link
Contributor

CC @mundaym

@ianlancetaylor ianlancetaylor changed the title Tests fail, build from source 1.15.2, linux/s390x, SIGILL internal/bytealg: SIGILL on s390x Sep 22, 2020
@ianlancetaylor ianlancetaylor added arch-s390x Issues solely affecting the s390x architecture. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 22, 2020
@ianlancetaylor ianlancetaylor added this to the Go1.16 milestone Sep 22, 2020
@mundaym
Copy link
Member

mundaym commented Sep 22, 2020

Thanks for the bug report @richatbawag. A few requests:

  1. Can you post the output of the command cat /proc/cpuinfo?
  2. Is this a real machine or a qemu emulated machine?
  3. Can you try again with the following environment variable set: GODEBUG="cpu.vx=off,cpu.vxe=off"?

The illegal instruction is pointing at an LGR instruction, but that is very unlikely to be accurate. Most likely the error is coming from the instruction before, a VLL instruction. We should only be trying to execute that if the vector facility is installed, but maybe the logic is slightly wrong.

@richatbawag
Copy link
Author

  1. Can you post the output of the command cat /proc/cpuinfo?
vendor_id       : IBM/S390
# processors    : 2
bogomips per cpu: 24038.00
max thread id   : 0
features	: esan3 zarch stfle msa ldisp eimm dfp etf3eh highgprs sie 
facilities      : 0 1 2 3 4 6 7 10 12 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 31 32 33 34 35 36 37 40 41 42 43 44 45 46 47 48 49 50 51 52 53 55 57 74 75 76 77 80 81 82 128 168
cache0          : level=1 type=Data scope=Private size=128K line_size=256 associativity=8
cache1          : level=1 type=Instruction scope=Private size=128K line_size=256 associativity=8
cache2          : level=2 type=Data scope=Private size=4096K line_size=256 associativity=8
cache3          : level=2 type=Instruction scope=Private size=4096K line_size=256 associativity=8
cache4          : level=3 type=Unified scope=Shared size=262144K line_size=256 associativity=32
cache5          : level=4 type=Unified scope=Shared size=983040K line_size=256 associativity=60
processor 0: version = FF,  identification = 0008F8,  machine = 2964
processor 1: version = FF,  identification = 0008F8,  machine = 2964

cpu number      : 0
cpu MHz dynamic : 5200
cpu MHz static  : 5200

cpu number      : 1
cpu MHz dynamic : 5200
cpu MHz static  : 5200
  1. Is this a real machine or a qemu emulated machine?

A real machine, no qemu

  1. Can you try again with the following environment variable set: GODEBUG="cpu.vx=off,cpu.vxe=off"?

Fails again.
go_1.15.2_build_form_source_tests_fail_s390x_cpuvxoff.txt

go1.14.9 works
go1.15 fails too

@mundaym
Copy link
Member

mundaym commented Sep 23, 2020

Thanks for the information. Looks like you are running a z13 with the vector facility disabled.

I think I know what the issue is. CL 156998 added calls to bytealg.IndexString that do not first check that the input string is shorter than bytealg.MaxLen (as required by the documentation for bytealg.IndexString). bytealg.MaxLen is 0 on s390x when the vector facility is unavailable and so bytealg.IndexString should not be called. Technically the generic implementation that was added in that CL should not be called either since generic platforms never set MaxLen to something other than 0.

Requiring callers to check MaxLen is probably asking for trouble. We might want to scrap it as part of the fix for this. I'll take a look and see if I can come up with a robust patch.

/cc @ianlancetaylor @randall77

@gopherbot
Copy link

Change https://golang.org/cl/256717 mentions this issue: bytes, internal/bytealg: fix incorrect IndexString usage

@mundaym
Copy link
Member

mundaym commented Sep 23, 2020

@gopherbot Please create backport issue for Go 1.15. This bug means that bytes.IndexAny and bytes.LastIndexAny cause an illegal instruction exception on s390x machines without the vector facility. There is no workaround.

@gopherbot
Copy link

Backport issue(s) opened: #41595 (for 1.15).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@golang golang locked and limited conversation to collaborators Sep 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-s390x Issues solely affecting the s390x architecture. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants