Subject: Re: bug#1079: GNUstep port segfaults making autoloads on x86_64

From: Glenn Morris <[email-masked]>
Date: Wed, 08 Oct 2008 03:51:59 -0400

Yavor Doganov wrote:

> Just to rule out the possibility, can you compile gnustep-base
> against libffi in case it was built with libffcall (and vice-versa
> -- rebuild it with libffcall if it was with libffi).

I don't have either. gnustep-startup provides both, but uses ffcall by
default. I tried to get it to use ffi instead, but it did not work out
of the box and I haven't had time to look into it yet.

> Nevertheless, still fixes a harmless runtime warning.

Installed.

> It is getting too complicated for me, but can you compile this test
> program (it should never crash):

Never say never...

32-bit:

(gdb) r '{a=b; c=d}' '(foo, bar)' --batch '(setq foo 1)'
Starting program: /scratch/gmorris/tmp/gnustep/obj/test '{a=b; c=d}' 
'(foo, bar)' --batch '(setq foo 1)'
[Thread debugging using libthread_db enabled]
[New Thread -1208932672 (LWP 26878)]
Useless info about bundle: <NSBundle: 0x93e3970> 
</scratch/gmorris/tmp/gnustep/Resources/test>
'{a=b; c=d}' - a dictionary.
'(foo, bar)' - an array.
'--batch' - a string.
'(setq foo 1)' failed with:
Parse failed  - Parse failed at line 1 (char 7) - unexpected character 
(wanted ',' or ')').
Failure.

Program exited with code 01.

(gdb) set environment NOHANDLE=yes 
(gdb)  r '{a=b; c=d}' '(foo, bar)' --batch '(setq foo 1)'
Starting program: /scratch/gmorris/tmp/gnustep/obj/test '{a=b; c=d}' 
'(foo, bar)' --batch '(setq foo 1)'
[Thread debugging using libthread_db enabled]
[New Thread -1208916288 (LWP 26885)]
Useless info about bundle: <NSBundle: 0x8edf9b8> 
</scratch/gmorris/tmp/gnustep/Resources/test>
NOHANDLE defined; should exit with success.

Program exited normally.

64-bit:

(gdb) r '{a=b; c=d}' '(foo, bar)' --batch '(setq foo 1)'
Starting program: /scratch/gmorris/tmp/gnustep/obj/test '{a=b; c=d}' 
'(foo, bar)' --batch '(setq foo 1)'
[Thread debugging using libthread_db enabled]
[New Thread 47102936683440 (LWP 11003)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47102936683440 (LWP 11003)]
0x00002ad701150af6 in NSCountFrames () at NSDebug.m:994
994     NSDebug.m: No such file or directory.
        in NSDebug.m
#0  0x00002ad701150af6 in NSCountFrames () at NSDebug.m:994
        env = (jbuf_type *) 0x573a370
#1  0x00002ad701158ff3 in GSPrivateStackAddresses () at NSDebug.m:1100
        n = 0
        stack = (class NSMutableArray *) 0x2ad70167e020
        pool = (class NSAutoreleasePool *) 0x7fffa9b14020
        i = 10967
        env = (jbuf_type *) 0x8
#2  0x00002ad70116f920 in -[NSException raise] (self=0x5738c50, 
    _cmd=0x2ad70161a440) at NSException.m:822
        __value = (struct objc_object *) 0x5738c50
        __object = (struct objc_object *) 0x7fffa9b140c0
        thread = (TInfo) 0x57394b0
        handler = (NSHandler *) 0x2ad701619aa0
        recursion = 0
#3  0x00002ad70116f3f4 in +[NSException raise:format:arguments:] (
    self=0x2ad701619fe0, _cmd=0x2ad70161a410, name=0x2ad701619aa0, 
    format=0x2ad701649020, argList=0x7fffa9b14100) at NSException.m:765
        reason = (class NSString *) 0x57394b0
        except = (class NSException *) 0x5738c50
#4  0x00002ad70116f32a in +[NSException raise:format:] 
(self=0x2ad701619fe0, 
    _cmd=0x2ad70164a6b0, name=0x2ad701619aa0, format=0x2ad701649020)
    at NSException.m:751
        args =   {{
    gp_offset = 32, 
    fp_offset = 48, 
    overflow_arg_area = 0x7fffa9b141f0, 
    reg_save_area = 0x7fffa9b14120
  }}
