X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com Received-SPF: pass (google.com: domain of k DOT kosciuszkiewicz AT gmail DOT com designates 10.213.26.154 as permitted sender) client-ip=10.213.26.154; Authentication-Results: mr.google.com; spf=pass (google.com: domain of k DOT kosciuszkiewicz AT gmail DOT com designates 10.213.26.154 as permitted sender) smtp.mail=k DOT kosciuszkiewicz AT gmail DOT com; dkim=pass header.i=k DOT kosciuszkiewicz AT gmail DOT com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=h5zJeAwP5ngpC7bBgEY+SBEMDZ+6yCTWV/qfOqFsiC4=; b=aNqe8bGk7o/6BehxKH33UjkkNlAukq7oWAXnvMQFhy2LKwozSLq1ornS8ItXPUMSWb 2LF49q/zZSQ4Tk653WMfPehozO1ELtDLk0m20EZD3CLJ5DZj2kMO98xQmUwNIqfVPEii fpBmfp3xvAXqlGtX1XRUl+UPrwq+u+KJ/aQCM= Date: Mon, 30 Jan 2012 23:42:45 +0100 From: Krzysztof =?utf-8?Q?Ko=C5=9Bciuszkiewicz?= To: geda-user AT delorie DOT com Subject: Re: [geda-user] gschem segfault Message-ID: <20120130224245.GD8575@localdomain> References: <20120129215810 DOT GA21496 AT localhost DOT localdomain> <20120130000030 DOT GC8575 AT localdomain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="M9NhX3UHpAaciwkO" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20120130000030.GC8575@localdomain> User-Agent: Mutt/1.5.18 (2008-05-17) Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Dnia 2012-01-30 o godzinie 01:00 Krzysztof Kościuszkiewicz napisał(a): > Dnia 2012-01-30 o godzinie 01:58 Vladimir Zhbanov napisał(a): > > > I've found gschem bug in git head. gschem segfaults when I close two > > windows with unsaved pages. > > ... > > > After bisecting I've got the following result: > > > > 8342bddce4487edf4a7214d5d6ab83cb73a066d4 is the first bad commit > > Thanks for the report and for finding the bad commit! Long story > short - the commit adds a "new toplevel" hook with hardcoded w_current > pointing to the first gschem window. > > When next window is created, hooks will still run with "old" w_current > - it's a miracle this blows up only when gschem exits and frees the > original w_current - but hooks for the subsequent windows still try to > access it. A patch for review is attached. Ideas for better name/place for gschem_toplevel_alloc_libgeda_toplevel() are welcome... Best regards, Krzysztof --M9NhX3UHpAaciwkO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-gschem-fix-segfault-when-multiple-windows-are-closed.patch" From 13d329ee5fb184c5dd73b0133722e9c5e32e0148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ko=C5=9Bciuszkiewicz?= Date: Mon, 30 Jan 2012 23:32:34 +0100 Subject: [PATCH] gschem: fix segfault when multiple windows are closed Reported by Vladimir Zhbanov , introduced in commit 8342bddce4487edf4a7214d5d6ab83cb73a066d4. Add new function gschem_toplevel_alloc_libgeda_toplevel which allocates the TOPLEVEL and appends new hooks that force pin cues redraw when net connectivity changes. Previously each new TOPLEVEL had invalidation hooks attached which had the GSCHEM_TOPLEVEL hardcoded, pointing at the very first window created when gschem was launched. --- gschem/include/prototype.h | 1 + gschem/src/gschem.c | 17 +---------------- gschem/src/gschem_toplevel.c | 10 ++++++++++ gschem/src/i_callbacks.c | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h index 42be9e0..640c497 100644 --- a/gschem/include/prototype.h +++ b/gschem/include/prototype.h @@ -2,6 +2,7 @@ /* gschem_toplevel.c */ GSCHEM_TOPLEVEL *gschem_toplevel_new(); +void gschem_toplevel_alloc_libgeda_toplevel(GSCHEM_TOPLEVEL *w_current); /* a_pan.c */ void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy, diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c index 1bb96c1..5f9b711 100644 --- a/gschem/src/gschem.c +++ b/gschem/src/gschem.c @@ -120,17 +120,6 @@ void gschem_quit(void) gtk_main_quit(); } -static void add_libgeda_toplevel_hooks (TOPLEVEL *toplevel, - GSCHEM_TOPLEVEL *w_current) -{ - o_attrib_append_attribs_changed_hook (toplevel, - (AttribsChangedFunc) o_invalidate, - w_current); - s_conn_append_conns_changed_hook (toplevel, - (ConnsChangedFunc) o_invalidate, - w_current); -} - /*! \brief Main Scheme(GUILE) program function. * \par Function Description * This function is the main program called from scm_boot_guile. @@ -233,11 +222,7 @@ void main_prog(void *closure, int argc, char *argv[]) /* Allocate w_current */ w_current = gschem_toplevel_new (); - /* Connect hooks that run for each s_toplevel_new() first */ - s_toplevel_append_new_hook ((NewToplevelFunc) add_libgeda_toplevel_hooks, - w_current); - - w_current->toplevel = s_toplevel_new (); + gschem_toplevel_alloc_libgeda_toplevel (w_current); w_current->toplevel->load_newer_backup_func = x_fileselect_load_backup; w_current->toplevel->load_newer_backup_data = w_current; diff --git a/gschem/src/gschem_toplevel.c b/gschem/src/gschem_toplevel.c index db97e29..983bbe4 100644 --- a/gschem/src/gschem_toplevel.c +++ b/gschem/src/gschem_toplevel.c @@ -208,3 +208,13 @@ GSCHEM_TOPLEVEL *gschem_toplevel_new () return w_current; } +void gschem_toplevel_alloc_libgeda_toplevel (GSCHEM_TOPLEVEL *w_current) +{ + w_current->toplevel = s_toplevel_new (); + o_attrib_append_attribs_changed_hook (w_current->toplevel, + (AttribsChangedFunc) o_invalidate, + w_current); + s_conn_append_conns_changed_hook (w_current->toplevel, + (ConnsChangedFunc) o_invalidate, + w_current); +} diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c index cc3a571..cebda89 100644 --- a/gschem/src/i_callbacks.c +++ b/gschem/src/i_callbacks.c @@ -104,7 +104,7 @@ DEFINE_I_CALLBACK(file_new_window) PAGE *page; w_current = gschem_toplevel_new (); - w_current->toplevel = s_toplevel_new (); + gschem_toplevel_alloc_libgeda_toplevel (w_current); w_current->toplevel->load_newer_backup_func = x_fileselect_load_backup; w_current->toplevel->load_newer_backup_data = w_current; -- 1.7.4.1 --M9NhX3UHpAaciwkO--