[augeas-devel] Fix segfault with bug_on

Francis Giraldeau francis.giraldeau at gmail.com
Thu Jan 12 03:24:39 UTC 2012


> On Thu, 2011-12-29 at 15:50 -0500, Francis Giraldeau wrote:
> > While working on an updated square lens, the old bug_on error came back. This
> > patch is some proposal to get it fixed. Adding this flag is not pretty, but it
> > works.
> 
> I don't recall the details of that problem - what exactly in bug_on is
> causing segfaults ?

Yeah, well, the problem is not bug_on. In lens_get, when lns_get returns
with an error, the function make_exn_lns_error() is called, which
returns either a normaly allocated value, or a static value with
exn_error(). The error comes from this static value which is modified at
various places and produces a segfault.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b93f6a in mem_realloc_n (ptrptr=0x7ffff7ddaa20, size=8,
count=1) at memory.c:101
101	    *(void**)ptrptr = tmp;
(gdb) bt
#0  0x00007ffff7b93f6a in mem_realloc_n (ptrptr=0x7ffff7ddaa20, size=8,
count=1) at memory.c:101
#1  0x00007ffff7b96393 in exn_add_lines (v=0x7ffff7dda9c0, nlines=1) at
syntax.c:416
#2  0x00007ffff7b9657f in exn_printf_line (exn=0x7ffff7dda9c0,
format=0x7ffff7bcdb6b "Tree generated so far:")
    at syntax.c:436
#3  0x00007ffff7ba2486 in lens_get (info=0x604c50, l=0x61e430,
str=0x6046a0) at builtin.c:194
[...]

I think it was done to report error in case of ENOMEM error. The flag
solution is not quite exciting. What about allocating this struct in
advance, say on aug_init? 

Cheer,

Francis




More information about the augeas-devel mailing list