Fix serious race in attach to many-threaded process
- the gist is that tasks continue running while we attach, so more tasks
come into existence, or the ones that we didn't attach to yet disappear,
etc.
- besides, we really can't enable breakpoints before we are done attaching,
otherwise the still-running tasks risk running into them and dying of
SIGTRAP.
diff --git a/breakpoints.c b/breakpoints.c
index 4e74923..1eff8b0 100644
--- a/breakpoints.c
+++ b/breakpoints.c
@@ -183,7 +183,7 @@
free(sbp);
}
-void
+int
breakpoints_init(Process *proc, int enable)
{
struct library_symbol *sym;
@@ -215,6 +215,11 @@
if (options.libcalls && proc->filename) {
proc->list_of_symbols = read_elf(proc);
+ if (proc->list_of_symbols == NULL) {
+ /* XXX leak breakpoints */
+ return -1;
+ }
+
if (opt_e) {
struct library_symbol **tmp1 = &proc->list_of_symbols;
while (*tmp1) {
@@ -242,6 +247,7 @@
proc->callstack_depth = 0;
proc->breakpoints_enabled = -1;
+ return 0;
}
void