Crash on Save (was Re: Open Register crash on Solaris)

Nigel Titley nigel at titley.com
Wed Jun 4 18:13:47 CDT 2003


On Wed, 2003-06-04 at 16:52, Derek Atkins wrote:
> Oh my god!  How has this ever worked?
> 
> The code says:
> 
> static const gchar *book_version_string;
> 
> ...
> 
>     fprintf( out, "<%s version=\"%s\">\n", BOOK_TAG, book_version_string );
> 
> These are the only two references to book_version_string in the
> whole file.  It's clearly never being set to anything.  My god, how
> has this ever worked on any platform?

It works because in most cases a null pointer to a string is converted
to a pointer to a null string or to "(null)". A static should be
initialised to 0.

See the following

#include <stdio.h>

static const char *test;

main ()
{
        printf("This is a test %s\n", test);
}

ntitley at magrat:~/playpit > ./testnull 
This is a test (null)
ntitley at magrat:~/playpit >

On Solaris however

bash-2.03$ ./testnull
Segmentation Fault (core dumped)
bash-2.03$ 


> 
> This is now bug #114401.  I'll go fix this!  Thanks!
> 
> -derek
> 
> Charles Gagnon <charlesg at unixrealm.com> writes:
> 
> > On Tue, Jun 03, 2003 at 09:12:37PM -0400, Derek Atkins wrote:
> > > gdb "attach" the running process and get a backtrace where
> > > it failed?
> > > 
> > > -derek
> > 
> > Sure, here goes. This was created starting gnucash and creating a
> > new file. I added a dummy account and tried saving. I get the "save
> > as..." dialog, give it a name and click okay. At that point it
> > crashes.
> > 
> > Script started on Tue Jun 03 21:22:00 2003
> > $ gdb
> > GNU gdb 5.0
> > Copyright 2000 Free Software Foundation, Inc.
> > GDB is free software, covered by the GNU General Public License, and you are
> > welcome to change it and/or distribute copies of it under certain conditions.
> > Type "show copying" to see the conditions.
> > There is absolutely no warranty for GDB.  Type "show warranty" for details.
> > This GDB was configured as "sparc-sun-solaris2.8".
> > (gdb) attach 19605
> > Attaching to process 19605
> > Reading symbols from /usr/local/bin/guile...done.
> > Reading symbols from /usr/local/lib/libguile.so.12...done.
> > Loaded symbols for /usr/local/lib/libguile.so.12
> > [...]
> > Symbols already loaded for /usr/local/lib/libimlib-png.so
> > Symbols already loaded for /usr/local/lib/libpng.so.2
> > 0xff11d2ec in _poll () from /usr/lib/libc.so.1
> > (gdb) continue
> > Continuing.
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > 0xff0b3200 in strlen () from /usr/lib/libc.so.1
> > (gdb) backtrace
> > #0  0xff0b3200 in strlen () from /usr/lib/libc.so.1
> > #1  0xff106210 in _doprnt () from /usr/lib/libc.so.1
> > #2  0xff107cb8 in fprintf () from /usr/lib/libc.so.1
> > #3  0xfedcc018 in write_book (out=0xff1402ac, book=0xaedb08, gd=0xb34450)
> >     at io-gncxml-v2.c:911
> > #4  0xfedcc5f4 in gnc_book_write_to_xml_filehandle_v2 (book=0xaedb08, 
> >     out=0xff1402ac) at io-gncxml-v2.c:1127
> > #5  0xfedcc9ac in gnc_book_write_to_xml_file_v2 (book=0xaedb08, 
> >     filename=0xff1402ac "", compress=0) at io-gncxml-v2.c:1238
> > #6  0xfedbd450 in gnc_file_be_write_to_file (be=0xbbdac0, make_backup=1)
> >     at gnc-backend-file.c:661
> > #7  0xfedbc94c in file_sync_all (be=0xbbdac0, book=0xaedb08)
> >     at gnc-backend-file.c:179
> > #8  0xfee5e2a0 in gnc_session_save (session=0x265868, 
> >     percentage_func=0xfe48f218 <gnc_mdi_show_progress>) at gnc-session.c:645
> > #9  0xfedf2d64 in gnc_file_save () at gnc-file.c:667
> > #10 0xfedf31a8 in gnc_file_save_as () at gnc-file.c:818
> > #11 0xfedf2eb0 in gnc_file_save () at gnc-file.c:699
> > #12 0xfef021c4 in gnc_main_window_file_save_cb (widget=0xb30a78, data=0x0)
> >     at window-main.c:451
> > #13 0xfe9c2180 in gtk_marshal_NONE__NONE (object=0xb30a78, 
> >     func=0xfef021b8 <gnc_main_window_file_save_cb>, func_data=0x0, 
> >     args=0xffbed228) at gtkmarshal.c:312
> > #14 0xfea05230 in gtk_handlers_run (handlers=0x22e128, signal=0xffbed188, 
> >     object=0xb30a78, params=0xffbed228, after=0) at gtksignal.c:1917
> > #15 0xfea0410c in gtk_signal_real_emit (object=0xb30a78, signal_id=68, 
> >     params=0xffbed228) at gtksignal.c:1477
> > #16 0xfea0116c in gtk_signal_emit (object=0xb30a78, signal_id=68)
> >     at gtksignal.c:552
> > #17 0xfe941cac in gtk_button_clicked (button=0xb30a78) at gtkbutton.c:336
> > #18 0xfe943cc0 in gtk_real_button_released (button=0xb30a78) at gtkbutton.c:861
> > #19 0xfe9c2180 in gtk_marshal_NONE__NONE (object=0xb30a78, 
> >     func=0xfe943bb0 <gtk_real_button_released>, func_data=0x0, args=0xffbed7a8)
> >     at gtkmarshal.c:312
> > #20 0xfea03f40 in gtk_signal_real_emit (object=0xb30a78, signal_id=67, 
> >     params=0xffbed7a8) at gtksignal.c:1440
> > #21 0xfea0116c in gtk_signal_emit (object=0xb30a78, signal_id=67)
> >     at gtksignal.c:552
> > #22 0xfe941b78 in gtk_button_released (button=0xb30a78) at gtkbutton.c:327
> > #23 0xfe943278 in gtk_button_button_release (widget=0xb30a78, event=0x2629e0)
> >     at gtkbutton.c:721
> > #24 0xfe9c1f10 in gtk_marshal_BOOL__POINTER (object=0xb30a78, 
> >     func=0xfe943120 <gtk_button_button_release>, func_data=0x0, 
> >     args=0xffbedd28) at gtkmarshal.c:28
> > #25 0xfea04154 in gtk_signal_real_emit (object=0xb30a78, signal_id=27, 
> >     params=0xffbedd28) at gtksignal.c:1492
> > #26 0xfea0116c in gtk_signal_emit (object=0xb30a78, signal_id=27)
> >     at gtksignal.c:552
> > #27 0xfea4c274 in gtk_widget_event (widget=0xb30a78, event=0x2629e0)
> >     at gtkwidget.c:2864
> > #28 0xfe9c1e84 in gtk_propagate_event (widget=0xb30a78, event=0x2629e0)
> >     at gtkmain.c:1378
> > #29 0xfe9c0bac in gtk_main_do_event (event=0x2629e0) at gtkmain.c:818
> > #30 0xfeada3ac in gdk_event_dispatch (source_data=0x2629e0, 
> >     current_time=0xffbee318, user_data=0x0) at gdkevents.c:2139
> > #31 0xfef45f00 in g_main_dispatch (dispatch_time=0xffbee318) at gmain.c:656
> > #32 0xfef4679c in g_main_iterate (block=-17383580, dispatch=1) at gmain.c:877
> > #33 0xfef469b0 in g_main_run (loop=0x253348) at gmain.c:935
> > #34 0xfe9c02a4 in gtk_main () at gtkmain.c:524
> > #35 0xfeeff020 in gnc_ui_start_event_loop () at top-level.c:538
> > #36 0xfefa1d50 in gw__tmp799_gnc_ui_start_event_loop_wrapper () at gw-gnc.c:276
> > #37 0xff2b268c in scm_ceval (x=0xbde30, env=0xb8970) at eval.c:2732
> > #38 0xff2b02fc in scm_ceval (x=0xbde10, env=0xb8970) at eval.c:2017
> > #39 0xff2b02fc in scm_ceval (x=0xbdc28, env=0xb8970) at eval.c:2017
> > #40 0xff2b0248 in scm_ceval (x=0xabe20, env=0xabe58) at eval.c:1987
> > #41 0xff2b55a0 in scm_i_eval_x (exp=0xff2aff40, env=0xabe58) at eval.c:4062
> > #42 0xff2b5660 in scm_primitive_eval_x (exp=0xabe38) at eval.c:4080
> > #43 0xff2b56fc in inner_eval_x (data=0xabe38) at eval.c:4127
> > #44 0xff2a79b0 in scm_internal_dynamic_wind (
> >     before=0xff2b56b0 <change_environment>, inner=0xff2b56f0 <inner_eval_x>, 
> >     after=0xff2b56d0 <restore_environment>, inner_data=0xabe38, 
> >     guard_data=0xabe40) at dynwind.c:168
> > #45 0xff2b57ac in scm_eval_x (exp=0xabe38, module=0x5e080) at eval.c:4136
> > #46 0xff2f1be8 in scm_shell (argc=6, argv=0xffbeec24) at script.c:676
> > #47 0x10940 in inner_main (closure=0x0, argc=6, argv=0xffbeec24) at guile.c:79
> > #48 0xff2cff0c in invoke_main_func (body_data=0xffbeeb30) at init.c:636
> > #49 0xff2cfec0 in scm_boot_guile_1 (base=0xffbeeb2c, closure=0xffbeeb30)
> >     at init.c:616
> > #50 0xff2cfab8 in scm_boot_guile (argc=6, argv=0xffbeec24, 
> >     main_func=0x10930 <inner_main>, closure=0x0) at init.c:440
> > #51 0x10970 in main (argc=6, argv=0xffbeec24) at guile.c:94
> > (gdb) continue
> > Continuing.
> > 
> > Program exited normally.
> > (gdb) quit
> > $ 
> > $ exit
> > script done on Tue Jun 03 21:25:09 2003
> > 
> > -- 
> > Charles Gagnon                   | My views are my views and they
> > http://unixrealm.com             | do not represent those of anybody
> > charlesg at unixrealm.com        | but me.
> > 
> >    All of you are sick!  All of you should be hospitalized!!
> >         -- Shaul Yahalom of the Israeli parliament, responding
> >            to members who suggest King David was gay
> > _______________________________________________
> > gnucash-devel mailing list
> > gnucash-devel at lists.gnucash.org
> > https://lists.gnucash.org/mailman/listinfo/gnucash-devel
> 
> -- 
>        Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
>        Member, MIT Student Information Processing Board  (SIPB)
>        URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
>        warlord at MIT.EDU                        PGP key available
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at lists.gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
> 





More information about the gnucash-devel mailing list