我的Go应用程序连接到IBM MQ。
当我的应用程序抛出分段违规错误(信号SIGSEGV)时,IBM MQ注册的信号处理程序使我的应用程序抛出“没有SA_ONSTACK标志的非Go代码设置信号处理程序”。
那我怎么设置那个标志呢?
package main
import (
"fmt"
"github.com/ibm-messaging/mq-golang/ibmmq"
)
type A struct {
Str string
}
type B struct {
Apointer *A
}
func main() {
connectIBMMQ()
b := B{}
fmt.Println(b.Apointer.Str)
}
const (
QMgrName = `QMgrName`
ChannelName = `ChannelName`
ConnectionName = `0.0.0.0(1416)`
Username = `username`
Password = `password`
)
func connectIBMMQ() {
mqcd := ibmmq.NewMQCD()
mqcd.ChannelName = ChannelName
mqcd.ConnectionName = ConnectionName
csp := ibmmq.NewMQCSP()
csp.AuthenticationType = ibmmq.MQCSP_AUTH_USER_ID_AND_PWD
csp.UserId = Username
csp.Password = Password
cno := ibmmq.NewMQCNO()
cno.ClientConn = mqcd
cno.Options = ibmmq.MQCNO_CLIENT_BINDING + ibmmq.MQCNO_RECONNECT + ibmmq.MQCNO_HANDLE_SHARE_BLOCK
cno.SecurityParms = csp
ibmmq.Connx(QMgrName, cno)
}
https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.1.0/com.ibm.mq.dev.doc/q025880_.htm https://golang.org/pkg/os/signal/#hdr-Go_programs_that_use_cgo_or_SWIG
signal 11 received but handler not on signal stack
fatal error: non-Go code set up signal handler without SA_ONSTACK flag
runtime stack:
runtime: unexpected return pc for runtime.sigtramp called from 0x7f60f6e9a517
stack: frame={sp:0xc000046628, fp:0xc000046680} stack=[0xc00003e578,0xc000046978)
000000c000046528: 000000c000046530 00000000004549a0 <runtime.throw.func1+0>
000000c000046538: 00000000004e2c3b 0000000000000039
000000c000046548: 000000c000046568 00000000004415df <runtime.sigNotOnStack+127>
000000c000046558: 00000000004e2c3b 0000000000000039
000000c000046568: 000000c000046618 0000000000440c6d <runtime.sigtrampgo+749>
000000c000046578: 000000000000000b 000000c000046600
000000c000046588: 000000c000046880 0000000000000000
000000c000046598: 0000000000000000 000000c000046628
000000c0000465a8: 0000000000000000 0000000000000000
000000c0000465b8: 0000000000000000 0000000000000000
000000c0000465c8: 0000000000000000 000000c000000180
000000c0000465d8: 0000000000000000 ffffffffffffffff
000000c0000465e8: 0000000000000000 0000000000000000
000000c0000465f8: 0000000000000000 000000c000002000
000000c000046608: 0000000000000000 0000000000008000
000000c000046618: 000000c000046670 0000000000459a33 <runtime.sigtramp+67>
000000c000046628: <000000000000000b 000000c0000469b0
000000c000046638: 000000c000046880 000000c000046880
000000c000046648: 000000c0000469b0 0000000000000000
000000c000046658: 000000000000000b 000000c000046670
000000c000046668: 00007f60f78213c0 000000000262e400
000000c000046678: !00007f60f6e9a517 >000000c000046690
000000c000046688: 8e26f8f48c919100 0000000000000000
000000c000046698: 0000000000000000 0000000000000008
000000c0000466a8: 0000000000000000 000000c000000180
000000c0000466b8: 0000000000000000 0000000000000000
000000c0000466c8: 0000000000000000 0000000000000000
000000c0000466d8: 0000000000000000 0000000000000000
000000c0000466e8: 0000000000000000 0000000000000000
000000c0000466f8: 0000000000000000 0000000000000000
000000c000046708: 0000000000000000 0000000000000000
000000c000046718: 0000000000000000 000000c000046f88
000000c000046728: 0000000000000004 0000000000000012
000000c000046738: 00000000004f21e1 0000000000000000
000000c000046748: 00007f60f6e9b45a 0000000000000000
000000c000046758: 0000000000000000 0000000000000000
000000c000046768: 0000000000000000 0000000000000000
000000c000046778: 0000000000000000
runtime.throw(0x4e2c3b, 0x39)
/usr/local/go/src/runtime/panic.go:617 +0x72
runtime.sigNotOnStack(0xb)
/usr/local/go/src/runtime/signal_unix.go:576 +0x7f
runtime.sigtrampgo(0xb, 0xc0000469b0, 0xc000046880)
/usr/local/go/src/runtime/signal_unix.go:334 +0x2ed
runtime: unexpected return pc for runtime.sigtramp called from 0x7f60f6e9a517
stack: frame={sp:0xc000046628, fp:0xc000046680} stack=[0xc00003e578,0xc000046978)
000000c000046528: 000000c000046530 00000000004549a0 <runtime.throw.func1+0>
000000c000046538: 00000000004e2c3b 0000000000000039
000000c000046548: 000000c000046568 00000000004415df <runtime.sigNotOnStack+127>
000000c000046558: 00000000004e2c3b 0000000000000039
000000c000046568: 000000c000046618 0000000000440c6d <runtime.sigtrampgo+749>
000000c000046578: 000000000000000b 000000c000046600
000000c000046588: 000000c000046880 0000000000000000
000000c000046598: 0000000000000000 000000c000046628
000000c0000465a8: 0000000000000000 0000000000000000
000000c0000465b8: 0000000000000000 0000000000000000
000000c0000465c8: 0000000000000000 000000c000000180
000000c0000465d8: 0000000000000000 ffffffffffffffff
000000c0000465e8: 0000000000000000 0000000000000000
000000c0000465f8: 0000000000000000 000000c000002000
000000c000046608: 0000000000000000 0000000000008000
000000c000046618: 000000c000046670 0000000000459a33 <runtime.sigtramp+67>
000000c000046628: <000000000000000b 000000c0000469b0
000000c000046638: 000000c000046880 000000c000046880
000000c000046648: 000000c0000469b0 0000000000000000
000000c000046658: 000000000000000b 000000c000046670
000000c000046668: 00007f60f78213c0 000000000262e400
000000c000046678: !00007f60f6e9a517 >000000c000046690
000000c000046688: 8e26f8f48c919100 0000000000000000
000000c000046698: 0000000000000000 0000000000000008
000000c0000466a8: 0000000000000000 000000c000000180
000000c0000466b8: 0000000000000000 0000000000000000
000000c0000466c8: 0000000000000000 0000000000000000
000000c0000466d8: 0000000000000000 0000000000000000
000000c0000466e8: 0000000000000000 0000000000000000
000000c0000466f8: 0000000000000000 0000000000000000
000000c000046708: 0000000000000000 0000000000000000
000000c000046718: 0000000000000000 000000c000046f88
000000c000046728: 0000000000000004 0000000000000012
000000c000046738: 00000000004f21e1 0000000000000000
000000c000046748: 00007f60f6e9b45a 0000000000000000
000000c000046758: 0000000000000000 0000000000000000
000000c000046768: 0000000000000000 0000000000000000
000000c000046778: 0000000000000000
runtime.sigtramp(0xc000046690, 0x8e26f8f48c919100, 0x0, 0x0, 0x8, 0x0, 0xc000000180, 0x0, 0x0, 0x0, ...)
/usr/local/go/src/runtime/sys_linux_amd64.s:357 +0x43
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc00004afe8 sp=0xc00004afe0 pc=0x457e41
goroutine 1 [running]:
goroutine running on other thread; stack unavailable
答案 0 :(得分:0)
您可以尝试设置环境变量“ MQS_NO_SYNC_SIGNAL_HANDLING = true”以禁用MQ的某些信号设置。至少应该更好地了解SEGV的来源。