Opened 13 years ago

Closed 11 years ago

#1451 closed defect (fixed)

r.li.mps (mean patch size): SIGPIPE at ipc.c:31

Reported by: hamish Owned by: grass-dev@…
Priority: normal Milestone: 6.4.4
Component: Raster Version: svn-develbranch6
Keywords: r.li.mps, r.li.daemon Cc:
CPU: x86-64 Platform: Linux

Description

Hi,

as reported on the ML, r.li.mps falls over with a SIGPIPE. Running outside of gdb results in a "double free or corruption (fasttop)" fault.

to reproduce: (North Carolina dataset)

g.region rast=landcover_1m
r.mapcalc "forest.test = if(landcover_1m == 2, 1, null())"

mkdir -p ~/.r.li/history/
cat << EOF > ~/.r.li/history/movwindow7
SAMPLINGFRAME 0|0|1|1
SAMPLEAREA -1|-1|0.0147679324895|0.0133079847909
MOVINGWINDOW
EOF

r.li.mps map=forest.test conf=movwindow7 out=mps.test
...
Program received signal SIGPIPE, Broken pipe.

gdb session extracts:

(gdb) frame 2
#2  0x00007ffff754edc9 in calculateIndex (file=0x605270 "movwindow7", f=0x4013a7 <meanPatchSize>, parameters=0x0, 
    raster=0x605250 "forest1996.maybe", output=0x605590 "test.out") at daemon.c:198
198		send(child[j].channel, &m);
(gdb) list
193		j = 0;
194	
195	
196		while (j < WORKERS && donePid != child[j].pid)
197		    j++;
198		send(child[j].channel, &m);
199	
200	    }
201	
202	    /*kill childs */



