palves at redhat dot com
2018-07-18 23:52:48 UTC
https://sourceware.org/bugzilla/show_bug.cgi?id=23429
Bug ID: 23429
Summary: GCC plugin to automatically detect live
non-trivially-destructible objects when guile
exceptions are thrown
Product: gdb
Version: unknown
Status: NEW
Severity: normal
Priority: P2
Component: guile
Assignee: unassigned at sourceware dot org
Reporter: palves at redhat dot com
Target Milestone: ---
A complication with the Guile code is that we have two types of exceptions to
consider: GDB/C++ exceptions, and Guile/SJLJ exceptions.
Because Guile exceptions are SJLJ based, we must make sure to not have live
local variables of types with non-trivial dtors when a Guile exception is
thrown, because the dtors won't be run when a Guile exceptions is thrown.
We currently have code in the tree that violates this. E.g.:
void
gdbscm_parse_function_args (const char *func_name,
int beginning_arg_pos,
const SCM *keywords,
const char *format, ...)
{
...
/* Keep track of malloc'd strings. We need to free them upon error. */
std::vector<char *> allocated_strings;
...
for (char *ptr : allocated_strings)
xfree (ptr);
gdbscm_throw (status); /// dtor of "allocated_strings" is not run!
}
It would be nice if we had a way to make it impossible to write such code.
One idea would be to annotate the functions that may throw a Scheme exception
with some attribute that would be recognized by a custom GCC plugin that would
them detect the violations.
We could probably borrow much of the Python checker plugins for this?
Bug ID: 23429
Summary: GCC plugin to automatically detect live
non-trivially-destructible objects when guile
exceptions are thrown
Product: gdb
Version: unknown
Status: NEW
Severity: normal
Priority: P2
Component: guile
Assignee: unassigned at sourceware dot org
Reporter: palves at redhat dot com
Target Milestone: ---
A complication with the Guile code is that we have two types of exceptions to
consider: GDB/C++ exceptions, and Guile/SJLJ exceptions.
Because Guile exceptions are SJLJ based, we must make sure to not have live
local variables of types with non-trivial dtors when a Guile exception is
thrown, because the dtors won't be run when a Guile exceptions is thrown.
We currently have code in the tree that violates this. E.g.:
void
gdbscm_parse_function_args (const char *func_name,
int beginning_arg_pos,
const SCM *keywords,
const char *format, ...)
{
...
/* Keep track of malloc'd strings. We need to free them upon error. */
std::vector<char *> allocated_strings;
...
for (char *ptr : allocated_strings)
xfree (ptr);
gdbscm_throw (status); /// dtor of "allocated_strings" is not run!
}
It would be nice if we had a way to make it impossible to write such code.
One idea would be to annotate the functions that may throw a Scheme exception
with some attribute that would be recognized by a custom GCC plugin that would
them detect the violations.
We could probably borrow much of the Python checker plugins for this?
--
You are receiving this mail because:
You are on the CC list for the bug.
You are receiving this mail because:
You are on the CC list for the bug.