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

Panic under macos #18

Open
longfangsong opened this issue Jan 10, 2022 · 2 comments
Open

Panic under macos #18

longfangsong opened this issue Jan 10, 2022 · 2 comments

Comments

@longfangsong
Copy link
Contributor

Environment:
OS: macOS 10.15.7 (19H1615) Darwin 19.6.0
File system: case sensitive APFS

How to reproduce:

make lab1P0
=== RUN   TestRawGet1
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff70e0a70a]

runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff70e0a70a
stack: frame={sp:0x7ffeefbff548, fp:0x7ffeefbff598} stack=[0x7ffeefb805e8,0x7ffeefbff650)
0x00007ffeefbff448:  0x01007ffeefbff468  0x0000000000000004 
0x00007ffeefbff458:  0x000000000000001f  0x00007fff70e0a70a 
0x00007ffeefbff468:  0x0b01dfacedebac1e  0x0000000000000001 
0x00007ffeefbff478:  0x0000000004038a71 <runtime.throw+0x0000000000000071>  0x00007ffeefbff518 
0x00007ffeefbff488:  0x000000000492a251  0x00007ffeefbff4d0 
0x00007ffeefbff498:  0x0000000004038d28 <runtime.fatalthrow.func1+0x0000000000000048>  0x0000000005045680 
0x00007ffeefbff4a8:  0x0000000000000001  0x0000000000000001 
0x00007ffeefbff4b8:  0x00007ffeefbff518  0x0000000004038a71 <runtime.throw+0x0000000000000071> 
0x00007ffeefbff4c8:  0x0000000005045680  0x00007ffeefbff508 
0x00007ffeefbff4d8:  0x0000000004038cb0 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff4e8 
0x00007ffeefbff4e8:  0x0000000004038ce0 <runtime.fatalthrow.func1+0x0000000000000000>  0x0000000005045680 
0x00007ffeefbff4f8:  0x0000000004038a71 <runtime.throw+0x0000000000000071>  0x00007ffeefbff518 
0x00007ffeefbff508:  0x00007ffeefbff538  0x0000000004038a71 <runtime.throw+0x0000000000000071> 
0x00007ffeefbff518:  0x00007ffeefbff520  0x0000000004038aa0 <runtime.throw.func1+0x0000000000000000> 
0x00007ffeefbff528:  0x00000000049373cc  0x000000000000002a 
0x00007ffeefbff538:  0x00007ffeefbff588  0x000000000404eef6 <runtime.sigpanic+0x0000000000000396> 
0x00007ffeefbff548: <0x00000000049373cc  0x0000000004d982a8 
0x00007ffeefbff558:  0x0100000004f2cc00  0x0000000005294a78 
0x00007ffeefbff568:  0x0000000000001260  0x0000000005045820 
0x00007ffeefbff578:  0x0000000005294af0  0x00007ffeefbff5d8 
0x00007ffeefbff588:  0x00007ffeefbff5d0 !0x00007fff70e0a70a 
0x00007ffeefbff598: >0x00007ffeefbff5d0  0x0000000004f18000 
0x00007ffeefbff5a8:  0x00000000000004bd  0x0000000004153285 <golang.org/x/sys/unix.libc_flock_trampoline+0x0000000000000005> 
0x00007ffeefbff5b8:  0x000000000406dbbf <runtime.syscall+0x000000000000001f>  0x000000c0001a33e8 
0x00007ffeefbff5c8:  0x00000000057a1198  0x000000c0001a33b8 
0x00007ffeefbff5d8:  0x000000000406ba10 <runtime.asmcgocall+0x0000000000000070>  0x000000000401c215 <runtime.SetFinalizer.func2+0x0000000000000035> 
0x00007ffeefbff5e8:  0x000000c00007f260  0x0000000004964ea8 
0x00007ffeefbff5f8:  0x0000000000000010  0x0000000004821fc0 
0x00007ffeefbff608:  0x0000000000000c70  0x000000c00018f1e0 
0x00007ffeefbff618:  0x0000000004069b29 <runtime.systemstack+0x0000000000000049>  0x0000000000000004 
0x00007ffeefbff628:  0x0000000004a072e0  0x0000000005045680 
0x00007ffeefbff638:  0x00007ffeefbff688  0x0000000004069a25 <runtime.mstart+0x0000000000000005> 
0x00007ffeefbff648:  0x00000000040699dd <runtime.rt0_go+0x000000000000013d> 
runtime.throw({0x49373cc, 0x4d982a8})
        /usr/local/Cellar/go/1.17.5/libexec/src/runtime/panic.go:1198 +0x71
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff70e0a70a
stack: frame={sp:0x7ffeefbff548, fp:0x7ffeefbff598} stack=[0x7ffeefb805e8,0x7ffeefbff650)
0x00007ffeefbff448:  0x01007ffeefbff468  0x0000000000000004 
0x00007ffeefbff458:  0x000000000000001f  0x00007fff70e0a70a 
0x00007ffeefbff468:  0x0b01dfacedebac1e  0x0000000000000001 
0x00007ffeefbff478:  0x0000000004038a71 <runtime.throw+0x0000000000000071>  0x00007ffeefbff518 
0x00007ffeefbff488:  0x000000000492a251  0x00007ffeefbff4d0 
0x00007ffeefbff498:  0x0000000004038d28 <runtime.fatalthrow.func1+0x0000000000000048>  0x0000000005045680 
0x00007ffeefbff4a8:  0x0000000000000001  0x0000000000000001 
0x00007ffeefbff4b8:  0x00007ffeefbff518  0x0000000004038a71 <runtime.throw+0x0000000000000071> 
0x00007ffeefbff4c8:  0x0000000005045680  0x00007ffeefbff508 
0x00007ffeefbff4d8:  0x0000000004038cb0 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff4e8 
0x00007ffeefbff4e8:  0x0000000004038ce0 <runtime.fatalthrow.func1+0x0000000000000000>  0x0000000005045680 
0x00007ffeefbff4f8:  0x0000000004038a71 <runtime.throw+0x0000000000000071>  0x00007ffeefbff518 
0x00007ffeefbff508:  0x00007ffeefbff538  0x0000000004038a71 <runtime.throw+0x0000000000000071> 
0x00007ffeefbff518:  0x00007ffeefbff520  0x0000000004038aa0 <runtime.throw.func1+0x0000000000000000> 
0x00007ffeefbff528:  0x00000000049373cc  0x000000000000002a 
0x00007ffeefbff538:  0x00007ffeefbff588  0x000000000404eef6 <runtime.sigpanic+0x0000000000000396> 
0x00007ffeefbff548: <0x00000000049373cc  0x0000000004d982a8 
0x00007ffeefbff558:  0x0100000004f2cc00  0x0000000005294a78 
0x00007ffeefbff568:  0x0000000000001260  0x0000000005045820 
0x00007ffeefbff578:  0x0000000005294af0  0x00007ffeefbff5d8 
0x00007ffeefbff588:  0x00007ffeefbff5d0 !0x00007fff70e0a70a 
0x00007ffeefbff598: >0x00007ffeefbff5d0  0x0000000004f18000 
0x00007ffeefbff5a8:  0x00000000000004bd  0x0000000004153285 <golang.org/x/sys/unix.libc_flock_trampoline+0x0000000000000005> 
0x00007ffeefbff5b8:  0x000000000406dbbf <runtime.syscall+0x000000000000001f>  0x000000c0001a33e8 
0x00007ffeefbff5c8:  0x00000000057a1198  0x000000c0001a33b8 
0x00007ffeefbff5d8:  0x000000000406ba10 <runtime.asmcgocall+0x0000000000000070>  0x000000000401c215 <runtime.SetFinalizer.func2+0x0000000000000035> 
0x00007ffeefbff5e8:  0x000000c00007f260  0x0000000004964ea8 
0x00007ffeefbff5f8:  0x0000000000000010  0x0000000004821fc0 
0x00007ffeefbff608:  0x0000000000000c70  0x000000c00018f1e0 
0x00007ffeefbff618:  0x0000000004069b29 <runtime.systemstack+0x0000000000000049>  0x0000000000000004 
0x00007ffeefbff628:  0x0000000004a072e0  0x0000000005045680 
0x00007ffeefbff638:  0x00007ffeefbff688  0x0000000004069a25 <runtime.mstart+0x0000000000000005> 
0x00007ffeefbff648:  0x00000000040699dd <runtime.rt0_go+0x000000000000013d> 
runtime.sigpanic()
        /usr/local/Cellar/go/1.17.5/libexec/src/runtime/signal_unix.go:719 +0x396