(gdb) frame 1
#1  0x00007ffff7551365 in send (pipe=5, m=0x7fffffffaa80) at ipc.c:31
31	    check = write(pipe, m, sizeof(msg));
(gdb) list
26	int send(int pipe, msg * m)
27	{
28	    int check;
29	
30	    /* write on pipe */
31	    check = write(pipe, m, sizeof(msg));
32	    if (check > 0)
33		return 1;
34	    else
35		return 0;

Hamish

Change History (5)

comment:1 by hamish, 13 years ago

ps- see #1323 for some automatically detected problems by Cppcheck

 ./raster/r.li/r.li.mps/mps.c:159 [error] - Resource leak: mask_fd
 ./raster/r.li/r.li.mps/mps.c:530 [error] - Resource leak: mask_fd
 ./raster/r.li/r.li.mps/mps.c:900 [error] - Resource leak: mask_fd 

Hamish

comment:2 by hamish, 12 years ago

r.li.patchdensity has the same trouble, complains about double-free or corruption.

by setting WORKERS=1 and g.gisenv DEBUG=1, I can see that the main patch_density() runs twice, the first time the G_free(sup) command runs ok, the second time it tries to run that it crashes.

a gdb backtrace shows it crashing in the same place as r.li.mps given above, at send(child[j].channel, &m).

# main r.li man page spearfish example
G65> export WORKERS=1
G65> r.li.patchdensity map=geology conf=testconf16 out=patch.dens --v

D1/1: r.li.daemon pathSetup: [/home/hamish/.r.li/history/testconf16]
D1/1: begin patch_density() index
D1/1: begin patch_density() index
*** glibc detected *** r.li.patchdensity: double free or corruption (fasttop): 0x0000000001aacdd0 ***
======= Backtrace: =========
/lib/libc.so.6(+0x71e16)[0x7f1a78f72e16]
/lib/libc.so.6(cfree+0x6c)[0x7f1a78f77b8c]
/home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_gis.6.5.svn.so(G_free+0x18)[0x7f1a79b247db]
r.li.patchdensity(patch_density+0x75f)[0x401666]
/home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_rli.so(worker+0x6f5)[0x7f1a794ead49]
/home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_rli.so(calculateIndex+0x35f)[0x7f1a794e7aeb]
r.li.patchdensity(main+0xf1)[0x400f05]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7f1a78f1fc8d]
r.li.patchdensity[0x400d59]
======= Memory map: ========
00400000-00402000 r-xp 00000000 09:01 1998212                            /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/bin/r.li.patchdensity
00601000-00602000 rw-p 00001000 09:01 1998212                            /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/bin/r.li.patchdensity
01a96000-01ab7000 rw-p 00000000 00:00 0                                  [heap]
7f1a74000000-7f1a74021000 rw-p 00000000 00:00 0 
7f1a74021000-7f1a78000000 ---p 00000000 00:00 0 
7f1a78ae7000-7f1a78afd000 r-xp 00000000 09:00 1175043                    /lib/libgcc_s.so.1
7f1a78afd000-7f1a78cfc000 ---p 00016000 09:00 1175043                    /lib/libgcc_s.so.1
7f1a78cfc000-7f1a78cfd000 rw-p 00015000 09:00 1175043                    /lib/libgcc_s.so.1
7f1a78cfd000-7f1a78cff000 r-xp 00000000 09:00 1180574                    /lib/libdl-2.11.3.so
7f1a78cff000-7f1a78eff000 ---p 00002000 09:00 1180574                    /lib/libdl-2.11.3.so
7f1a78eff000-7f1a78f00000 r--p 00002000 09:00 1180574                    /lib/libdl-2.11.3.so
7f1a78f00000-7f1a78f01000 rw-p 00003000 09:00 1180574                    /lib/libdl-2.11.3.so
7f1a78f01000-7f1a7905a000 r-xp 00000000 09:00 1179836                    /lib/libc-2.11.3.so
7f1a7905a000-7f1a79259000 ---p 00159000 09:00 1179836                    /lib/libc-2.11.3.so
7f1a79259000-7f1a7925d000 r--p 00158000 09:00 1179836                    /lib/libc-2.11.3.so
7f1a7925d000-7f1a7925e000 rw-p 0015c000 09:00 1179836                    /lib/libc-2.11.3.so
7f1a7925e000-7f1a79263000 rw-p 00000000 00:00 0 
7f1a79263000-7f1a792e3000 r-xp 00000000 09:00 1180575                    /lib/libm-2.11.3.so
7f1a792e3000-7f1a794e3000 ---p 00080000 09:00 1180575                    /lib/libm-2.11.3.so
7f1a794e3000-7f1a794e4000 r--p 00080000 09:00 1180575                    /lib/libm-2.11.3.so
7f1a794e4000-7f1a794e5000 rw-p 00081000 09:00 1180575                    /lib/libm-2.11.3.so
7f1a794e5000-7f1a794ee000 r-xp 00000000 09:01 1988192                    /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_rli.6.5.svn.so
7f1a794ee000-7f1a796ee000 ---p 00009000 09:01 1988192                    /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_rli.6.5.svn.so
7f1a796ee000-7f1a796ef000 rw-p 00009000 09:01 1988192                    /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_rli.6.5.svn.so
7f1a796ef000-7f1a79706000 r-xp 00000000 09:00 1047279                    /usr/lib/libz.so.1.2.3.4
7f1a79706000-7f1a79905000 ---p 00017000 09:00 1047279                    /usr/lib/libz.so.1.2.3.4
7f1a79905000-7f1a79906000 rw-p 00016000 09:00 1047279                    /usr/lib/libz.so.1.2.3.4
7f1a79906000-7f1a7990f000 r-xp 00000000 09:01 1988074                    /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_datetime.6.5.svn.so
7f1a7990f000-7f1a79b0f000 ---p 00009000 09:01 1988074                    /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_datetime.6.5.svn.so
7f1a79b0f000-7f1a79b10000 rw-p 00009000 09:01 1988074                    /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_datetime.6.5.svn.so
7f1a79b10000-7f1a79b76000 r-xp 00000000 09:01 1988086                    /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_gis.6.5.svn.so
7f1a79b76000-7f1a79d75000 ---p 00066000 09:01 1988086                    /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_gis.6.5.svn.so
7f1a79d75000-7f1a79d78000 rw-p 00065000 09:01 1988086                    /home/hamish/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_gis.6.5.svn.so
7f1a79d78000-7f1a79d79000 rw-p 00000000 00:00 0 
7f1a79d79000-7f1a79d97000 r-xp 00000000 09:00 1178057                    /lib/ld-2.11.3.so
7f1a79f6f000-7f1a79f73000 rw-p 00000000 00:00 0 
7f1a79f93000-7f1a79f96000 rw-p 00000000 00:00 0 
7f1a79f96000-7f1a79f97000 r--p 0001d000 09:00 1178057                    /lib/ld-2.11.3.so
7f1a79f97000-7f1a79f98000 rw-p 0001e000 09:00 1178057                    /lib/ld-2.11.3.so
7f1a79f98000-7f1a79f99000 rw-p 00000000 00:00 0 
7fff66a9c000-7fff66ab1000 rw-p 00000000 00:00 0                          [stack]
7fff66bff000-7fff66c00000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

Hamish

comment:3 by hamish, 11 years ago

Keywords: r.li.daemon added
Milestone: 6.4.26.4.4

see also comment 27 in #2024, same crash in the same place but set off by r.li.edgedensity. Includes backtrace and valgrind analysis.

in reply to:  3 comment:4 by mmetz, 11 years ago

Replying to hamish:

see also comment 27 in #2024, same crash in the same place but set off by r.li.edgedensity. Includes backtrace and valgrind analysis.

r.li.mps is fixed in trunk r59072. As with the other r.li modules, it works only reliably if the current region is set to the input raster.

comment:5 by neteler, 11 years ago

Resolution: fixed
Status: newclosed

Rewrite from trunk backported in r59304.

Closing here, continued in bug #1214.

Note: See TracTickets for help on using tickets.