---Type <return> to continue, or q <return> to quit---
#5  0x00002ad7011e3fbb in GSPropertyListFromStringsFormat 
(string=0x56ee4e0)
    at NSPropertyList.m:1505
        dict = (class NSMutableDictionary *) 0x0
        _pld = {
  ptr = 0x5737450 "(setq foo 1)8", 
  end = 12, 
  pos = 0, 
  lin = 0, 
  err = 0x2ad701649000, 
  opt = NSPropertyListImmutable, 
  key = 0 '\000', 
  old = 1 '\001'
}
        pld = (pldata *) 0x7fffa9b14210
        d = (class NSData *) 0x5738e00
        __PRETTY_FUNCTION__ =   "GSPropertyListFromStringsFormat"
#6  0x00002ad70121e474 in -[NSString propertyList] (self=0x56ee4e0, 
    _cmd=0x2ad701678f80) at NSString.m:4701
        NSLocalHandler = {
  jumpState =     {{
      __jmpbuf =         {47102929706784,
        -6946947468941412056,
        91449456,
        47102923872888,
        91075728,
        0,
        -6946947468941410312,
        -6947038554855696004}, 
      __mask_was_saved = 0, 
---Type <return> to continue, or q <return> to quit---
      __saved_mask = {
        __val =           {47102924024290,
          0,
          6,
          34359738380,
          47102929894528,
          47102929784384,
          91153632,
          140736040354784,
          47102925290065,
          34450891952,
          47102929894528,
          47102929784464,
          91153632,
          51539607552,
          91153632,
          140736040354864}
      }
    }}, 
  next = 0x7fffa9b14450, 
  exception = 0x7fffa9b14430
}
        data = (class NSData *) 0x57374a0
        result = (struct objc_object *) 0x0
        format = NSPropertyListOpenStepFormat
        error = (class NSString *) 0x5738d80
#7  0x00002ad7012515f3 in -[NSUserDefaults __createArgumentDictionary] (
    self=0x57341d0, _cmd=0x2ad701678bf0) at NSUserDefaults.m:1816
        NSLocalHandler = {
---Type <return> to continue, or q <return> to quit---
  jumpState =     {{
      __jmpbuf =         {91153632,
        -6946947468941412200,
        91449456,
        47102923872888,
        91075728,
        0,
        -6946947468941412008,
        -6947038554855380769}, 
      __mask_was_saved = 0, 
      __saved_mask = {
        __val =           {0,
          91449728,
          10,
          140736040355024,
          47102923869137,
          240,
          47102929920032,
          140736040355104,
          47102923868903,
          43041122496,
          91449464,
          5,
          91449696,
          8,
          91449728,
          18446744073709551615}
      }
    }}, 
---Type <return> to continue, or q <return> to quit---
  next = 0x0, 
  exception = 0x7fffa9b14550
}
        plist_val = (class NSObject *) 0xa01678900
        old = (class NSString *) 0x0
        args = (class NSArray *) 0x56f0830
        enumerator = (class NSEnumerator *) 0x5736d00
        argDict = (class NSMutableDictionary *) 0x5737320
        done = 0 '\000'
        key = (struct objc_object *) 0x5737420
        val = (struct objc_object *) 0x56ee4e0
#8  0x00002ad70124ce0e in -[NSUserDefaults initWithContentsOfFile:] (
    self=0x57341d0, _cmd=0x2ad701678ae0, path=0x5734fa0)
    at NSUserDefaults.m:872
        mgr = (class NSFileManager *) 0x5706160
        r = {
  location = 2147483647, 
  length = 0
}
        loadReadonly = 0 '\000'
        flag = 0 '\000'
        objc_super = {
  self = 0x57341d0, 
  super_class = 0x2ad70163a860
}
#9  0x00002ad70124c349 in -[NSUserDefaults initWithUser:] 
(self=0x57341d0, 
    _cmd=0x2ad701678ad0, userName=0x56ae9f0) at NSUserDefaults.m:774
        path = (class NSString *) 0x5734e60
