Opened 21 years ago
Closed 17 years ago
#359 closed defect (worksforme)
get segmentation fault with SDTS dem data
Reported by: | Owned by: | warmerdam | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | default | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | Markus Neteler |
Description (last modified by )
GRASS:/ext2e/data/GRASSDATA/princeton_dem > v.in.sdts catd=4429CATD.DDF output=test Processing CATD module Processing STAT module Processing IDEN module Processing XREF module Processing IREF module Error: Unable to process composite modules. Continuing. Processing manifold: DEM1 Processing LE module: 4429LDEF.DDF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Illegal Tag = LDEF Segmentation fault GRASS:/ext2e/data/GRASSDATA/princeton_dem > r.in.gdal input=4429CATD.DDF output=test Segmentation fault GRASS:/ext2e/data/GRASSDATA/princeton_dem > I had initially assumed that this data was raster data being new to grass. So I ran it with r.in.gdal and got a segmentation fault. I did some tracing and it crashes with a segmentation fault. I am using the latest redhat 7.3. It executes G_no_gisinit() ; then gisinit() so far we have (gdb) bt #0 gisinit () at gisinit.c:82 #1 0x08049cfb in G_no_gisinit () at gisinit.c:58 #2 0x080494ca in main (argc=3, argv=0xbfffe114) at main.c:88 #3 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 Then back to: G_no_gisinit () at gisinit.c:60 60 return 0; (gdb) bt #0 G_no_gisinit () at gisinit.c:60 #1 0x080494ca in main (argc=3, argv=0xbfffe114) at main.c:88 #2 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) and then back to: main (argc=3, argv=0xbfffe114) at main.c:91 91 argv[0] = cmdName; then to: 254 if ((value = G__getenv(name))) (gdb) bt #0 G_getenv (name=0x8057b70 "GISBASE") at env.c:254 #1 0x08049c74 in G_gisbase () at gisbase.c:15 #2 0x0804947d in pgm_name (pgm=0xbfffdc90 "", dir=0x8057a5d "cmd", name=0xbffff8fc "r.in.gdal") at main.c:59 #3 0x0804950b in main (argc=3, argv=0xbfffe114) at main.c:123 #4 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 Then this is where it soon crashes: (gdb) step G__getenv (name=0x8057b70 "GISBASE") at env.c:268 268 if (strcmp (name, "GISBASE") == 0) (gdb) 269 return getenv (name); (gdb) Program received signal SIGTRAP, Trace/breakpoint trap. Cannot remove breakpoints because program is no longer writable. It might be running in another process. Further execution is probably impossible. 0x40000b50 in _start () from /lib/ld-linux.so.2 (gdb) bt #0 0x40000b50 in _start () from /lib/ld-linux.so.2 This crashed in a different place than it did when I ran it before. It crashed when it was execve a program. The data I am using is the SDTS data for the princeton quad in the state of Alabama.
Change History (20)
comment:2 by , 21 years ago
I got this data from one of the USGS distribution private sites. It seems that they have changed their web sites since I was last there.
comment:3 by , 21 years ago
Can you provide the file to me somehow? If you want, you can anonymous ftp it it to ftp://gdal.velocet.ca/pub/incoming
comment:5 by , 21 years ago
OK, I have done a quick test on the SDTS file, and it doesn't not cause me any problems. Now that I review your tracebacks (as I should have in the first place), it does not appear that the program has even gotten to any GDAL library related actions. Looking at your backtrace, I really don't understand what is going wrong. I don't have a modern GRASS environment built here, so there really isn't too much I can do about this. By the way, what source are you using for GRASS and your libgdal.1.1.so? Is it possible that you built the libgdal.1.1.so yourself, and that you configured in support for GRASS when building GDAL? This might well mess things up since up as two copies of stuff like the G_getenv() code would be configured in.
comment:6 by , 21 years ago
I built this library gdal-1.1.8.tar.gz I am not sure which one is installed this one or the one in grass. The version of grass I built is grass.5.0.2. This is in my config log configure:5605: checking if we should build directly against GDAL configure:5670: checking whether to use TIFF I am going to recompile from scratch (make distclean)
comment:7 by , 21 years ago
Wel I am confused now has to how to build this. I rebuilt grass and it did not create a libgdal. I then built gdal installed it and I get a segmentation fault again. Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x08049d87 in gisinit () at gisinit.c:89 #2 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 Before I ran ldconfig grass did not crash , it only said that it could not find the gdal library. Do I need to set this option and not install gdal? --with-gdal[=path] build directly against GDAL (path is gdal-config) Perhaps the interfaces are different for grass and the gdal library?
comment:8 by , 21 years ago
I tried the precompiled binaries for gdal. It was interesting that it came not with one but two libraries. One for gdal and one for stdc++. The library for stdc++ crashed my system and kde would not start. I put the old one back in. I then used the binary for gdal and that crashed also. Perhaps some changes were made to the standard libraries which make gdal unable to work properly.
comment:9 by , 21 years ago
I just built the latest grass from CVS to see if the same thing happens. GRASS:/ext2e/data/GRASSDATA/princeton_dem > r.in.gdal input=4429CATD.DDF output=test Segmentation fault GRASS:/ext2e/data/GRASSDATA/princeton_dem > Perhaps a there is alcue in the following output ################################################################# /ext2e/grass_exp/grass/src/raster/r.in.gdal mkdir OBJ.i686-pc-linux-gnu make -f OBJ.i686-pc-linux-gnu/make.rules make[1]: Entering directory `/ext2e/grass_exp/grass/src/raster/r.in.gdal' gcc -I/ext2e/grass_exp/grass/src/include -g -Wall -c main.c -o OBJ.i686-pc-linux-gnu/main.o main.c: In function `main': main.c:141: warning: suggest parentheses around assignment used as truth value main.c:232: warning: implicit declaration of function `G_make_location' main.c: At top level: /ext2e/grass_exp/grass/src/include/gis.h:35: warning: `GRASS_copyright' defined but not used gcc -I/ext2e/grass_exp/grass/src/include -g -Wall -c gbgetsymbol.c -o OBJ.i686-pc-linux-gnu/gbgetsymbol.o gcc -I/ext2e/grass_exp/grass/src/include -g -Wall -c gdalbridge.c -o OBJ.i686-pc-linux-gnu/gdalbridge.o gcc -I/ext2e/grass_exp/grass/src/include -g -Wall -c make_loc.c -o OBJ.i686-pc-linux-gnu/make_loc.o /ext2e/grass_exp/grass/src/include/gis.h:35: warning: `GRASS_copyright' defined but not used gcc -L/ext2e/grass_exp/grass/src/libes/LIB.i686-pc-linux-gnu -o /ext2e/grass_exp/grass/dist.i686-pc-linux-gnu/etc/bin/cmd/r.in.gdal OBJ.i686-pc-linux-gnu/main. o OBJ.i686-pc-linux-gnu/gbgetsymbol.o OBJ.i686-pc-linux-gnu/gdalbridge.o OBJ.i686-pc-linux-gnu/make_loc.o \ -ldl -lgproj -lgis -lI -lm -lz make[1]: Leaving directory `/ext2e/grass_exp/grass/src/raster/r.in.gdal'
comment:11 by , 21 years ago
This does execute in r.in.gdal. I have used gdb to trace the flow. G_gisinit seems to be executed more than once although there is only one line in the source. Later the next sequential instruction in the source is not executed but one several lines farther. Here is a copy of my debug session: I r(gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /usr/local/grass5/bin/r.in.gdal input=4429CATD.DDF output=test Breakpoint 1, main (argc=3, argv=0xbffff684) at main.c:75 75 struct Flag *flag_o, *flag_e; (gdb) step 76 (gdb) 78 /* Initialize. */ (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 5, main (argc=3, argv=0xbffff684) at main.c:80 80 G_gisinit (argv[0]); (gdb) Breakpoint 6, main (argc=3, argv=0xbffff684) at main.c:82 82 module = G_define_module(); (gdb) bt #0 main (argc=3, argv=0xbffff684) at main.c:82 #1 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) info source Current source file is main.c Compilation directory is /ext2e/grass5.0.2/src/front.end/ Located in /ext2e/grass5.0.2/src/raster/r.in.gdal/main.c Contains 1045 lines. Source language is c. Compiled with stabs debugging format. (gdb) step Breakpoint 2, main (argc=3, argv=0xbffff684) at main.c:88 88 /* -------------------------------------------------------------------- */ (gdb) G_no_gisinit () at gisinit.c:58 58 gisinit(); (gdb) gisinit () at gisinit.c:76 76 G__.window_set = 0 ; (gdb) bt #0 gisinit () at gisinit.c:76 #1 0x0804a103 in G_no_gisinit () at gisinit.c:58 #2 0x08049550 in main (argc=3, argv=0xbffff684) at main.c:88 #3 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) step 79 G__.want_histogram = 0; (gdb) 82 for (i = 0; i < MAXFILES; i++) (gdb) next 84 G__.fileinfo[i].open_mode = -1; (gdb) 82 for (i = 0; i < MAXFILES; i++) (gdb) 84 G__.fileinfo[i].open_mode = -1; (gdb) l 79 G__.want_histogram = 0; 80 81 /* Mark all cell files as closed */ 82 for (i = 0; i < MAXFILES; i++) 83 { 84 G__.fileinfo[i].open_mode = -1; 85 } 86 87 /* Set compressed data buffer size to zero */ 88 G__.compressed_buf_size = 0; (gdb) break 88 Note: breakpoint 9 also set at pc 0x804a1b4. Breakpoint 10 at 0x804a1b4: file gisinit.c, line 88. (gdb) cont Continuing. Breakpoint 9, gisinit () at gisinit.c:88 88 G__.compressed_buf_size = 0; (gdb) step 89 G__.work_buf_size = 0; (gdb) 90 G__.null_buf_size = 0; (gdb) 91 G__.mask_buf_size = 0; (gdb) 92 G__.temp_buf_size = 0; (gdb) 94 G__reallocate_mask_buf(); (gdb) G__reallocate_mask_buf () at opencell.c:799 799 n = (WINDOW.cols + 1) * sizeof(CELL); (gdb) bt #0 G__reallocate_mask_buf () at opencell.c:799 #1 0x0804a1eb in gisinit () at gisinit.c:94 #2 0x0804a103 in G_no_gisinit () at gisinit.c:58 #3 0x08049550 in main (argc=3, argv=0xbffff684) at main.c:88 #4 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) info source Current source file is opencell.c Compilation directory is /ext2e/grass5.0.2/src/libes/gis/ Located in /ext2e/grass5.0.2/src/libes/gis/opencell.c Contains 1006 lines. Source language is c. Compiled with stabs debugging format. (gdb) step 800 if (n > G__.mask_buf_size) (gdb) 802 if (G__.mask_buf_size <= 0) (gdb) 803 G__.mask_buf = (CELL *) G_malloc (n); (gdb) print n $14 = 4 (gdb) next 806 G__.mask_buf_size = n; (gdb) 809 return 0; (gdb) bt #0 G__reallocate_mask_buf () at opencell.c:809 #1 0x0804a1eb in gisinit () at gisinit.c:94 #2 0x0804a103 in G_no_gisinit () at gisinit.c:58 #3 0x08049550 in main (argc=3, argv=0xbffff684) at main.c:88 #4 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) #0 G__reallocate_mask_buf () at opencell.c:809 #1 0x0804a1eb in gisinit () at gisinit.c:94 #2 0x0804a103 in G_no_gisinit () at gisinit.c:58 #3 0x08049550 in main (argc=3, argv=0xbffff684) at main.c:88 #4 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) next 810 } (gdb) gisinit () at gisinit.c:97 97 G__.fp_type = FCELL_TYPE; (gdb) 98 G__.fp_nbytes = XDR_FLOAT_NBYTES; (gdb) 101 G__.auto_mask = -1 ; (gdb) 104 G__init_null_patterns(); (gdb) step G__init_null_patterns () at null_val.c:142 142 if (!initialized) (gdb) bt #0 G__init_null_patterns () at null_val.c:142 #1 0x0804a20e in gisinit () at gisinit.c:104 #2 0x0804a103 in G_no_gisinit () at gisinit.c:58 #3 0x08049550 in main (argc=3, argv=0xbffff684) at main.c:88 #4 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) next 148 numBits = sizeof(CELL) * 8; (gdb) 150 cellNullPattern = 1 << (numBits - 1); (gdb) 155 bytePtr = (unsigned char *) &fcellNullPattern; (gdb) 157 for (i = 0; i < sizeof(FCELL); i++) (gdb) ls Undefined command: "ls". Try "help". (gdb) l 152 /* Create the null pattern for the FCELL data type - set all bits */ 153 /* to 1, basically NaN. Need to use a byte pointer since bytes */ 154 /* represent the exponent and mantissa */ 155 bytePtr = (unsigned char *) &fcellNullPattern; 156 157 for (i = 0; i < sizeof(FCELL); i++) 158 { 159 *bytePtr = (unsigned char) 255; 160 bytePtr++; 161 } (gdb) 162 163 /* Create the null pattern for the DCELL data type - set all bits */ 164 /* to 1, basically NaN. Need to use a byte pointer since bytes */ 165 /* represent the exponent and mantissa */ 166 bytePtr = (unsigned char *) &dcellNullPattern; 167 168 for (i = 0; i < sizeof(DCELL); i++) 169 { 170 *bytePtr = (unsigned char) 255; 171 bytePtr++; (gdb) 172 } 173 174 /* Set the initialized flag to TRUE */ 175 initialized = TRUE; 176 } 177 178 return; 179 } 180 181 /**************************************************************************** (gdb) break 175 Breakpoint 11 at 0x804a8f8: file null_val.c, line 175. (gdb) cont Continuing. Breakpoint 11, G__init_null_patterns () at null_val.c:175 175 initialized = TRUE; (gdb) nbt Undefined command: "nbt". Try "help". (gdb) bt #0 G__init_null_patterns () at null_val.c:175 #1 0x0804a20e in gisinit () at gisinit.c:104 #2 0x0804a103 in G_no_gisinit () at gisinit.c:58 #3 0x08049550 in main (argc=3, argv=0xbffff684) at main.c:88 #4 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) next 179 } (gdb) gisinit () at gisinit.c:106 106 initialized = 1; (gdb) 107 umask(022); (gdb) 109 return 0; (gdb) 110 } (gdb) info source Current source file is gisinit.c Compilation directory is /ext2e/grass5.0.2/src/libes/gis/ Located in /ext2e/grass5.0.2/src/libes/gis/gisinit.c Contains 110 lines. Source language is c. Compiled with stabs debugging format. (gdb) next G_no_gisinit () at gisinit.c:60 60 return 0; (gdb) 61 } (gdb) main (argc=3, argv=0xbffff684) at main.c:91 91 parm.input->type = TYPE_STRING; (gdb) 97 parm.band->type = TYPE_INTEGER; (gdb) l 92 parm.input->required = YES; 93 parm.input->description = "Bin raster file to be imported"; 94 95 parm.band = G_define_option(); 96 parm.band->key = "band"; 97 parm.band->type = TYPE_INTEGER; 98 parm.band->required = NO; 99 parm.band->description = "Band to select (default is all bands)"; 100 101 parm.output = G_define_option(); (gdb) l 88 83 module->description = 84 "Import GDAL supported raster file into a binary raster map layer."; 85 86 /* -------------------------------------------------------------------- */ 87 /* Setup and fetch parameters. */ 88 /* -------------------------------------------------------------------- */ 89 parm.input = G_define_option(); 90 parm.input->key = "input"; 91 parm.input->type = TYPE_STRING; 92 parm.input->required = YES; (gdb) 93 parm.input->description = "Bin raster file to be imported"; 94 95 parm.band = G_define_option(); 96 parm.band->key = "band"; 97 parm.band->type = TYPE_INTEGER; 98 parm.band->required = NO; 99 parm.band->description = "Band to select (default is all bands)"; 100 101 parm.output = G_define_option(); 102 parm.output->key = "output"; (gdb)
comment:12 by , 21 years ago
I have looked at the compilation log for front.end/main.c, alloc.c,opencell.c, gisinit.c, and nullval.c and I have not found any unusual warning messages. Maybe I will try grass on a different distribution.
comment:13 by , 21 years ago
It appears that there is a memeory leak at least in my implementation. I tried using memwatch to trace it, but I could not get a good compile after much work.
comment:15 by , 21 years ago
I did some more tracing of the program. Below this point I believe is where r.in.gdal is called. I could not trace through the previous execution of parser.c. Maybe because its source is in one directory and the object in another. Program received signal SIGTRAP, Trace/breakpoint trap. 0x40000b50 in _start () from /lib/ld-linux.so.2 (gdb) Continuing. Program received signal SIGSEGV, Segmentation fault. 0x40006ee4 in _dl_lookup_symbol_internal () from /lib/ld-linux.so.2 (gdb) bt #0 0x40006ee4 in _dl_lookup_symbol_internal () from /lib/ld-linux.so.2 #1 0x421137b0 in _dl_sym () from /lib/i686/libc.so.6 #2 0x4002cfd0 in dlsym_doit () from /lib/i686/libm.so.6 #3 0x4000b4b3 in _dl_catch_error_internal () from /lib/ld-linux.so.2 #4 0x4002d28f in _dlerror_run () from /lib/i686/libm.so.6 #5 0x4002cf96 in dlsym () from /lib/i686/libm.so.6 #6 0x0804bee2 in G__open_raster_new (name=0xbfffbf30 "libgdal.1.1.so", open_mode=-871821421) at opencell.c:602 #7 0x0804bf38 in G__open_raster_new (name=0xbfffbf30 "libgdal.1.1.so", open_mode=-871821421) at opencell.c:616 #8 0x0804ca1b in G__reallocate_mask_buf () at opencell.c:799 #9 0x08049fbd in print_word (fd=0x3, word=0xbffff234, len=0xbffff244, lead=134517998) at error.c:296 #10 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) It is already corrupted before r.in.gdal is called since the execution jumps from line 91 to line 97. So it seems that parser.c is suspect. Unfortunately it will take some "trick" to get gdb to debug it. (gdb) main (argc=3, argv=0xbfffefa4) at main.c:91 91 parm.input->type = TYPE_STRING; (gdb) info source Current source file is main.c Compilation directory is /ext2e/grass5.0.2/grass/src/front.end/ Located in /ext2e/grass5.0.2/grass/src/raster/r.in.gdal/main.c Contains 1045 lines. Source language is c. Compiled with stabs debugging format. (gdb) l 85 80 G_gisinit (argv[0]); 81 82 module = G_define_module(); 83 module->description = 84 "Import GDAL supported raster file into a binary raster map layer."; 85 86 /* -------------------------------------------------------------------- */ 87 /* Setup and fetch parameters. */ 88 /* -------------------------------------------------------------------- */ 89 parm.input = G_define_option(); (gdb) 90 parm.input->key = "input"; 91 parm.input->type = TYPE_STRING; 92 parm.input->required = YES; 93 parm.input->description = "Bin raster file to be imported"; 94 95 parm.band = G_define_option(); 96 parm.band->key = "band"; 97 parm.band->type = TYPE_INTEGER; 98 parm.band->required = NO; 99 parm.band->description = "Band to select (default is all bands)"; (gdb) step 97 parm.band->type = TYPE_INTEGER; (gdb)
comment:16 by , 21 years ago
I seem to be getting different results in this latest debugging session. Could it be that an invalid location data is causing this crash? (gdb) r input=4429CATD.DDF output=test Starting program: /usr/local/grass5/etc/bin/cmd/r.in.gdal input=4429CATD.DDF output=test Breakpoint 1, main (argc=134532704, argv=0x3) at main.c:56 56 { (gdb) cont Continuing. Breakpoint 2, read_env () at env.c:113 113 fclose (fd); (gdb) cont Continuing. PROJ_INFO file not found for location princeton_dem PROJ_UNITS file not found for location princeton_dem Program received signal SIGSEGV, Segmentation fault. 0x080548d6 in G_find_key_value (key=0x8097d87 "proj", kv=0x0) at key_value1.c:106 106 for (n = 0; n < kv->nitems; n++) (gdb) bt #0 0x080548d6 in G_find_key_value (key=0x8097d87 "proj", kv=0x0) at key_value1.c:106 #1 0x0804ef00 in G_compare_projections (proj_info1=0x0, proj_units1=0x0, proj_info2=0x80cf2c8, proj_units2=0x80cf280) at main.c:1033 #2 0x0804d424 in main (argc=3, argv=0xbfffe584) at main.c:249 #3 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) l 101 102 char *G_find_key_value (char *key, struct Key_Value *kv) 103 { 104 int n; 105 106 for (n = 0; n < kv->nitems; n++) 107 if (strcmp (key, kv->key[n]) == 0) 108 return kv->value[n][0] ? kv->value[n] : NULL; 109 return NULL; 110 } (gdb) print kv $2 = (struct Key_Value *) 0x0 (gdb)
comment:17 by , 21 years ago
Teh segmentation fault has stopped. Running g.setproj fixed the problem. The current location must not contain a PROJ_INFO or PROJ_UNITS file. The segmentation fault was caused by trying to use a char pointer that was zero. That can be seen in the previous post. I will now have to verify that r.in.gdal is working properly.
comment:18 by , 21 years ago
I am able to run r.in.gdal without crashing now. However when I used r.describe etc to look at the layers it says that there is no data at a given location. If I run v.in.sdts on this DEM USGS data it segfaults, but it loads the other SDTS. r.in.gdal does not seem to do that and that seems to be the problem.
comment:19 by , 21 years ago
I got the r.in.gdal to work in importing SDTS USGS 7.5" data file. It appears to have been just a configuration issue. I used the input file to create a region, then I exited grass, restarted it and ran r.support. Previously r.in.gdal segmetation faulted when my PROJ_INFO and PROJ_UNITS were not set which is caused by incomplete location informaton.
comment:20 by , 17 years ago
Description: | modified (diff) |
---|---|
Resolution: | → worksforme |
Status: | assigned → closed |
It is not clear that there is a pending GDAL action item for this ticket.
Note:
See TracTickets
for help on using tickets.