goroutine 12 [syscall]:
syscall.syscall(0x4153280, 0x6, 0x6, 0x0)
        /usr/local/Cellar/go/1.17.5/libexec/src/runtime/sys_darwin.go:22 +0x3b fp=0xc0001a33e8 sp=0xc0001a33c8 pc=0x406865b
syscall.syscall(0xc0001a3450, 0x0, 0xc000000000, 0x13)
        <autogenerated>:1 +0x26 fp=0xc0001a3430 sp=0xc0001a33e8 pc=0x406e406
golang.org/x/sys/unix.Flock(0xc0003b2700, 0xe)
        /Users/longfangsong/go/pkg/mod/golang.org/x/sys@v0.0.0-20191120155948-bd437916bb0e/unix/zsyscall_darwin_amd64.go:1150 +0x38 fp=0xc0001a3460 sp=0xc0001a3430 pc=0x4152ed8
github.com/Connor1996/badger.acquireDirectoryLock({0xc0003b2700, 0xe}, {0x490b7c2, 0x0}, 0x0)
        /Users/longfangsong/go/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20211220080806-e856748bd047/dir_unix.go:61 +0x125 fp=0xc0001a3520 sp=0xc0001a3460 pc=0x4509665
github.com/Connor1996/badger.Open({{0xc0003b2700, 0xe}, {0xc0003b2700, 0xe}, 0x1, 0x1, 0x0, 0x4000000, 0x20, 0x5, ...})
        /Users/longfangsong/go/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20211220080806-e856748bd047/db.go:214 +0x3c5 fp=0xc0001a3a08 sp=0xc0001a3520 pc=0x45028c5