#10 0x00002ad70124c2c4 in -[NSUserDefaults init] (self=0x57341d0, 
---Type <return> to continue, or q <return> to quit---
    _cmd=0x2ad701678910) at NSUserDefaults.m:765
No locals.
#11 0x00002ad70124b383 in +[NSUserDefaults standardUserDefaults] (
    self=0x2ad7016786c0, _cmd=0x2ad701678870) at NSUserDefaults.m:474
        added_lang = 0 '\000'
        added_locale = 0 '\000'
        lang = (struct objc_object *) 0x2ad7018e8708
        uL = (class NSArray *) 0x7fffa9b14760
        enumerator = (class NSEnumerator *) 0x2ad7010a7fba
#12 0x00002ad70124bc78 in +[NSUserDefaults userLanguages] (
    self=0x2ad7016786c0, _cmd=0x2ad7015fa9f0) at NSUserDefaults.m:682
        currLang = (class NSArray *) 0x0
        locale = (class NSString *) 0x57341a0
        result = (class NSArray *) 0x2ad7018e8708
#13 0x00002ad70110ab99 in +[NSBundle 
_bundleResourcePathsWithRootPath:subPath:]
    (self=0x2ad7015fa360, _cmd=0x2ad7015faa00, rootPath=0x57283d0, 
subPath=0x0)
    at NSBundle.m:1603
        primary = (class NSString *) 0x2ad7015f7e90
        language = (class NSString *) 0x56df120
        languages = (class NSArray *) 0x2ad70125a36f
        array = (class NSMutableArray *) 0x572e4a0
        enumerate = (class NSEnumerator *) 0x2ad7015fa360
#14 0x00002ad70110ae05 in +[NSBundle 
pathForResource:ofType:inRootPath:inDirectory:withVersion:] 
(self=0x2ad7015fa360, _cmd=0x2ad7015faa10, 
    name=0x2ad7015f9760, ext=0x2ad7015f9780, rootPath=0x57283d0, 
subPath=0x0, 
    version=0) at NSBundle.m:1637
        path = (class NSString *) 0x0
        fullpath = (class NSString *) 0x2ad70163a860
        pathlist = (class NSEnumerator *) 0x7fffa9b148d0
---Type <return> to continue, or q <return> to quit---
#15 0x00002ad70110b31f in -[NSBundle 
pathForResource:ofType:inDirectory:] (
    self=0x572d710, _cmd=0x2ad7015fa770, name=0x2ad7015f9760, 
    ext=0x2ad7015f9780, subPath=0x0) at NSBundle.m:1732
        rootPath = (class NSString *) 0x57283d0
#16 0x00002ad70110b1e4 in -[NSBundle pathForResource:ofType:] 
(self=0x572d710, 
    _cmd=0x2ad7015fab10, name=0x2ad7015f9760, ext=0x2ad7015f9780)
    at NSBundle.m:1713
No locals.
#17 0x00002ad70110d0f5 in -[NSBundle infoDictionary] (self=0x572d710, 
    _cmd=0x2ad7015fa990) at NSBundle.m:2192
        path = (class NSString *) 0x7fffa9b149f0
#18 0x00002ad70110d3d5 in -[NSBundle bundleIdentifier] (self=0x572d710, 
    _cmd=0x2ad7015fa8f0) at NSBundle.m:2237
No locals.
#19 0x00002ad7011098b3 in -[NSBundle initWithPath:] (self=0x572d710, 
    _cmd=0x2ad7015fa750, path=0x57283d0) at NSBundle.m:1315
        identifier = (class NSString *) 0x2ad7015fa750
        objc_super = {
  self = 0x572d710, 
  super_class = 0x2ad70163a860
}
#20 0x00002ad7011092a0 in +[NSBundle bundleWithPath:] 
(self=0x2ad7015fa360, 
    _cmd=0x2ad7015fabc0, path=0x572d530) at NSBundle.m:1192
No locals.
#21 0x00002ad70110d980 in +[NSBundle(GNUstep) bundleForLibrary:version:] 
(
    self=0x2ad7015fa360, _cmd=0x2ad7015fa820, libraryName=0x5706f40, 
    interfaceVersion=0x2ad7015f9080) at NSBundle.m:2352
        b = (class NSBundle *) 0x2ad7016df315
        isDir = 1 '\001'
---Type <return> to continue, or q <return> to quit---
        paths = (class NSArray *) 0x5706f80
        enumerator = (class NSEnumerator *) 0x5729420
        path = (class NSString *) 0x572d530
        fm = (class NSFileManager *) 0x5706160
#22 0x00002ad70110806a in +[NSBundle initialize] (self=0x2ad7015fa360, 
    _cmd=0x2ad70167eef0) at NSBundle.m:819
        env = (class NSDictionary *) 0x570d850
        str = (class NSString *) 0x5701b30
#23 0x00002ad7016df04d in objc_msg_lookup () from /usr/lib64/libobjc.so.1
No symbol table info available.
#24 0x0000000000400c12 in main (argc=5, argv=0x7fffa9b14e98, 
    env=0x7fffa9b14ec8) at test.m:8
        pool = (class NSAutoreleasePool *) 0x56df120
        proc = (class NSProcessInfo *) 0x56ad230
        bundle = (class NSBundle *) 0x382141abc0
        args = (class NSArray *) 0x401220
        i = 4196843
        retval = 0

(gdb) set environment NOHANDLE=yes
(gdb) r '{a=b; c=d}' '(foo, bar)' --batch '(setq foo 1)'
Starting program: /scratch/gmorris/tmp/gnustep/obj/test '{a=b; c=d}' 
'(foo, bar)' --batch '(setq foo 1)'
[Thread debugging using libthread_db enabled]
[New Thread 47495076418480 (LWP 11065)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47495076418480 (LWP 11065)]
0x00002b324e6e8af6 in NSCountFrames () at NSDebug.m:994
994     NSDebug.m: No such file or directory.
        in NSDebug.m
(gdb) bt full
#0  0x00002b324e6e8af6 in NSCountFrames () at NSDebug.m:994
        env = (jbuf_type *) 0xac85460
#1  0x00002b324e6f0ff3 in GSPrivateStackAddresses () at NSDebug.m:1100
        n = 0
        stack = (class NSMutableArray *) 0x2b324ec16020
        pool = (class NSAutoreleasePool *) 0x7fff5c579a70
        i = 11058
        env = (jbuf_type *) 0x8
#2  0x00002b324e707920 in -[NSException raise] (self=0xac83d40, 
    _cmd=0x2b324ebb2440) at NSException.m:822
        __value = (struct objc_object *) 0xac83d40
        __object = (struct objc_object *) 0x7fff5c579b10
        thread = (TInfo) 0xac845a0
        handler = (NSHandler *) 0x2b324ebb1aa0
        recursion = 0
#3  0x00002b324e7073f4 in +[NSException raise:format:arguments:] (
    self=0x2b324ebb1fe0, _cmd=0x2b324ebb2410, name=0x2b324ebb1aa0, 
    format=0x2b324ebe1020, argList=0x7fff5c579b50) at NSException.m:765
        reason = (class NSString *) 0xac845a0
        except = (class NSException *) 0xac83d40
#4  0x00002b324e70732a in +[NSException raise:format:] 
(self=0x2b324ebb1fe0, 
    _cmd=0x2b324ebe26b0, name=0x2b324ebb1aa0, format=0x2b324ebe1020)
    at NSException.m:751
        args =   {{
    gp_offset = 32, 
    fp_offset = 48, 
    overflow_arg_area = 0x7fff5c579c40, 
    reg_save_area = 0x7fff5c579b70
  }}
---Type <return> to continue, or q <return> to quit---
#5  0x00002b324e77bfbb in GSPropertyListFromStringsFormat 
(string=0xac39500)
    at NSPropertyList.m:1505
        dict = (class NSMutableDictionary *) 0x0
        _pld = {
  ptr = 0xac82540 "(setq foo 1)8", 
  end = 12, 
  pos = 0, 
  lin = 0, 
  err = 0x2b324ebe1000, 
  opt = NSPropertyListImmutable, 
  key = 0 '\000', 
  old = 1 '\001'
}
        pld = (pldata *) 0x7fff5c579c60
        d = (class NSData *) 0xac83ef0
        __PRETTY_FUNCTION__ =   "GSPropertyListFromStringsFormat"
