Segmentation Fault in xaccFreeSplit

Derek Atkins warlord at MIT.EDU
Fri Jan 21 11:07:27 EST 2005

I see nothing wrong with this code.  It should be perfectly legal to
set an invalid pointer like this.  Unless you are specifically doing
bounds-checking on pointer-sets I can't see how setting a pointer
would cause a SEGV.  You're not ACCESSING the memory then, you're only
setting the pointer.  It should be no more special than setting the
pointer to NULL or to some other arbitrary value.

And yes, this code has been there a long time, in order to detect a
double-free.  You could probably change the code to have:

  static char deleted_string = "***this object deleted***";

And then use 'deleted_string' instead of "(char *) 1"..


"Matthew Vanecek" <mevanecek at> writes:

> hey,
> I don't know if this is just my machine, or what, but I've started getting
> a segmentation fault in Gnucash, gnucash-gnome2-dev branch. I'm running
> Fedora Core 3, updated via up2date somewhat regularly.  The crash occurs
> when loading an existing file, or when exiting after creating a new file
> and adding a split.  E.g., start gnucash, create empty file, add account
> with opening balance (Opening Balance account auto-creates).  Quit, and
> select yesyouwanttosave.  Application crashes.  It also is crashing on
> opening an existing known good file.
> Now, I don't know if this is a Fedora problem or a GC problem (or maybe
> even a bad bit in memory), but I do know the bit of code.  The code that
> is causing the problem is in Transaction.c in the xaccFreeSplit()
> function:
>         split->memo        = (char *) 1;
> I think this has been that way a long long time, but I thought I'd poll
> for opinions anyhow.  I put together a small test program (source
> attached) that does the samae type of assignment, and sure enough it
> crashes.  Anyhow, I'll eventually get around to rebooting, but in the
> meantime, is this supposed to (continue to be) a valid assignment?  Much
> appears to be changing with newer versions of glibc, etc., WRT standards
> enforcement, etc.
> Thanks,

       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL:    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available

More information about the gnucash-devel mailing list