Your Question
It's a probabilistic problem, and it's only happened once. When the query statement "where" is executed, the program crashes and the service exits. The stack is as follows:
unexpected fault address 0x0 fatal error: fault [signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x55c8920c9f29]
goroutine 62 [running]: runtime.throw({0x55c892218d84, 0x55c891b64011}) runtime/panic.go:1198 +0x71 fp=0xc00047caa0 sp=0xc00047ca70 pc=0x55c891b8e3b1 runtime.sigpanic() runtime/signal_unix.go:743 +0x2f6 fp=0xc00047caf0 sp=0xc00047caa0 pc=0x55c891ba3e56 gorm.io/gorm.(Statement).BuildCondition(0xc0001ca540, {0x55c8925a91a0, 0xc000229a40}, {0x0, 0xc00047d2b0, 0xc00047d1c8}) gorm.io/gorm@v1.23.4/statement.go:392 +0x1989 fp=0xc00047d178 sp=0xc00047caf0 pc=0x55c8920c9f29 gorm.io/gorm.(DB).Where(0x0, {0x55c8925a91a0, 0xc000229a40}, {0x0, 0x0, 0x0}) gorm.io/gorm@v1.23.4/chainable_api.go:157 +0x6c fp=0xc00047d1d8 sp=0xc00047d178 pc=0x55c8920b7a0c
Here's the code with my error
func QueryMkByName(mkName string, userID string) (*MK, error) {
var mk MK
if result := DB.Where(&MK{UserID: userID, MKName: mkName}).Find(&mk); result.Error != nil {
return nil, result.Error
}
return &mk, nil
}
The document you expected this should be explained
Expected answer
Can you explain the cause and how to reproduce the problem? And I want to make sure if it's my code error or the gorm framework error.
Comment From: luxiangx
other code bug
Comment From: KingPuiWong
I also encountered this problem today. I suspect it was caused by db or consul. What is the cause of it?
Comment From: WilliamYang1992
@luxiangx Hi,how it happend? How to solve it? I encounter same problem