I’m running grass 6.4, revision 33922, on Ubuntu 8.04 and keep getting a bus error when running r.resamp.stats with the -w flag. I couldn’t find any recent mentions of this type of error in trac, and none regarding r.resamp.stats. Any ideas?
> g.region -g
n=50.00083333
s=29.99916667
w=-80.00083333
e=-59.99916667
nsres=0.00166667
ewres=0.00166667
rows=12001
cols=12001
cells=144024001
> r.info -rstg W080N50
min=0
max=1
north=50N
south=30N
east=60W
west=80W
nsres=0:00:03
ewres=0:00:03
datatype=CELL
> r.resamp.stats -w input=W080N50 output=temp
Bus error
Jamie Adams wrote:
I'm running grass 6.4, revision 33922, on Ubuntu 8.04 and keep getting a bus
error when running r.resamp.stats with the -w flag. I couldn't find any
recent mentions of this type of error in trac, and none regarding
r.resamp.stats. Any ideas?
Nope. Can you get a backtrace from gdb? E.g.:
$ gdb r.resamp.stats
> run -w input=W080N50 output=temp
[error message]
> where
--
Glynn Clements <glynn@gclements.plus.com>
Here’s the output:
This GDB was configured as “x86_64-linux”…
(gdb) run -w input=W080N50 output=temp
Starting program: /usr/local/grass-6.4.svn/bin/r.resamp.stats -w input=W080N50 output=temp
0%
Program received signal SIGSEGV, Segmentation fault.
0x00007f8c4f2682a8 in transfer_to_cell_id (fd=, cell=0xa1) at get_row.c:571
571 ((DCELL *) cell)[i] = ((CELL *) G__.work_buf)[i];
(gdb) where
#0 0x00007f8c4f2682a8 in transfer_to_cell_id (fd=, cell=0xa1) at get_row.c:571
#1 0x00007f8c4f26899d in get_map_row_nomask (fd=6, rast=0xa1, row=, data_type=) at get_row.c:633
#2 0x00007f8c4f269279 in get_map_row (fd=6, rast=0xa1, row=6, data_type=2, null_is_zero=0, with_mask=1) at get_row.c:646
#3 0x0000000000402256 in main (argc=, argv=) at main.c:192
On Mon, Oct 20, 2008 at 4:03 PM, Glynn Clements <glynn@gclements.plus.com> wrote:
Jamie Adams wrote:
I’m running grass 6.4, revision 33922, on Ubuntu 8.04 and keep getting a bus
error when running r.resamp.stats with the -w flag. I couldn’t find any
recent mentions of this type of error in trac, and none regarding
r.resamp.stats. Any ideas?
Nope. Can you get a backtrace from gdb? E.g.:
$ gdb r.resamp.stats
run -w input=W080N50 output=temp
[error message]
where
–
Glynn Clements <glynn@gclements.plus.com>
Jamie Adams wrote:
This GDB was configured as "x86_64-linux"...
(gdb) run -w input=W080N50 output=temp
Starting program: /usr/local/grass-6.4.svn/bin/r.resamp.stats -w
input=W080N50 output=temp
0%
Program received signal SIGSEGV, Segmentation fault.
0x00007f8c4f2682a8 in transfer_to_cell_id (fd=<value optimized out>,
cell=0xa1) at get_row.c:571
571 ((DCELL *) cell)[i] = ((CELL *) G__.work_buf)[i];
(gdb) where
#0 0x00007f8c4f2682a8 in transfer_to_cell_id (fd=<value optimized out>,
cell=0xa1) at get_row.c:571
#1 0x00007f8c4f26899d in get_map_row_nomask (fd=6, rast=0xa1, row=<value
optimized out>, data_type=<value optimized out>) at get_row.c:633
#2 0x00007f8c4f269279 in get_map_row (fd=6, rast=0xa1, row=6, data_type=2,
null_is_zero=0, with_mask=1) at get_row.c:646
#3 0x0000000000402256 in main (argc=<value optimized out>, argv=<value
optimized out>) at main.c:192
Okay. AFAICT, there are two likely possibilities. One is that the
array element bufs[i] is getting corrupted, the other is that it is
outside of the bounds of the array.
I suspect the latter; the g.region/r.info output indicates a scale
factor of 24000:12001 ~= 1.9998333. This will result in it allocating
ceil(1.9998333) + 1 = 3 rows, which should be enough regardless of the
position of the input window. However, it's possible that rounding
errors are causing it to go slightly over.
Assuming that's what's happening, the following change should fix it:
--- raster/r.resamp.stats/main.c (revision 33947)
+++ raster/r.resamp.stats/main.c (working copy)
@@ -315,8 +315,8 @@
G_set_window(&src_w);
- row_scale = 1 + ceil(dst_w.ns_res / src_w.ns_res);
- col_scale = 1 + ceil(dst_w.ew_res / src_w.ew_res);
+ row_scale = 2 + ceil(dst_w.ns_res / src_w.ns_res);
+ col_scale = 2 + ceil(dst_w.ew_res / src_w.ew_res);
/* allocate buffers for input rows */
bufs = G_malloc(row_scale * sizeof(DCELL *));
--
Glynn Clements <glynn@gclements.plus.com>
On Tue, Oct 21, 2008 at 1:19 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:
the following change should fix it:
--- raster/r.resamp.stats/main.c (revision 33947)
+++ raster/r.resamp.stats/main.c (working copy)
@@ -315,8 +315,8 @@
G_set_window(&src_w);
- row_scale = 1 + ceil(dst_w.ns_res / src_w.ns_res);
- col_scale = 1 + ceil(dst_w.ew_res / src_w.ew_res);
+ row_scale = 2 + ceil(dst_w.ns_res / src_w.ns_res);
+ col_scale = 2 + ceil(dst_w.ew_res / src_w.ew_res);
/* allocate buffers for input rows */
bufs = G_malloc(row_scale * sizeof(DCELL *));
Backported to 6.4.svn.
Markus
Great. The command is proceeding normally now.
Thanks!
On Tue, Oct 21, 2008 at 11:34 AM, Markus Neteler <neteler@osgeo.org> wrote:
On Tue, Oct 21, 2008 at 1:19 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:
the following change should fix it:
— raster/r.resamp.stats/main.c (revision 33947)
+++ raster/r.resamp.stats/main.c (working copy)
@@ -315,8 +315,8 @@
G_set_window(&src_w);
- row_scale = 1 + ceil(dst_w.ns_res / src_w.ns_res);
- col_scale = 1 + ceil(dst_w.ew_res / src_w.ew_res);
- row_scale = 2 + ceil(dst_w.ns_res / src_w.ns_res);
- col_scale = 2 + ceil(dst_w.ew_res / src_w.ew_res);
/* allocate buffers for input rows */
bufs = G_malloc(row_scale * sizeof(DCELL *));
Backported to 6.4.svn.
Markus