From 9c5cee130f71b2bb6197043c234a62ea258d3149 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 13 Mar 2012 19:40:56 +0000 Subject: [PATCH] Pull in a fix (still under GPLv2) for a double free in gdb, leading to an assert, which can occur if you repeatedly dlopen() and dlclose() a .so file in a tight loop. This was reported on freebsd-current@ by Alexandre Martins, with a sample to reproduce the behaviour. Obtained from: http://sourceware.org/git/?p=gdb.git;a=commit;h=a6f2cbb341520f8e100f4b8305979dd6207a79e8 --- contrib/gdb/gdb/target.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/gdb/gdb/target.c b/contrib/gdb/gdb/target.c index ff47ac13bf7..1f703dd806f 100644 --- a/contrib/gdb/gdb/target.c +++ b/contrib/gdb/gdb/target.c @@ -1425,6 +1425,13 @@ target_resize_to_sections (struct target_ops *target, int num_added) (*t)->to_sections_end = target->to_sections_end; } } + /* There is a flattened view of the target stack in current_target, + so its to_sections pointer might also need updating. */ + if (current_target.to_sections == old_value) + { + current_target.to_sections = target->to_sections; + current_target.to_sections_end = target->to_sections_end; + } } return old_count;