#6  0x00002b324e7b6474 in -[NSString propertyList] (self=0xac39500, 
    _cmd=0x2b324ec10f80) at NSString.m:4701
        NSLocalHandler = {
  jumpState =     {{
      __jmpbuf =         {47495069441824,
        5927823237564070548,
        180885856,
        47495063607928,
        180511920,
        0,
        5927823237564070180,
        5927738896990535792}, 
      __mask_was_saved = 0, 
---Type <return> to continue, or q <return> to quit---
      __saved_mask = {
        __val =           {47495063759330,
          0,
          6,
          34359738380,
          47495069629568,
          47495069519424,
          180589824,
          140734742634032,
          47495065025105,
          34540328144,
          47495069629568,
          47495069519504,
          180589824,
          51539607552,
          180589824,
          140734742634112}
      }
    }}, 
  next = 0x7fff5c579ea0, 
  exception = 0x7fff5c579e80
}
        data = (class NSData *) 0xac82590
        result = (struct objc_object *) 0x0
        format = NSPropertyListOpenStepFormat
        error = (class NSString *) 0xac83e70
#7  0x00002b324e7e95f3 in -[NSUserDefaults __createArgumentDictionary] (
    self=0xac7f2c0, _cmd=0x2b324ec10bf0) at NSUserDefaults.m:1816
        NSLocalHandler = {
---Type <return> to continue, or q <return> to quit---
  jumpState =     {{
      __jmpbuf =         {180589824,
        5927823237564070852,
        180885856,
        47495063607928,
        180511920,
        0,
        5927823237564070532,
        5927738896990794195}, 
      __mask_was_saved = 0, 
      __saved_mask = {
        __val =           {0,
          180886128,
          10,
          140734742634272,
          47495063604177,
          240,
          47495069655072,
          140734742634352,
          47495063603943,
          43130558896,
          180885864,
          5,
          180886096,
          8,
          180886128,
          18446744073709551615}
      }
    }}, 
---Type <return> to continue, or q <return> to quit---
  next = 0x0, 
  exception = 0x7fff5c579fa0
}
        plist_val = (class NSObject *) 0xa4ec10900
        old = (class NSString *) 0x0
        args = (class NSArray *) 0xac3b850
        enumerator = (class NSEnumerator *) 0xac81df0
        argDict = (class NSMutableDictionary *) 0xac82410
        done = 0 '\000'
        key = (struct objc_object *) 0xac82510
        val = (struct objc_object *) 0xac39500
#8  0x00002b324e7e4e0e in -[NSUserDefaults initWithContentsOfFile:] (
    self=0xac7f2c0, _cmd=0x2b324ec10ae0, path=0xac80090)
    at NSUserDefaults.m:872
        mgr = (class NSFileManager *) 0xac51170
        r = {
  location = 2147483647, 
  length = 0
}
        loadReadonly = 0 '\000'
        flag = 0 '\000'
        objc_super = {
  self = 0xac7f2c0, 
  super_class = 0x2b324ebd2860
}
#9  0x00002b324e7e4349 in -[NSUserDefaults initWithUser:] 
(self=0xac7f2c0, 
    _cmd=0x2b324ec10ad0, userName=0xabf99f0) at NSUserDefaults.m:774
        path = (class NSString *) 0xac7ff50
#10 0x00002b324e7e42c4 in -[NSUserDefaults init] (self=0xac7f2c0, 
---Type <return> to continue, or q <return> to quit---
    _cmd=0x2b324ec10910) at NSUserDefaults.m:765
No locals.
#11 0x00002b324e7e3383 in +[NSUserDefaults standardUserDefaults] (
    self=0x2b324ec106c0, _cmd=0x2b324ec10870) at NSUserDefaults.m:474
        added_lang = 0 '\000'
        added_locale = 0 '\000'
        lang = (struct objc_object *) 0x2b324ee80708
        uL = (class NSArray *) 0x7fff5c57a1b0
        enumerator = (class NSEnumerator *) 0x2b324e63ffba
#12 0x00002b324e7e3c78 in +[NSUserDefaults userLanguages] (
    self=0x2b324ec106c0, _cmd=0x2b324eb929f0) at NSUserDefaults.m:682
        currLang = (class NSArray *) 0x0
        locale = (class NSString *) 0xac7f290
        result = (class NSArray *) 0x2b324ee80708
#13 0x00002b324e6a2b99 in +[NSBundle 
_bundleResourcePathsWithRootPath:subPath:]
    (self=0x2b324eb92360, _cmd=0x2b324eb92a00, rootPath=0xac734c0, 
subPath=0x0)
    at NSBundle.m:1603
        primary = (class NSString *) 0x2b324eb8fe90
        language = (class NSString *) 0xac2a140
        languages = (class NSArray *) 0x2b324e7f236f
        array = (class NSMutableArray *) 0xac79590
        enumerate = (class NSEnumerator *) 0x2b324eb92360
#14 0x00002b324e6a2e05 in +[NSBundle 
pathForResource:ofType:inRootPath:inDirectory:withVersion:] 
(self=0x2b324eb92360, _cmd=0x2b324eb92a10, 
    name=0x2b324eb91760, ext=0x2b324eb91780, rootPath=0xac734c0, 
subPath=0x0, 
    version=0) at NSBundle.m:1637
        path = (class NSString *) 0x0
        fullpath = (class NSString *) 0x2b324ebd2860
        pathlist = (class NSEnumerator *) 0x7fff5c57a320
---Type <return> to continue, or q <return> to quit---
#15 0x00002b324e6a331f in -[NSBundle 
pathForResource:ofType:inDirectory:] (
    self=0xac78800, _cmd=0x2b324eb92770, name=0x2b324eb91760, 
    ext=0x2b324eb91780, subPath=0x0) at NSBundle.m:1732
        rootPath = (class NSString *) 0xac734c0
#16 0x00002b324e6a31e4 in -[NSBundle pathForResource:ofType:] 
(self=0xac78800, 
    _cmd=0x2b324eb92b10, name=0x2b324eb91760, ext=0x2b324eb91780)
    at NSBundle.m:1713
No locals.
#17 0x00002b324e6a50f5 in -[NSBundle infoDictionary] (self=0xac78800, 
    _cmd=0x2b324eb92990) at NSBundle.m:2192
        path = (class NSString *) 0x7fff5c57a440
#18 0x00002b324e6a53d5 in -[NSBundle bundleIdentifier] (self=0xac78800, 
    _cmd=0x2b324eb928f0) at NSBundle.m:2237
No locals.
#19 0x00002b324e6a18b3 in -[NSBundle initWithPath:] (self=0xac78800, 
    _cmd=0x2b324eb92750, path=0xac734c0) at NSBundle.m:1315
        identifier = (class NSString *) 0x2b324eb92750
        objc_super = {
  self = 0xac78800, 
  super_class = 0x2b324ebd2860
}
#20 0x00002b324e6a12a0 in +[NSBundle bundleWithPath:] 
(self=0x2b324eb92360, 
    _cmd=0x2b324eb92bc0, path=0xac78620) at NSBundle.m:1192
No locals.
#21 0x00002b324e6a5980 in +[NSBundle(GNUstep) bundleForLibrary:version:] 
(
    self=0x2b324eb92360, _cmd=0x2b324eb92820, libraryName=0xac51f50, 
    interfaceVersion=0x2b324eb91080) at NSBundle.m:2352
        b = (class NSBundle *) 0x2b324ec77315
        isDir = 1 '\001'
---Type <return> to continue, or q <return> to quit---
        paths = (class NSArray *) 0xac51f90
        enumerator = (class NSEnumerator *) 0xac74510
        path = (class NSString *) 0xac78620
        fm = (class NSFileManager *) 0xac51170
#22 0x00002b324e6a006a in +[NSBundle initialize] (self=0x2b324eb92360, 
    _cmd=0x2b324ec16ef0) at NSBundle.m:819
        env = (class NSDictionary *) 0xac58930
        str = (class NSString *) 0xac4cc00
#23 0x00002b324ec7704d in objc_msg_lookup () from /usr/lib64/libobjc.so.1
No symbol table info available.
#24 0x0000000000400c12 in main (argc=5, argv=0x7fff5c57a8e8, 
    env=0x7fff5c57a918) at test.m:8
        pool = (class NSAutoreleasePool *) 0xac2a140
        proc = (class NSProcessInfo *) 0xabf8230
        bundle = (class NSBundle *) 0x382141abc0
        args = (class NSArray *) 0x401220
        i = 4196843
        retval = 0