Closed iffy closed 1 year ago
There are several bugs here at once:
assert
raises a Defect
and you cannot reason about behavior after thattestit.nim(15) testit
Nim/lib/system/excpt.nim(417) nimLeaveFinally
Nim/lib/system/excpt.nim(408) reportUnhandledError
Nim/lib/system/excpt.nim(360) reportUnhandledErrorAux
Nim/lib/system/excpt.nim(631) signalHandler
indicating that this is a bug in nim itself.
Okay, thank you! I'll file upstream.
assert false
to raise ValueError.newException("foo")
it still segfaults. Is my understanding correct that raising ValueError
is not a Defect
?How did you get the call stack? I've been going crazy trying to track down what's happening.
by running it in the nimbus build environment which does magic things for call stacks that I'm not entirely sure how they work (git clone nimbus-eth2; make; ./env.sh bash
)
still segfaults
this is the Nim bug that the call stack hints at - better repro code is:
import chronos
type
Obj = ref object
queue: AsyncQueue[string]
proc newQueue(o: Obj): AsyncQueue[string] =
o.queue = newAsyncQueue[string]()
return o.queue
try:
var o = Obj()
var oq = o.newQueue()
defer: waitFor o.queue.addLast("foo")
raise (ref ValueError)(msg: "test")
except ValueError:
echo "test"
ie the code triggers an error even when the exception is actually caught - this is likely a closure transformation bug in the exception handling
Thanks! I've filed upstream, so I'll close this as it's not a chronos
issue.
On my macOS machine, this minimal code produces the following result:
Result of
nim c -r tests/test_tmp
:If I take any line out, it doesn't segfault.
defer
,waitFor
,AsyncQueue
or my code?