[GRASS5] [bug #3585] (grass) bus error in general/manage modules

this bug's URL: http://intevation.de/rt/webrt?serial_num=3585
-------------------------------------------------------------------------

Subject: bus error in general/manage modules

Platform: Mac OSX
grass obtained from: Trento Italy site
grass binary for platform: Compiled from Sources
GRASS Version: 6.x

In 3 of the general-manage modules, g.remove, g.rename and g.copy, I get a bus error. On Mac OS
10.3.9, but NOT on 10.4.2. g.list is OK. GRASS 6.0.x and 6.1 CVS. GRASS and dependencies are
built with exactly the same options, but using GCC 3.3 on Mac OS 10.3.9 and GCC 4 on Mac OS
10.4.2. I'm sure this used to work on Mac OS 10.3.9 before GRASS 6.0.0, but I've been using 10.4
for so long now I can't say when it might have changed.

I see the CPU use spiking to 100% for a couple seconds before it crashes. It looks like it's happening
in read_list.c - here are parts of the crashlog from g.remove and g.rename (the rest of the crashlog
is a list of all the loaded libraries):

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x90050f60

Thread 0 Crashed:
0 g.remove 0x00003004 read_list + 0x40 (read_list.c:36)
1 g.remove 0x00002db8 init + 0x18 (init.c:11)
2 g.remove 0x00002894 main + 0x2c (remove.c:28)
3 g.remove 0x00002358 _start + 0x188 (crt.c:267)
4 dyld 0x8fe1a558 _dyld_start + 0x64

PPC Thread State:
  srr0: 0x00003004 srr1: 0x0000f030 vrsave: 0x00000000
    cr: 0x22000048 xer: 0x00000004 lr: 0x00002fcc ctr: 0x90029620
    r0: 0x00000000 r1: 0xbfffed60 r2: 0x0000419c r3: 0x00003f60
    r4: 0x00000000 r5: 0x00000004 r6: 0x00000001 r7: 0x00000006
    r8: 0x01602022 r9: 0x90050f60 r10: 0x004261d0 r11: 0x90134758
   r12: 0x90029620 r13: 0x00000000 r14: 0xbffffbac r15: 0x00000000
   r16: 0x00002878 r17: 0x00000000 r18: 0x00000000 r19: 0x00000000
   r20: 0x00000000 r21: 0x00000000 r22: 0x00000000 r23: 0x00000000
   r24: 0x00000000 r25: 0x00000000 r26: 0xbffffba8 r27: 0x0000000c
   r28: 0x00000002 r29: 0xbffffbac r30: 0xbffffbb8 r31: 0x00002fcc

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x90050f60

Thread 0 Crashed:
0 g.rename 0x00002ef0 read_list + 0x40 (read_list.c:36)
1 g.rename 0x00002c08 init + 0x18 (init.c:11)
2 g.rename 0x00002538 main + 0x30 (rename.c:19)
3 g.rename 0x00001ff8 _start + 0x188 (crt.c:267)
4 dyld 0x8fe1a558 _dyld_start + 0x64

PPC Thread State:
  srr0: 0x00002ef0 srr1: 0x0200f030 vrsave: 0x00000000
    cr: 0x22000248 xer: 0x00000004 lr: 0x00002eb8 ctr: 0x90029620
    r0: 0x00000000 r1: 0xbfffece0 r2: 0x000041ac r3: 0x00003f60
    r4: 0x00000000 r5: 0x00000009 r6: 0x00000001 r7: 0x00000007
    r8: 0x01602025 r9: 0x90050f60 r10: 0x004261d0 r11: 0x90134758
   r12: 0x90029620 r13: 0x00000000 r14: 0x00002518 r15: 0x00000000
   r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x00000000
   r20: 0x00000000 r21: 0x00000000 r22: 0x00000000 r23: 0x00000000
   r24: 0x00000000 r25: 0x00000000 r26: 0xbffffa3c r27: 0x0000000c
   r28: 0x00000002 r29: 0xbffffa40 r30: 0xbffffa4c r31: 0x00002eb8

-------------------------------------------- Managed by Request Tracker

I had some time to try a few things, and narrowed down the cause a little, I hope. I don't use GRASS on Mac OS 10.3 much these days, but on Mac OS 10.4, so I only occassionally give it a try.

At first I thought it might have something to do with the new SHLIB_LD options for Mac OS X (from back in bug #2544). I had initial success just changing these options a bit. But recently that hasn't worked. After fiddling with the options some more, I haven't had any success.

I realized that about the time I first saw the problem (and when changing the SHLIB_LD options worked), I had started using GDAL CVS and 1.3.0 betas. Because I really don't use Mac OS 10.3 much, I can't be sure of timing, but I'd guess that when I updated to GDAL 1.3.1 is when adjusting the SHLIB_LD options stopped working.

I worked around a bug in configure and compiled GRASS 6.0.1 without GDAL, and with the original SHLIB_LD options, and now it's working - no bus errors.

So, the two factors here: Mac OS 10.3 (that is, GCC 3.3) and newer GDALs (1.3.x). Everything is fine with the current GDAL and Mac OS 10.4 (GCC 4.0).

Any ideas what changed in GDAL that could have this effect with older GCC's and GRASS? Some C++ thing?

I could try rebuilding my whole dependency tree, but that will take a while.