Skip to content

bazel/libgeos: segfault on s390x under cross-build #144582

Open
@golgeek

Description

@golgeek

Describe the problem

When running (current master branch) ./cockroach demo with the bazel built (cross-built) libgeos.so and libgeos_c.so libs on s390x, the binary crashes when trying to init the CGO code.

SIGSEGV: segmentation violation
PC=0x3ffae98afea m=5 sigcode=1 addr=0x3ffce3b4000
signal arrived during cgo execution

goroutine 1 gp=0xc0000021c0 m=5 mp=0xc000180008 [syscall]:
runtime.cgocall(0x77cb120, 0xc0031e9290)
	GOROOT/src/runtime/cgocall.go:167 +0x6a fp=0xc0031e9260 sp=0xc0031e9230 pc=0x110d00a
github.com/cockroachdb/cockroach/pkg/geo/geos._Cfunc_CR_GEOS_Init({0xc0025e1608, 0x11}, {0xc001c91620, 0xf}, 0xc001c915d8)
	_cgo_gotypes.go:408 +0x4c fp=0xc0031e9288 sp=0xc0031e9260 pc=0x3139e9c
github.com/cockroachdb/cockroach/pkg/geo/geos.initGEOS.func1({0xc001c9137d, 0x3}, 0xc001c915d8)
	com_github_cockroachdb_cockroach/pkg/geo/geos/geos.go:200 +0x27a fp=0xc0031e93a8 sp=0xc0031e9288 pc=0x313d95a
github.com/cockroachdb/cockroach/pkg/geo/geos.initGEOS({0xc001483140, 0x3, 0x4})
	com_github_cockroachdb_cockroach/pkg/geo/geos/geos.go:200 +0xd0 fp=0xc0031e9480 sp=0xc0031e93a8 pc=0x313d3a0
github.com/cockroachdb/cockroach/pkg/geo/geos.ensureInit.func1()
	com_github_cockroachdb_cockroach/pkg/geo/geos/geos.go:91 +0x60 fp=0xc0031e94c8 sp=0xc0031e9480 pc=0x313c5f0
sync.(*Once).doSlow(0xe44baa8, 0xc0031e9568)

Full stacktrace:
cockroach.stderr.log

Valgrind:
valgrind.cockroach.stderr.log

--

I tried building the same version of libgeos locally, and didn't face the issue after replacing the bazel built libs:

ubuntu@teamcity-19444336-1744830048-01-n9cpu4-geo-0001:~/lib$ readelf -h libgeos.so.bazel libgeos.so.local

File: libgeos.so.bazel
ELF Header:
  Magic:   7f 45 4c 46 02 02 01 03 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - GNU
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           IBM S/390
  Version:                           0x1
  Entry point address:               0x19c7f0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          6722936 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         8
  Size of section headers:           64 (bytes)
  Number of section headers:         37
  Section header string table index: 35

File: libgeos.so.local
ELF Header:
  Magic:   7f 45 4c 46 02 02 01 03 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - GNU
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           IBM S/390
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          3545688 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         7
  Size of section headers:           64 (bytes)
  Number of section headers:         29
  Section header string table index: 28

ubuntu@teamcity-19444336-1744830048-01-n9cpu4-geo-0001:~$ ll lib/
total 11716
drwxrwx---  2 ubuntu ubuntu    4096 Apr 16 20:49 ./
drwxr-x--- 12 ubuntu ubuntu    4096 Apr 16 20:51 ../
lrwxrwxrwx  1 ubuntu ubuntu      18 Apr 16 20:49 libgeos_c.so -> libgeos_c.so.local*
-rwxrwx---  1 ubuntu ubuntu  593360 Apr 16 19:03 libgeos_c.so.bazel*
-rwxrwx---  1 ubuntu ubuntu  360672 Apr 16 20:22 libgeos_c.so.local*
lrwxrwxrwx  1 ubuntu ubuntu      16 Apr 16 20:49 libgeos.so -> libgeos.so.local*
-rwxrwx---  1 ubuntu ubuntu 7479056 Apr 16 19:03 libgeos.so.bazel*
-rwxrwx---  1 ubuntu ubuntu 3547544 Apr 16 20:21 libgeos.so.local*

ubuntu@teamcity-19444336-1744830048-01-n9cpu4-geo-0001:~$ ./cockroach demo
<jemalloc>: No THP support: thp:never
#
# Welcome to the CockroachDB demo database!
[...]
#
[email protected]:26257/demoapp/movr> SELECT ST_IsValid(ST_MakePoint(1,2));
  st_isvalid
--------------
      t
(1 row)

Time: 1ms total (execution 1ms / network 0ms)

[email protected]:26257/demoapp/movr>

Jira issue: CRDB-49436

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.branch-masterFailures and bugs on the master branch.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions