Opened 6 months ago

Last modified 2 months ago

#68687 new defect

totp-cli - legacy support broken in go? - SIGSEGV: segmentation violation

Reported by: RobK88 Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: lion Cc: RobK88, manojkarthick (Manoj Karthick), ci42, herbygillot (Herby Gillot)
Port: totp-cli, go

Description (last modified by RobK88)

I am unable to get the go port totp-cli to build on legacy Mac systems. It does build on High Sierra and greater. I suspect it may be a go compiler issue.

I tried adding the following to the Portfile for totp-cli to add legacy support:

pre-build {
#   Sierra and earlier
    if { ${os.platform} eq "darwin" && ${os.major} < 17 } {
        build.env-append    GO_EXTLINK_ENABLED="1" \
                            GO_LDFLAGS="\"-extldflags=${configure.ldflags}\"" \
                            CGO_LDFLAGS="-g -O2 ${configure.ldflags}"
    }
}

depends_build-append    port:legacy-support

But when I try to install totp-cli on my Mac running Lion, I see:

--->  Building totp-cli
Executing:  cd "/opt/local/var/macports/build/_Users_rob_Development_MacPorts_local-repo_security_totp-cli/totp-cli/work/gopath/src/github.com/yitsushi/totp-cli" && /opt/local/bin/go build 
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7fff8afcdd9f]

runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff8afcdd9f
stack: frame={sp:0x7fff5fbff2b0, fp:0x7fff5fbff300} stack=[0x7fff5fb80370,0x7fff5fbff3e0)
0x00007fff5fbff1b0:  0x01007fff5fbff1d0  0x0000000000000004 
0x00007fff5fbff1c0:  0x000000000000001f  0x00007fff8afcdd9f 
0x00007fff5fbff1d0:  0x0000000000000000  0x0000000000000001 
0x00007fff5fbff1e0:  0x00000000040356f1 <runtime.throw+0x0000000000000071>  0x00007fff5fbff280 
0x00007fff5fbff1f0:  0x00000000045ab167  0x00007fff5fbff238 
0x00007fff5fbff200:  0x00000000040359a8 <runtime.fatalthrow.func1+0x0000000000000048>  0x00000000049a06c0 
0x00007fff5fbff210:  0x0000000000000001  0x0000000000000001 
0x00007fff5fbff220:  0x00007fff5fbff280  0x00000000040356f1 <runtime.throw+0x0000000000000071> 
0x00007fff5fbff230:  0x00000000049a06c0  0x00007fff5fbff270 
0x00007fff5fbff240:  0x0000000004035930 <runtime.fatalthrow+0x0000000000000050>  0x00007fff5fbff250 
0x00007fff5fbff250:  0x0000000004035960 <runtime.fatalthrow.func1+0x0000000000000000>  0x00000000049a06c0 
0x00007fff5fbff260:  0x00000000040356f1 <runtime.throw+0x0000000000000071>  0x00007fff5fbff280 
0x00007fff5fbff270:  0x00007fff5fbff2a0  0x00000000040356f1 <runtime.throw+0x0000000000000071> 
0x00007fff5fbff280:  0x00007fff5fbff288  0x0000000004035720 <runtime.throw.func1+0x0000000000000000> 
0x00007fff5fbff290:  0x00000000045b3eef  0x000000000000002a 
0x00007fff5fbff2a0:  0x00007fff5fbff2f0  0x000000000404b1e9 <runtime.sigpanic+0x0000000000000389> 
0x00007fff5fbff2b0: <0x00000000045b3eef  0xffffffffffffffff 
0x00007fff5fbff2c0:  0x0000000000736668  0x0000000000000000 
0x00007fff5fbff2d0:  0xff00000000000000  0x0000000000000000 
0x00007fff5fbff2e0:  0x63614d5f746e656d  0x000000002c3000f0 
0x00007fff5fbff2f0:  0x00007fff5fbff310 !0x00007fff8afcdd9f 
0x00007fff5fbff300: >0x000000002c3000f0  0x000000002c300020 
0x00007fff5fbff310:  0x00007fff5fbff340  0x00007fff8afce4cb 
0x00007fff5fbff320:  0x687469672f637273  0x000000c00013e888 
0x00007fff5fbff330:  0x000000c0000001a0  0x000000002c00d4f4 
0x00007fff5fbff340:  0x00007fff5fbff360  0x000000000406809f <runtime.syscall+0x000000000000001f> 
0x00007fff5fbff350:  0x000000c00013e888  0x000000002c2110a8 
0x00007fff5fbff360:  0x000000c00013e858  0x0000000004065f10 <runtime.asmcgocall+0x0000000000000070> 
0x00007fff5fbff370:  0x000000000401ab55 <runtime.SetFinalizer.func2+0x0000000000000035>  0x000000c000134360 
0x00007fff5fbff380:  0x00000000045e4f28  0x0000000000000010 
0x00007fff5fbff390:  0x0000000004514760  0x00000000000017d0 
0x00007fff5fbff3a0:  0x000000c0000001a0  0x0000000004064029 <runtime.systemstack+0x0000000000000049> 
0x00007fff5fbff3b0:  0x0000000000000004  0x0000000004661908 
0x00007fff5fbff3c0:  0x00000000049a06c0  0x00007fff5fbff418 
0x00007fff5fbff3d0:  0x0000000004063f25 <runtime.mstart+0x0000000000000005>  0x0000000004063edd <runtime.rt0_go+0x000000000000013d> 
runtime.throw({0x45b3eef, 0xffffffffffffffff})
	/opt/local/lib/go/src/runtime/panic.go:1198 +0x71
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff8afcdd9f
stack: frame={sp:0x7fff5fbff2b0, fp:0x7fff5fbff300} stack=[0x7fff5fb80370,0x7fff5fbff3e0)
0x00007fff5fbff1b0:  0x01007fff5fbff1d0  0x0000000000000004 
0x00007fff5fbff1c0:  0x000000000000001f  0x00007fff8afcdd9f 
0x00007fff5fbff1d0:  0x0000000000000000  0x0000000000000001 
0x00007fff5fbff1e0:  0x00000000040356f1 <runtime.throw+0x0000000000000071>  0x00007fff5fbff280 
0x00007fff5fbff1f0:  0x00000000045ab167  0x00007fff5fbff238 
0x00007fff5fbff200:  0x00000000040359a8 <runtime.fatalthrow.func1+0x0000000000000048>  0x00000000049a06c0 
0x00007fff5fbff210:  0x0000000000000001  0x0000000000000001 
0x00007fff5fbff220:  0x00007fff5fbff280  0x00000000040356f1 <runtime.throw+0x0000000000000071> 
0x00007fff5fbff230:  0x00000000049a06c0  0x00007fff5fbff270 
0x00007fff5fbff240:  0x0000000004035930 <runtime.fatalthrow+0x0000000000000050>  0x00007fff5fbff250 
0x00007fff5fbff250:  0x0000000004035960 <runtime.fatalthrow.func1+0x0000000000000000>  0x00000000049a06c0 
0x00007fff5fbff260:  0x00000000040356f1 <runtime.throw+0x0000000000000071>  0x00007fff5fbff280 
0x00007fff5fbff270:  0x00007fff5fbff2a0  0x00000000040356f1 <runtime.throw+0x0000000000000071> 
0x00007fff5fbff280:  0x00007fff5fbff288  0x0000000004035720 <runtime.throw.func1+0x0000000000000000> 
0x00007fff5fbff290:  0x00000000045b3eef  0x000000000000002a 
0x00007fff5fbff2a0:  0x00007fff5fbff2f0  0x000000000404b1e9 <runtime.sigpanic+0x0000000000000389> 
0x00007fff5fbff2b0: <0x00000000045b3eef  0xffffffffffffffff 
0x00007fff5fbff2c0:  0x0000000000736668  0x0000000000000000 
0x00007fff5fbff2d0:  0xff00000000000000  0x0000000000000000 
0x00007fff5fbff2e0:  0x63614d5f746e656d  0x000000002c3000f0 
0x00007fff5fbff2f0:  0x00007fff5fbff310 !0x00007fff8afcdd9f 
0x00007fff5fbff300: >0x000000002c3000f0  0x000000002c300020 
0x00007fff5fbff310:  0x00007fff5fbff340  0x00007fff8afce4cb 
0x00007fff5fbff320:  0x687469672f637273  0x000000c00013e888 
0x00007fff5fbff330:  0x000000c0000001a0  0x000000002c00d4f4 
0x00007fff5fbff340:  0x00007fff5fbff360  0x000000000406809f <runtime.syscall+0x000000000000001f> 
0x00007fff5fbff350:  0x000000c00013e888  0x000000002c2110a8 
0x00007fff5fbff360:  0x000000c00013e858  0x0000000004065f10 <runtime.asmcgocall+0x0000000000000070> 
0x00007fff5fbff370:  0x000000000401ab55 <runtime.SetFinalizer.func2+0x0000000000000035>  0x000000c000134360 
0x00007fff5fbff380:  0x00000000045e4f28  0x0000000000000010 
0x00007fff5fbff390:  0x0000000004514760  0x00000000000017d0 
0x00007fff5fbff3a0:  0x000000c0000001a0  0x0000000004064029 <runtime.systemstack+0x0000000000000049> 
0x00007fff5fbff3b0:  0x0000000000000004  0x0000000004661908 
0x00007fff5fbff3c0:  0x00000000049a06c0  0x00007fff5fbff418 
0x00007fff5fbff3d0:  0x0000000004063f25 <runtime.mstart+0x0000000000000005>  0x0000000004063edd <runtime.rt0_go+0x000000000000013d> 
runtime.sigpanic()
	/opt/local/lib/go/src/runtime/signal_unix.go:719 +0x389

