[GRASS5] i.points and i.rectify: glibc detected/corruption

Hi,

in both i.points and i.rectify we get ugly
*** glibc detected *** double free or corruption

While i.points continues to work, i.rectify does not with more
than 3 input maps (the first maps are processed, with subsequent
maps in the group it crashes when closing the original map, while
calling G_close_cell() ):

(gdb) break rectify.c:42
Breakpoint 2 at 0x804c33d: file rectify.c, line 42.
(gdb) run
`/nfsmnt/thuille0/ssi/software/cvsgrass61/dist.i686-pc-linux-gnu/bin/i.rectify' has changed; re-reading symbols.
Breakpoint 1 at 0x804c66a: file rectify.c, line 107.
Breakpoint 2 at 0x804c37e: file rectify.c, line 42.
Starting program: /nfsmnt/thuille0/ssi/software/cvsgrass61/dist.i686-pc-linux-gnu/bin/i.rectify group=landsat_nov2002 extension=rectify order=2 -a
Region N=6340321.018350 S=6329231.553074 E=4379720.870537 W=4369526.512250
Resolution EW=15.080412 NS=15.067208
Using Region: N=6340321.018350 S=6329231.553074, E=4379720.870537 W=4369526.512250
Rectified input file 20021104_HPN_riocuarto will be saved as 20021104_HPN_riocuartorectify

Breakpoint 2, rectify (name=0x8b6de40 "20021104_HPN_riocuarto", mapset=0x8b6df40 "gomez", result=0x8b6dcc8 "20021104_HPN_riocuartorectify", order=2) at rectify.c:42
(gdb) next
(gdb) cont
Continuing.

Breakpoint 1, rectify (name=0x8b6de40 "20021104_HPN_riocuarto", mapset=0x8b6df40 "gomez", result=0x8b6dcc8 "20021104_HPN_riocuartorectify", order=2) at rectify.c:107
(gdb) cont
Continuing.
***********************************************
Rectify [20021104_HPN_riocuarto@gomez] (LOCATION riocuarto_landsat)
into [20021104_HPN_riocuartorectify in neteler] (LOCATION riocuarto_vect)
complete
-----------------------------------------------
736 rows, 676 cols (497536 cells) completed in 1:01
489379.7 cells per minute

Rectified input file 20021104_HRF_riocuarto.1 will be saved as 20021104_HRF_riocuarto.1rectify

Breakpoint 2, rectify (name=0x8b6e040 "20021104_HRF_riocuarto.1", mapset=0x8b6e140 "gomez", result=0x8b6f358 "20021104_HRF_riocuarto.1rectify", order=2) at rectify.c:42
(gdb) next
(gdb) cont
Continuing.

Breakpoint 1, rectify (name=0x8b6e040 "20021104_HRF_riocuarto.1", mapset=0x8b6e140 "gomez", result=0x8b6f358 "20021104_HRF_riocuarto.1rectify", order=2) at rectify.c:107
(gdb) cont
Continuing.
***********************************************
Rectify [20021104_HRF_riocuarto.1@gomez] (LOCATION riocuarto_landsat)
into [20021104_HRF_riocuarto.1rectify in neteler] (LOCATION riocuarto_vect)
complete
-----------------------------------------------
736 rows, 676 cols (497536 cells) completed in 0:38
785583.2 cells per minute

Rectified input file 20021104_HRF_riocuarto.2 will be saved as 20021104_HRF_riocuarto.2rectify

Breakpoint 2, rectify (name=0x8b6e240 "20021104_HRF_riocuarto.2", mapset=0x8b6e340 "gomez", result=0x8b6f440 "20021104_HRF_riocuarto.2rectify", order=2) at rectify.c:42
(gdb) cont
Continuing.

Breakpoint 1, rectify (name=0x8b6e240 "20021104_HRF_riocuarto.2", mapset=0x8b6e340 "gomez", result=0x8b6f440 "20021104_HRF_riocuarto.2rectify", order=2) at rectify.c:107
(gdb) cont
Continuing.
***********************************************
Rectify [20021104_HRF_riocuarto.2@gomez] (LOCATION riocuarto_landsat)
into [20021104_HRF_riocuarto.2rectify in neteler] (LOCATION riocuarto_vect)
complete
-----------------------------------------------
736 rows, 676 cols (497536 cells) completed in 0:22
1356916.4 cells per minute

Rectified input file 20021104_HRF_riocuarto.3 will be saved as 20021104_HRF_riocuarto.3rectify

Breakpoint 2, rectify (name=0x8b6e440 "20021104_HRF_riocuarto.3", mapset=0x8b6e540 "gomez", result=0x8b6f468 "20021104_HRF_riocuarto.3rectify", order=2) at rectify.c:42
(gdb) cont
Continuing.

Breakpoint 1, rectify (name=0x8b6e440 "20021104_HRF_riocuarto.3", mapset=0x8b6e540 "gomez", result=0x8b6f468 "20021104_HRF_riocuarto.3rectify", order=2) at rectify.c:107
(gdb) cont
Continuing.
*** glibc detected *** double free or corruption (!prev): 0x08b85f70 ***

Program received signal SIGABRT, Aborted.
0x003207a2 in ?? ()
(gdb)

In the fcb section something happens which is called by G_close_cell().
Strangly, it works for the first maps.

How to debug this?

Markus

On 28/11/05 17:50, Markus Neteler wrote:

Hi,

in both i.points and i.rectify we get ugly
*** glibc detected *** double free or corruption

Ah yes. that is is nasty. it means that we are calling free on a pointer
allready freed, or free on something that does npt point anywhere. I.e
random.

I ran into this today at work, and there it was casied by having a
string in 2 structures, but the string pointer was copied to the second
struct, instead of, say, strdup. The program would crash whenever both
structures were freed.

In the fcb section something happens which is called by G_close_cell().
Strangly, it works for the first maps.

How to debug this?

Enable coredumps, and then run i.rectify again (make sure you have
compiuled with -g (which you seem to have done) and then dump a the
callstack in "gdb i.rectify core" with the "bt" command.

This should give you the callstack, and you can thene see what is being
freed. Then you can try to find in the code or with a debugger if a
pointer to this meory location is copied or something.

Also if you are running on linux (intel cpu) you can also try if
valgrind is of any help.

--Wolf

--

<:3 )---- Wolf Bergenheim ----( 8:>

Markus Neteler wrote:

in both i.points and i.rectify we get ugly
*** glibc detected *** double free or corruption

How to debug this?

One thing which may help is to link against -lmcheck then call
mprobe() on malloc'd pointers as often as possible.

If you call mprobe() often enough, the actual bug shouldn't be too far
behind the point where the error is reported.

--
Glynn Clements <glynn@gclements.plus.com>