No subject


Wed Nov 14 13:37:45 EST 2007


 - Variable: CFLAGS
     Debugging and optimization options for the C compiler.  If it is
     not set in the environment when `configure' runs, the default
     value is set when you call `AC_PROG_CC' (or empty if you don't).
     `configure' uses this variable when compiling programs to test for
     C features.


 - Macro: AC_PROG_CC ([COMPILER-SEARCH-LIST])

  [snip]

     If using the GNU C compiler, set shell variable `GCC' to `yes'.
     If output variable `CFLAGS' was not already set, set it to `-g
     -O2' for the GNU C compiler (`-O2' on systems where GCC does not
     accept `-g'), or `-g' for other compilers.

> Manually resolved, now recompiled from scratch.
> 
> (gdb) r -anC input='areecampione125m,modis_vi250m20010712.250m_16_days_EVI' fs=space
> Starting program: /hardmnt/eden0/ssi/software/cvsgrass61/dist.x86_64-unknown-linux-gnu/bin/r.stats -anC input='areecampione125m,modis_vi250m20010712.250m_16_days_EVI' fs=space
> Detaching after fork from child process 6288.
> Detaching after fork from child process 6289.
> WARNING: r.stats: cats for modis_vi250m20010712.250m_16_days_EVI are either
>          missing or have no explicit labels. Using nsteps=255

> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000402b7f in main (argc=4, argv=0x7fbffff498) at main.c:242
> 242         for (i = 0; name = option.cell->answers[i]; i++)
> (gdb) bt full
> #0  0x0000000000402b7f in main (argc=4, argv=0x7fbffff498) at main.c:242

>         i = 2

>         option = {cell = 0x3535323d737065, fs = 0x508730, nv = 0x5087c0, output = 0x508850, nsteps = 0x508900}
> 
> This looks similar (but hopefully more reasonable) to the first
> report.

That option.cell == 0x3535323d737065 looks quite wrong. The fact that
i == 2 suggests that it didn't start out wrong but has been
overwritten, apparently with ASCII:

	$ echo -ne 'eps=255\0' | od -t x8
	0000000 003535323d737065

Hmm.

	char msg[100];

	sprintf(msg, "%s: cats for %s are either missing or have no explicit labels. Using nsteps=%d", G_program_name(),name, nsteps);

Assuming:

	G_program_name() = "r.stats"
	name = "modis_vi250m20010712.250m_16_days_EVI"
	nsteps = 255

gives:

	msg = "r.stats: cats for modis_vi250m20010712.250m_16_days_EVI are either missing or have no explicit labels. Using nsteps=255"

The backtrace says:

        msg = "r.stats: cats for modis_vi250m20010712.250m_16_days_EVI are either missing or have no explicit label"

which is 100 bytes. The remainder ("s. Using nsteps=255" and the
terminating NUL) is beyond the array, and the last 8 bytes
("eps=255\0") are overwriting option.cell.

I suggest getting rid of all of the sprintf() calls and just using
G_fatal_error() (which has a 2000 byte buffer).

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




More information about the grass-dev mailing list