[Xastir] dbfawk bug?

Tom Russo russo at bogodyn.org
Tue Jan 25 15:50:34 EST 2005


On Tue, Jan 25, 2005 at 01:32:01PM -0700, we recorded a bogon-computron collision of the <russo at bogodyn.org> flavor, containing:
> On Tue, Jan 25, 2005 at 12:22:44PM -0800, we recorded a bogon-computron collision of the <archer at eskimo.com> flavor, containing:
> > On Tue, 25 Jan 2005, Jason Winningham wrote:
> > 
> > > I was working on some shapefiles while editing dbfawks with emacs. 
> > > [...], it keeps a checkpoint (called an
> > > auto-save) in #filename#, so while editing
> > > dlg-24k-shapefile-LE01.dbfawk it creates
> > > #dlg-24k-shapefile-LE01.dbfawk#
> [...]
> > > So, I'm editing a dbfawk and have one of these #filename# files, and
> > > "add new maps".  xastir dies with
> > >
> > > .#dlg-24k-shapefile-LE01.dbfawk: failed to parse
> > >
> > > Tried to start xastir again and it died with the same error.
> > >
> > > I got rid of the checkpoint file and all is well, but this isn't
> > > terribly friendly behavior.
> > 
> > That's kind of funny!  Please add it to the bug-list.
> 
> Oh, yeah, a riot.
> 
> Looking through the code, that's not supposed to be a fatal error.  Must
> be failing to clean up after the parse failure and allowing something to 
> dereference a null pointer or some such.  Is the specific "death" a segfault 
> or other failure indicative of what the problem is?  

I think I see what the problem is.  When building the datastructure that 
contains dbfawk signatures, dbfawk_load_sigs mallocs space for a new list entry 
and links it into the linked list, *then* tries to parse the dbfawk file 
and populate the structure.  As far as I can tell, if the 
"awk_compile_program" call fails it doesn't unlink and free the useless,
incomplete list element.  The segfault is probably happening later on when 
walking through the list of dbfawk signatures to find a match.  Worse, it's
probably happening because your broken, unparsable dbfawk file probably has
the correct signature to match with a shapefile you want to display, and is
appearing earlier in the list than the good one (because of the ".#" prefix).
So its entry gets pulled out and draw_shapefile_map tries to run its
(null) dbfawk program.  Bickety bam, you get a segfault.

I don't have a quick fix, but it seems the correct fix is to change
dbfawk_load_sigs so it mallocs and populates the list entry completely
before it links to the list, and only link it in if it's possible to
complete the operation.  If it's not good it should be freed instead, and 
nobody's the wiser.  Definitely add it to the bug list.  I will try to fix
it as soon as I can.

-- 
Tom Russo    KM5VY     SAR502  DM64ux         http://www.swcp.com/~russo/
Tijeras, NM  QRPL#1592 K2#398  SOC#236 AHTB#1 
 "When life gives you lemons, find someone with a paper cut."



More information about the Xastir mailing list