github.com/pingcap-incubator/tinykv/kv/util/engine_util.CreateDB({0x490b04d, 0x2}, 0xc000336dc0)
        /Users/longfangsong/pingcap/vldb-labs-longfangsong/tinykv/kv/util/engine_util/engines.go:78 +0x27a fp=0xc0001a3da0 sp=0xc0001a3a08 pc=0x454243a
github.com/pingcap-incubator/tinykv/kv/storage/standalone_storage.NewStandAloneStorage(...)
        /Users/longfangsong/pingcap/vldb-labs-longfangsong/tinykv/kv/storage/standalone_storage/standalone_storage.go:19
github.com/pingcap-incubator/tinykv/kv/server.TestRawGet1(0x40092b9)
        /Users/longfangsong/pingcap/vldb-labs-longfangsong/tinykv/kv/server/server_test.go:55 +0x5f fp=0xc0001a3f70 sp=0xc0001a3da0 pc=0x46cf73f
testing.tRunner(0xc0003bc4e0, 0x4964538)
        /usr/local/Cellar/go/1.17.5/libexec/src/testing/testing.go:1259 +0x102 fp=0xc0001a3fc0 sp=0xc0001a3f70 pc=0x4108842
testing.(*T).Run·dwrap·21()
        /usr/local/Cellar/go/1.17.5/libexec/src/testing/testing.go:1306 +0x2a fp=0xc0001a3fe0 sp=0xc0001a3fc0 pc=0x410954a
runtime.goexit()
        /usr/local/Cellar/go/1.17.5/libexec/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc0001a3fe8 sp=0xc0001a3fe0 pc=0x406bd01
created by testing.(*T).Run
        /usr/local/Cellar/go/1.17.5/libexec/src/testing/testing.go:1306 +0x35a

goroutine 1 [chan receive]:
testing.(*T).Run(0xc0003bc340, {0x4913925, 0x13dba354fa24}, 0x4964538)
        /usr/local/Cellar/go/1.17.5/libexec/src/testing/testing.go:1307 +0x375
testing.runTests.func1(0xc0003b0750)
        /usr/local/Cellar/go/1.17.5/libexec/src/testing/testing.go:1598 +0x6e
testing.tRunner(0xc0003bc340, 0xc000317d18)
        /usr/local/Cellar/go/1.17.5/libexec/src/testing/testing.go:1259 +0x102
testing.runTests(0xc000120700, {0x5018b40, 0xb, 0xb}, {0x408ae6d, 0x4917220, 0x5044d00})
        /usr/local/Cellar/go/1.17.5/libexec/src/testing/testing.go:1596 +0x43f
testing.(*M).Run(0xc000120700)
        /usr/local/Cellar/go/1.17.5/libexec/src/testing/testing.go:1504 +0x51d
main.main()
        _testmain.go:63 +0x14b
FAIL    github.com/pingcap-incubator/tinykv/kv/server   0.565s
FAIL
@you06
Copy link
Contributor

you06 commented Jan 11, 2022

I find this syscall also in the official badger, usage.

package main

import (
	badger "github.com/dgraph-io/badger/v3"
)

func main() {
	db, err := badger.Open(badger.DefaultOptions("/tmp/badger"))
	if err != nil {
		panic(err)
	}
	defer db.Close()
	if err := db.Update(func(txn *badger.Txn) error {
		return txn.Set([]byte("key"), []byte("value"))
	}); err != nil {
		panic(err)
	}
	println("Put Value:", "value")
	if err := db.View(func(txn *badger.Txn) error {
		item, err := txn.Get([]byte("key"))
		if err != nil {
			return err
		}
		val, err := item.ValueCopy([]byte{})
		if err != nil {
			return err
		}
		println("Get Value:", string(val))
		return nil
	}); err != nil {
		panic(err)
	}
}

Can you try this case and check the output? It works in my machines(amd64 Linux and arm MacOS) and got the following result:

» go run main.go
badger 2022/01/11 14:06:10 INFO: All 1 tables opened in 0s
badger 2022/01/11 14:06:10 INFO: Discard stats nextEmptySlot: 0
badger 2022/01/11 14:06:10 INFO: Set nextTxnTs to 1
Put Value: value
Get Value: value
badger 2022/01/11 14:06:10 INFO: Lifetime L0 stalled for: 0s
badger 2022/01/11 14:06:10 INFO: 
Level 0 [ ]: NumTables: 02. Size: 342 B of 0 B. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 64 MiB
Level 1 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 2 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 3 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 4 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 5 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level 6 [B]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
Level Done

@longfangsong
Copy link
Contributor Author

This case works well and produces the same output...
However I found the problem is caused by golang v1.17, maybe similiar with golang/go#49992
Downgrade to golang v1.16 is an effictive workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants