awnumar / memguard

Secure software enclave for storage of sensitive information in memory.
Apache License 2.0
2.49k stars 124 forks source link

panic: runtime error: coffer partition disappears #136

Closed awnumar closed 1 year ago

awnumar commented 3 years ago

Describe the bug

This example crashes sporadically on my system.

To Reproduce

go test -v -count=10 ./examples/deadlock

Traces

=== RUN   TestPanicsPoC
[] [14 227 172 214 47 31 152 84 236 122 1 107 223 116 37 0 158 52 188 103 100 78 201 60 202 48 122 169 17 135 212 236]
panic: open verify fail

goroutine 26 [running]:
github.com/awnumar/memguard/examples/deadlock.immediateOpen(0x59ed20, 0xc000054420, 0xc00000e060, 0xc000014440, 0x20, 0x20)
    /home/awn/projects/src/go/src/github.com/awnumar/memguard/examples/deadlock/poc.go:80 +0x26e
github.com/awnumar/memguard/examples/deadlock.OpenEnclave.func1(0xc000010230, 0xa, 0xa, 0xc00001c260, 0xc000136000, 0xa, 0xa, 0xa, 0x59ed20, 0xc000054420)
    /home/awn/projects/src/go/src/github.com/awnumar/memguard/examples/deadlock/poc.go:40 +0xe8
created by github.com/awnumar/memguard/examples/deadlock.OpenEnclave
    /home/awn/projects/src/go/src/github.com/awnumar/memguard/examples/deadlock/poc.go:32 +0x2bf
FAIL    github.com/awnumar/memguard/examples/deadlock   0.010s
FAIL
=== RUN   TestPanicsPoC
panic: runtime error: index out of range [0] with length 0

goroutine 266 [running]:
github.com/awnumar/memguard/core.(*Coffer).View(0xc0001082a0, 0x0, 0x0, 0x0)
    /home/awn/projects/src/go/src/github.com/awnumar/memguard/core/coffer.go:123 +0x207
github.com/awnumar/memguard/core.Open(0xc0000a80c0, 0x0, 0x0, 0x0)
    /home/awn/projects/src/go/src/github.com/awnumar/memguard/core/enclave.go:101 +0x60
github.com/awnumar/memguard.(*Enclave).Open(0xc0000a2038, 0x0, 0x0, 0x0)
    /home/awn/projects/src/go/src/github.com/awnumar/memguard/enclave.go:43 +0x32
github.com/awnumar/memguard/examples/deadlock.openVerify(0xc0000a2038, 0xc0000a6240, 0x20, 0x20, 0x0, 0x0)
    /home/awn/projects/src/go/src/github.com/awnumar/memguard/examples/deadlock/poc.go:55 +0x58
github.com/awnumar/memguard/examples/deadlock.immediateOpen.func1(0xc0000a2038, 0xc0000a6240, 0x20, 0x20, 0xc000180960)
    /home/awn/projects/src/go/src/github.com/awnumar/memguard/examples/deadlock/poc.go:71 +0x49
created by github.com/awnumar/memguard/examples/deadlock.immediateOpen
    /home/awn/projects/src/go/src/github.com/awnumar/memguard/examples/deadlock/poc.go:70 +0xc8
FAIL    github.com/awnumar/memguard/examples/deadlock   0.068s

System (please complete the following information):

awnumar commented 1 year ago

Setting ulimit -l to a high value prevents both of these panics