goroutine 1 [syscall]:
syscall.syscall(0x407a9a0, 0x2c3000f0, 0x0, 0x0)
	/opt/local/lib/go/src/runtime/sys_darwin.go:22 +0x3b fp=0xc00013e888 sp=0xc00013e868 pc=0x4062b5b
syscall.syscall(0xc000162630, 0x90, 0xc0001a9e60, 0x0)
	<autogenerated>:1 +0x26 fp=0xc00013e8d0 sp=0xc00013e888 pc=0x4068866
syscall.closedir(0xc000132068)
	/opt/local/lib/go/src/syscall/zsyscall_darwin_amd64.go:505 +0x2f fp=0xc00013e900 sp=0xc00013e8d0 pc=0x4077c6f
os.(*dirInfo).close(...)
	/opt/local/lib/go/src/os/dir_darwin.go:23
os.(*file).close(0xc000134360)
	/opt/local/lib/go/src/os/file_unix.go:249 +0x52 fp=0xc00013e958 sp=0xc00013e900 pc=0x40d34d2
os.(*File).Close(...)
	/opt/local/lib/go/src/os/file_posix.go:26
io/ioutil.ReadDir({0xc000162630, 0x90})
	/opt/local/lib/go/src/io/ioutil/ioutil.go:64 +0x71 fp=0xc00013e9d8 sp=0xc00013e958 pc=0x4161c11
cmd/go/internal/fsys.readDir({0xc000162630, 0x0})
	/opt/local/lib/go/src/cmd/go/internal/fsys/fsys.go:246 +0x27 fp=0xc00013ea20 sp=0xc00013e9d8 pc=0x41a7ea7
cmd/go/internal/fsys.ReadDir({0xc000162630, 0xc00011b501})
	/opt/local/lib/go/src/cmd/go/internal/fsys/fsys.go:270 +0x28e fp=0xc00013edc0 sp=0xc00013ea20 pc=0x41a828e
go/build.(*Context).readDir(0x49a0220, {0xc000162630, 0xc000136574})
	/opt/local/lib/go/src/go/build/build.go:192 +0x30 fp=0xc00013ede0 sp=0xc00013edc0 pc=0x417ddd0
go/build.(*Context).Import(0x49a0220, {0xc000136574, 0x1c}, {0xc000034004, 0xc0001c1c70}, 0xc)
	/opt/local/lib/go/src/go/build/build.go:807 +0x11d8 fp=0xc00013f4d8 sp=0xc00013ede0 pc=0x417ffb8
cmd/go/internal/load.loadPackageData.func2()
	/opt/local/lib/go/src/cmd/go/internal/load/pkg.go:892 +0x187 fp=0xc00013f5c0 sp=0xc00013f4d8 pc=0x43f0a27
cmd/go/internal/par.(*Cache).Do(0x499f580, {0x44fe440, 0xc00011b570}, 0xc00013f7a0)
	/opt/local/lib/go/src/cmd/go/internal/par/work.go:128 +0xc3 fp=0xc00013f608 sp=0xc00013f5c0 pc=0x41c5723
cmd/go/internal/load.loadPackageData({0x4676ae0, 0xc000124000}, {0xc000136574, 0x1c}, {0x0, 0x0}, {0xc000034004, 0x90}, {0x0, 0x0}, ...)
	/opt/local/lib/go/src/cmd/go/internal/load/pkg.go:843 +0x465 fp=0xc00013f828 sp=0xc00013f608 pc=0x43f0725
cmd/go/internal/load.loadImport({0x4676ae0, 0xc000124000}, {0x18, 0xfa, 0x13}, 0xc00011b540, {0xc000136574, 0x1c}, {0xc000034004, 0x90}, ...)
	/opt/local/lib/go/src/cmd/go/internal/load/pkg.go:677 +0x14b fp=0xc00013f9a8 sp=0xc00013f828 pc=0x43ef22b
cmd/go/internal/load.PackagesAndErrors({0x4676ae0, 0xc000124000}, {0x2d, 0x0, 0x0}, {0xc000138010, 0x0, 0x0})
	/opt/local/lib/go/src/cmd/go/internal/load/pkg.go:2468 +0x809 fp=0xc00013fc78 sp=0xc00013f9a8 pc=0x43fb929
cmd/go/internal/work.runBuild({0x4676ae0, 0xc000124000}, 0xc000152480, {0xc000138010, 0x0, 0x0})
	/opt/local/lib/go/src/cmd/go/internal/work/build.go:371 +0xa5 fp=0xc00013fd98 sp=0xc00013fc78 pc=0x4442fa5
main.invoke(0x498d5a0, {0xc000138010, 0x1, 0x1})
	/opt/local/lib/go/src/cmd/go/main.go:216 +0x2f6 fp=0xc00013fe60 sp=0xc00013fd98 pc=0x44c5e76
main.main()
	/opt/local/lib/go/src/cmd/go/main.go:173 +0x78e fp=0xc00013ff80 sp=0xc00013fe60 pc=0x44c584e
runtime.main()
	/opt/local/lib/go/src/runtime/proc.go:255 +0x227 fp=0xc00013ffe0 sp=0xc00013ff80 pc=0x4037d87
runtime.goexit()
	/opt/local/lib/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc00013ffe8 sp=0xc00013ffe0 pc=0x4066201

goroutine 19 [semacquire]:
sync.runtime_SemacquireMutex(0xc000132058, 0xb8, 0x45440a0)
	/opt/local/lib/go/src/runtime/sema.go:71 +0x25
sync.(*Mutex).lockSlow(0xc000138364)
	/opt/local/lib/go/src/sync/mutex.go:138 +0x165
sync.(*Mutex).Lock(...)
	/opt/local/lib/go/src/sync/mutex.go:81
cmd/go/internal/par.(*Cache).Do(0x499f580, {0x44fe440, 0xc000098010}, 0xc000092e98)
	/opt/local/lib/go/src/cmd/go/internal/par/work.go:126 +0xa9
cmd/go/internal/load.loadPackageData({0x4676ae0, 0xc000124000}, {0xc000136574, 0x1c}, {0x0, 0x0}, {0xc000034004, 0x90}, {0x0, 0x0}, ...)
	/opt/local/lib/go/src/cmd/go/internal/load/pkg.go:843 +0x465
cmd/go/internal/load.(*preload).preloadMatches.func1({0xc000136574, 0x1c})
	/opt/local/lib/go/src/cmd/go/internal/load/pkg.go:999 +0xb1
created by cmd/go/internal/load.(*preload).preloadMatches
	/opt/local/lib/go/src/cmd/go/internal/load/pkg.go:997 +0x255
