diff options
author | Ștefan Talpalaru <stefantalpalaru@yahoo.com> | 2021-05-19 19:19:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-19 19:19:11 +0200 |
commit | a1c82c39af812b54cd3dd1e472c9088457fb7dc5 (patch) | |
tree | aecc61e015df41e7a68d960e911d249e7fe141eb /tests/async | |
parent | 7052503ca8d360f11fabf476f7450dc3f794a602 (diff) | |
download | Nim-a1c82c39af812b54cd3dd1e472c9088457fb7dc5.tar.gz |
asyncdispatch+stackTraceOverride: fix premature collection (#18039) [backport:1.2]
Copying StackTraceEntry instances when nimStackTraceOverride is defined breaks the link between a cstring field that's supposed to point at another string field in the same object. Sometimes, the original object is garbage collected, that memory region reused for storing other strings, so when the StackTraceEntry copy tries to use its cstring pointer to construct a traceback message, it accesses unrelated strings. This only happens for async tracebacks and this patch prevents that by making sure we only use the string fields when nimStackTraceOverride is defined. Async tracebacks also beautified slightly by getting rid of an extra line that was supposed to be commented out, along with the corresponding debugging output. There's also a micro-optimisation to avoid concatenating two strings just to get their combined length.
Diffstat (limited to 'tests/async')
-rw-r--r-- | tests/async/tasync_traceback.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/async/tasync_traceback.nim b/tests/async/tasync_traceback.nim index 9f787929b..cd16b2257 100644 --- a/tests/async/tasync_traceback.nim +++ b/tests/async/tasync_traceback.nim @@ -86,7 +86,7 @@ Async traceback: asyncfutures\.nim\(\d+?\)\s+?read \]# Exception message: b failure -Exception type: + bar failure Async traceback: @@ -114,7 +114,7 @@ Async traceback: asyncfutures\.nim\(\d+?\)\s+?read \]# Exception message: bar failure -Exception type: + """ # TODO: is asyncmacro good enough location for fooIter traceback/debugging? just put the callsite info for all? |