Libraries and breakpoints should be cloned from original's leader
This pops up when a thread calls vfork. In that case there are no
libraries assigned to the process itself, but newly-vfork'd process is
itself a leader, and therefore needs its own libraries and breakpoints.
diff --git a/proc.c b/proc.c
index bf7f3ad..3134ce9 100644
--- a/proc.c
+++ b/proc.c
@@ -348,7 +348,7 @@
* breakpoints. */
struct library *lib;
struct library **nlibp = &retp->libraries;
- for (lib = proc->libraries; lib != NULL; lib = lib->next) {
+ for (lib = proc->leader->libraries; lib != NULL; lib = lib->next) {
*nlibp = malloc(sizeof(**nlibp));
if (*nlibp == NULL
|| library_clone(*nlibp, lib) < 0) {
@@ -375,7 +375,7 @@
.new_proc = retp,
.error = 0,
};
- dict_apply_to_all(proc->breakpoints, &clone_single_bp, &data);
+ dict_apply_to_all(proc->leader->breakpoints, &clone_single_bp, &data);
if (data.error < 0)
goto fail2;