Command failed:  cd "/opt/local/var/macports/build/_Users_rob_Development_MacPorts_local-repo_security_totp-cli/totp-cli/work/gopath/src/github.com/yitsushi/totp-cli" && /opt/local/bin/go build 
Exit code: 2
Error: Failed to build totp-cli: command execution failed
Error: See /opt/local/var/macports/logs/_Users_rob_Development_MacPorts_local-repo_security_totp-cli/totp-cli/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.

Attachments (1)

main.log (49.9 KB) - added by RobK88 6 months ago.

Download all attachments as: .zip

Change History (12)

Changed 6 months ago by RobK88

Attachment: main.log added

comment:1 Changed 6 months ago by RobK88

Summary: toto-cli - legacy support broken in go?totp-cli - legacy support broken in go?

comment:2 Changed 6 months ago by RobK88

Description: modified (diff)

comment:3 Changed 6 months ago by RobK88

I see I did not add legacy support properly. I also tried the adding the following to the Portfile for totp-cli but received the same SIGSEGV: segmentation violation error message:

PortGroup           legacysupport 1.1

pre-build {
#   Sierra and earlier
    if { ${os.platform} eq "darwin" && ${os.major} < 17 } {
        build.env-append    GO_EXTLINK_ENABLED="1" \
                            GO_LDFLAGS="\"-extldflags=${configure.ldflags}\"" \
                            CGO_LDFLAGS="-g -O2 ${configure.ldflags}"
    }
}
Last edited 6 months ago by RobK88 (previous) (diff)

comment:4 Changed 6 months ago by RobK88

Summary: totp-cli - legacy support broken in go?totp-cli - legacy support broken in go? - SIGSEGV: segmentation violation

comment:5 Changed 6 months ago by RobK88

P.S. If I download the precompiled binary from the developer's website and run it, I see:

rob$ /Users/rob/Downloads/totp-cli 
dyld: Symbol not found: _clock_gettime
  Referenced from: /Users/rob/Downloads/totp-cli
  Expected in: flat namespace

Trace/BPT trap: 5

So it sure looks like a legacy support issue. The symbol _clock_gettime is likely not natively found on Macs running Lion.

comment:6 Changed 6 months ago by RobK88

FYI -- If you want to see the whole Portfile for totp-cli, you can see the latest Pull Request (PR) to update the port to the latest version 1.8.3 here:

https://github.com/macports/macports-ports/pull/21366

comment:7 Changed 6 months ago by ryandesign (Ryan Carsten Schmidt)

Zillions of go-based ports in MacPorts don't build on legacy systems. I'm not aware of any effort underway to either fix that or properly mark those ports as not supporting those systems.

comment:8 Changed 6 months ago by RobK88

@ryandesign - Thank Ryan for confirming my suspicions. I was hoping that by adding the environment variables to the Portfile for totp-cli as recommended in the note to the go port, the totp-cli port would build on legacy Macs. I now see that was false hope.

Since older versions of totp-cli (such as v 1.2.5) do build on legacy Macs, it looks like the best solution is to modify the Portfile for totp-cli so MacPorts would install the last working version on legacy Macs.

Last edited 6 months ago by RobK88 (previous) (diff)

comment:9 Changed 5 months ago by RobK88

It does not look like there is a problem with the totp-cli port.

It looks like the legacy go compiler is completely broken. See https://trac.macports.org/ticket/68700#ticket

comment:10 in reply to:  5 Changed 2 months ago by barracuda156

Replying to RobK88:

P.S. If I download the precompiled binary from the developer's website and run it, I see:

rob$ /Users/rob/Downloads/totp-cli 
dyld: Symbol not found: _clock_gettime
  Referenced from: /Users/rob/Downloads/totp-cli
  Expected in: flat namespace

Trace/BPT trap: 5

So it sure looks like a legacy support issue. The symbol _clock_gettime is likely not natively found on Macs running Lion.

Try linking it manually to legacy-support?

comment:11 in reply to:  9 Changed 2 months ago by barracuda156

Replying to RobK88:

It does not look like there is a problem with the totp-cli port.

It looks like the legacy go compiler is completely broken. See https://trac.macports.org/ticket/68700#ticket

It probably is. The question is whether the right approach is to try to fix the versions used currently or fallback to earlier ones which must have worked at some point (I suspect, it may not coincide, however, with upstream claims of either supporting a given system or not).

Note: See TracTickets for help on using tickets.