-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fixes #25306; Dangling pointers in stack traces with -d:nimStackTraceOverride
#25313
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
base: devel
Are you sure you want to change the base?
Conversation
|
maybe add |
I can add it for |
I think there's more value adding it always to remove as many differences as possible between override and non-override mode |
|
That would potentially break external libraries that use type
StackTraceEntry* = object
when defined(nimStackTraceOverride):
programCounter*: uint ## Program counter - will be used to get the rest of the info,
## when `$` is called on this type. We can't use
## "cuintptr_t" in here.
procnameStr*, filenameStr*: string ## GC-ed alternatives to "procname" and "filename"
else:
procname*: cstring ## Name of the proc that is currently executing.
filename*: cstring ## Filename of the proc that is currently executing.
when defined(nimStackTraceOverride):
proc `procname`*(s: StackTraceEntry): cstring =
s.procnameStr.cstring
proc `filename`*(s: StackTraceEntry): cstring =
s.filenameStr.cstringIdeally, we only provide accessors for |
come to think of it, this is tricky because in current versions, libbacktrace has to set these values to a valid pointer as part of constructing the trace entry. another way I thought of was to implement an actual |
| for i in 0..<s.len: | ||
| let entry = addr s[i] | ||
| result.add(copyStackTraceEntry entry) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to copy anything here, all you need to do it to patch every entry after an add operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strictly speaking, in this particular case, one would want to move the existing entries...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add operation triggers a copy, which is marked {.error.}. Perhaps I need to use nodestroy or something?
fixes #25306