loading bundles stopped working

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

loading bundles stopped working

Sebastian Reitenbach-2
Hi,

since a good months ago, on OpenBSD -current amd64, bundle loading stopped working. I'm not sure what caused it, at least nothing with regard to objc and gnustep, since I haven't touched the packages since then.

So ktrace tells me, it finds the GSBackend bundle, opens the Info-Gnustep.plist, reads it, and opens the
object file. But then in:

Breakpoint 1, initialize_gnustep_backend () at NSApplication.m:321
321             backend = NSClassFromString (@"GSBackend");

That NSClassFromString fails, and basically all GUI applications stop working as well as
any other application that loads bundles seems to have the same/similar problem as well,
as I saw the same thing with SOGo webmailer.

Below a gdb session, where I tried to follow the flow from above backtrace.

I think somewhere in libobjc2, some "assumption" how things work, is due to some change
in the OS or some dependent package not right anymore?
But I've no clue.

Things are built with clang from base, wich is:
OpenBSD clang version 6.0.0 (tags/RELEASE_600/final) (based on LLVM 6.0.0)
Target: amd64-unknown-openbsd6.4
Thread model: posix
InstalledDir: /usr/bin

But I also tried clang6.0.1 from ports, but to no avail.

On OpenBSD -current there is /usr/bin/ld, /usr/bin/ld.lld and /usr/bin/ld.bfd installed,
where /usr/bin/ld is a hardlink to /usr/bin/ld.lld.

When I build libobjc2 or other libs/apps, then for linking clang is used, which in turn uses
I think /usr/bin/ld ?

So, the thing is, when I replace all /usr/bin/ld* with the /usr/bin/ld.bfd, and rebuild everything,
then GUI apps, as well as SOGo start up. But I can't do that when building packages :(
At some point in time the default linker was changed from the ld.bfd to ld.lld, but I think
that happened quite a bit earlier.

I tried to force using /usr/bin/ld.bfd setting LD=/usr/bin/ld.bfd, but then building gnustep-base or
others, when it comes to linking, it is whining about parameters/flags it doesn't understand.

someone can point me into some direction what might go wrong here?

Sebastian

following versions are installed:
gnustep-back-0.26.2 GNUstep gui backend
gnustep-base-1.25.1p1 GNUstep base library
gnustep-gui-0.26.2  GNUstep gui library
gnustep-libobjc2-1.8.1p0 GNUstep libobjc2 objective-c runtime
gnustep-make-2.7.0p2 GNUstep makefile package

 egdb /usr/local/bin/GMines  
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-openbsd6.4".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/GMines...done.
(gdb) r
Starting program: /usr/local/bin/GMines

Program received signal SIGFPE, Arithmetic exception.
0x00000b039aff524c in _dl_find_symbol_obj (obj=0xb03d90cbc00, sl=0x7f7fffff44d8) at /usr/src/libexec/ld.so/resolve.c:584
584             for (si = obj->buckets[sl->sl_elf_hash % obj->nbuckets];
(gdb) bt
#0  0x00000b039aff524c in _dl_find_symbol_obj (obj=0xb03d90cbc00, sl=0x7f7fffff44d8) at /usr/src/libexec/ld.so/resolve.c:584
#1  0x00000b039aff5068 in _dl_find_symbol (name=0xb0360931d15 "getpid", this=0x7f7fffff4578, flags=48, ref_sym=0xb03608c6338, req_obj=<optimized out>,
    pobj=0x7f7fffff4570) at /usr/src/libexec/ld.so/resolve.c:663
#2  0x00000b039aff3f1a in _dl_bind (object=0xb03f04dd400, index=<optimized out>) at /usr/src/libexec/ld.so/amd64/rtld_machine.c:357
#3  0x00000b039aff5fed in _dl_bind_start () at /usr/src/libexec/ld.so/amd64/ldasm.S:108
#4  0x00000b0360d6b5c4 in NSLogv (format=0xb0399f41308, args=0x7f7fffff48c0) at NSLog.m:350
#5  0x00000b0360c73d75 in -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] (self=0xb03e00bfd38, _cmd=0xb0357e4f7c8 <.objc_selector_list+1392>,
    functionName=0xb0371011688, fileName=0xb040117be88, line=323, format=0xb0357e4d0e8 <.objc_str.404>) at NSAssertionHandler.m:101
#6  0x00000b0357abed97 in initialize_gnustep_backend () at NSApplication.m:322
#7  0x00000b0357ac136b in -[NSApplication _init] (self=0xb039592ee08, _cmd=0xb0357e4fa38 <.objc_selector_list+2016>) at NSApplication.m:878
#8  0x00000b0360d8e5f8 in -[NSObject performSelector:withObject:] (self=0xb039592ee08, _cmd=0xb0360fb5630 <.objc_selector_list+720>,
    aSelector=0xb0357e4fa38 <.objc_selector_list+2016>, anObject=0xb039592ee08) at NSObject.m:2000
#9  0x00000b0360e24673 in -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] (self=0xb039592ee08,
    _cmd=0xb0360fb53a0 <.objc_selector_list+64>, aSelector=0xb0357e4fa38 <.objc_selector_list+2016>, aThread=0xb0400c40588, anObject=0xb039592ee08, aFlag=1 '\001',
    anArray=0xb040117b988) at NSThread.m:1672
#10 0x00000b0360e24321 in -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:modes:] (self=0xb039592ee08,
    _cmd=0xb0360fb53e0 <.objc_selector_list+128>, aSelector=0xb0357e4fa38 <.objc_selector_list+2016>, anObject=0xb039592ee08, aFlag=1 '\001', anArray=0xb040117b988)
    at NSThread.m:1627
#11 0x00000b0360e243be in -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] (self=0xb039592ee08,
    _cmd=0xb0357e50098 <.objc_selector_list+3648>, aSelector=0xb0357e4fa38 <.objc_selector_list+2016>, anObject=0xb039592ee08, aFlag=1 '\001') at NSThread.m:1638
#12 0x00000b0357ac1ad5 in -[NSApplication init] (self=0xb039592ee08, _cmd=0xb0357e50178 <.objc_selector_list+3872>) at NSApplication.m:978
#13 0x00000b0357ac12dd in +[NSApplication sharedApplication] (self=0xb0357e4e8b8 <_OBJC_CLASS_NSApplication>, _cmd=0xb014671b268 <.objc_selector_list+160>)
    at NSApplication.m:850
#14 0x00000b014670dfb8 in gnustep_base_user_main (argc=1, argv=0x7f7fffff4f48, env=0x7f7fffff4f58) at main.m:44
#15 0x00000b0360dc21e7 in main (argc=1, argv=0x7f7fffff4f48, env=0x7f7fffff4f58) at NSProcessInfo.m:1002
#16 0x00000b014670a056 in ___start ()
#17 0x0000000000000000 in ?? ()
(gdb) frame 6
#6  0x00000b0357abed97 in initialize_gnustep_backend () at NSApplication.m:322
322             NSCAssert1 (backend != Nil,
(gdb) list
317                         path);
318
319             /* Now get the GSBackend class, which should have just been loaded
320              * from the bundle.  */
321             backend = NSClassFromString (@"GSBackend");
322             NSCAssert1 (backend != Nil,
323               _(@"Backend at path %@ doesn't contain the GSBackend class"), path);
324             [backend initializeBackend];
325           }
326
(gdb) break NSApplication.m:321
Breakpoint 1 at 0xb0357abec6e: file NSApplication.m, line 321.
(gdb) c
Continuing.

Program terminated with signal SIGFPE, Arithmetic exception.
The program no longer exists.
(gdb) r
Starting program: /usr/local/bin/GMines

Breakpoint 1, initialize_gnustep_backend () at NSApplication.m:321
321             backend = NSClassFromString (@"GSBackend");
(gdb) s
NSClassFromString (aClassName=0xfaf8e68cfe0 <.objc_str.393>) at NSObjCRuntime.m:108
108       if (aClassName != nil)
(gdb) n
110           int       len = [aClassName length];
(gdb)
111           char      buf[len+1];
(gdb)
113           [aClassName getCString: buf
(gdb)
114                        maxLength: len + 1
(gdb)
113           [aClassName getCString: buf
(gdb)
116           return objc_lookUpClass (buf);
(gdb) s
objc_lookUpClass (name=0x7f7ffffee240 "GSBackend") at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/class_table.c:519
519             return (id)class_table_get_safe(name);
(gdb) s
class_table_get_safe (class_name=0x7f7ffffee240 "GSBackend") at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/class_table.c:131
131             if (NULL == class_name) { return Nil; }
(gdb) list
126             class_table_internal_insert(class_table, class);
127     }
128
129     PRIVATE Class class_table_get_safe(const char *class_name)
130     {
131             if (NULL == class_name) { return Nil; }
132             return class_table_internal_table_get(class_table, class_name);
133     }
134
135     PRIVATE Class class_table_next(void **e)
(gdb) print class_name
$1 = 0x7f7ffffee240 "GSBackend"
(gdb) print class_table
$2 = (class_table_internal_table *) 0xfaf8951e9c0
(gdb) print *class_table
$3 = {lock = 0xfafca3b8200, table_size = 4096, table_used = 784, enumerator_count = 1, old = 0x0, table = 0xfafbe1fa000}
(gdb) s
132             return class_table_internal_table_get(class_table, class_name);
(gdb) s
class_table_internal_table_get (table=0xfaf8951e9c0, key=0x7f7ffffee240) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:418
418             PREFIX(_table_cell) cell = PREFIX(_table_get_cell)(table, key);
(gdb) print table
$4 = (class_table_internal_table *) 0xfaf8951e9c0
(gdb) print key
$5 = (const void *) 0x7f7ffffee240
(gdb) print *key
Attempt to dereference a generic pointer.
(gdb) print const char *key
A syntax error in expression, near `key'.
(gdb) print const char * key
A syntax error in expression, near `key'.
(gdb) print (const char *) key
$6 = 0x7f7ffffee240 "GSBackend"
(gdb) s
class_table_internal_table_get_cell (table=0xfaf8951e9c0, key=0x7f7ffffee240) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:338
338             uint32_t hash = MAP_TABLE_HASH_KEY(key);
(gdb) print (const char *) key
$7 = 0x7f7ffffee240 "GSBackend"
(gdb) s
string_hash (str=0x7f7ffffee240 "GSBackend") at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/string_hash.h:10
10              uint32_t hash = 0;
(gdb) list
5        * Efficient string hash function.
6        */
7       __attribute__((unused))
8       static uint32_t string_hash(const char *str)
9       {
10              uint32_t hash = 0;
11              int32_t c;
12              while ((c = *str++))
13              {
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb) s
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb) print c
$8 = 71
(gdb) c
Continuing.

Program received signal SIGFPE, Arithmetic exception.
0x00000faee7d1e24c in _dl_find_symbol_obj (obj=0xfaf1783e800, sl=0x7f7ffffede78) at /usr/src/libexec/ld.so/resolve.c:584
584             for (si = obj->buckets[sl->sl_elf_hash % obj->nbuckets];
(gdb) c
Continuing.

Program terminated with signal SIGFPE, Arithmetic exception.
The program no longer exists.
(gdb) r
Starting program: /usr/local/bin/GMines

Breakpoint 1, initialize_gnustep_backend () at NSApplication.m:321
321             backend = NSClassFromString (@"GSBackend");
(gdb) s
NSClassFromString (aClassName=0xa32a1719fe0 <.objc_str.393>) at NSObjCRuntime.m:108
108       if (aClassName != nil)
(gdb)
110           int       len = [aClassName length];
(gdb)
111           char      buf[len+1];
(gdb)
113           [aClassName getCString: buf
(gdb)
114                        maxLength: len + 1
(gdb)
113           [aClassName getCString: buf
(gdb)
116           return objc_lookUpClass (buf);
(gdb)
objc_lookUpClass (name=0x7f7ffffc0090 "GSBackend") at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/class_table.c:519
519             return (id)class_table_get_safe(name);
(gdb)
class_table_get_safe (class_name=0x7f7ffffc0090 "GSBackend") at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/class_table.c:131
131             if (NULL == class_name) { return Nil; }
(gdb)
132             return class_table_internal_table_get(class_table, class_name);
(gdb)
class_table_internal_table_get (table=0xa331e009540, key=0x7f7ffffc0090) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:418
418             PREFIX(_table_cell) cell = PREFIX(_table_get_cell)(table, key);
(gdb)
class_table_internal_table_get_cell (table=0xa331e009540, key=0x7f7ffffc0090) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:338
338             uint32_t hash = MAP_TABLE_HASH_KEY(key);
(gdb)
string_hash (str=0x7f7ffffc0090 "GSBackend") at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/string_hash.h:10
10              uint32_t hash = 0;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb) print hash
$9 = 277150827
(gdb) list
9       {
10              uint32_t hash = 0;
11              int32_t c;
12              while ((c = *str++))
13              {
14                      hash = c + (hash << 6) + (hash << 16) - hash;
15              }
16              return hash;
17      }
18
(gdb) s
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
16              return hash;
(gdb) print hash
$10 = 4054769640
(gdb) s
class_table_internal_table_get_cell (table=0xa331e009540, key=0x7f7ffffc0090) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:339
339             PREFIX(_table_cell) cell = PREFIX(_table_lookup)(table, hash);
(gdb) print cell
$11 = (class_table_internal_table_cell) 0x7f7ffffbffe0
(gdb) list
334     }
335
336     static void *PREFIX(_table_get_cell)(PREFIX(_table) *table, const void *key)
337     {
338             uint32_t hash = MAP_TABLE_HASH_KEY(key);
339             PREFIX(_table_cell) cell = PREFIX(_table_lookup)(table, hash);
340             // Value does not exist.
341             if (!MAP_TABLE_VALUE_NULL(cell->value))
342             {
343                     if (MAP_TABLE_COMPARE_FUNCTION(key, cell->value))
(gdb)
344                     {
345                             return cell;
346                     }
347                     uint32_t jump = cell->secondMaps;
348                     // Look at each offset defined by the jump table to find the displaced location.
349                     for (int hop = __builtin_ffs(jump) ; hop > 0 ; hop = __builtin_ffs(jump))
350                     {
351                             PREFIX(_table_cell) hopCell = PREFIX(_table_lookup)(table, hash+hop);
352                             if (MAP_TABLE_COMPARE_FUNCTION(key, hopCell->value))
353                             {
(gdb) s
class_table_internal_table_lookup (table=0xa331e009540, hash=4054769640) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:219
219             hash = hash % TABLE_SIZE(table);
(gdb) lidz
Undefined command: "lidz".  Try "help".
(gdb) list
214     };
215
216     static inline PREFIX(_table_cell) PREFIX(_table_lookup)(PREFIX(_table) *table,
217                                                             uint32_t hash)
218     {
219             hash = hash % TABLE_SIZE(table);
220             return &table->table[hash];
221     }
222
223     static int PREFIX(_table_move_gap)(PREFIX(_table) *table, uint32_t fromHash,
(gdb) print table
$12 = (class_table_internal_table *) 0xa331e009540
(gdb) print hash
$13 = 4054769640
(gdb) print &table->table[hash]
$14 = (struct class_table_internal_table_cell_struct *) 0xa41d88dfe80
(gdb) print (struct class_table_internal_table_cell_struct *) &table->table[hash]
$15 = (struct class_table_internal_table_cell_struct *) 0xa41d88dfe80
(gdb) print (struct class_table_internal_table_cell_struct *) 0xa41d88dfe80
$16 = (struct class_table_internal_table_cell_struct *) 0xa41d88dfe80
(gdb) print (struct class_table_internal_table_cell_struct *) 0xa41d88dfe80
$17 = (struct class_table_internal_table_cell_struct *) 0xa41d88dfe80
(gdb) print 0xa41d88dfe80
$18 = 11277922336384
(gdb) print (struct class_table_internal_table_cell_struct ) 0xa41d88dfe80
Invalid cast.
(gdb) print (struct class_table_internal_table_cell_struct *) &0xa41d88dfe80
Attempt to take address of value not located in memory.
(gdb) print (struct class_table_internal_table_cell_struct *) *0xa41d88dfe80
Cannot access memory at address 0xa41d88dfe80
(gdb) print (struct class_table_internal_table_cell_struct *) ^CQuit88dfe80
(gdb) print table->table[hash]
Cannot access memory at address 0xa41d88dfe80
(gdb) print &table->table[hash]
$19 = (struct class_table_internal_table_cell_struct *) 0xa41d88dfe80
(gdb) s
220             return &table->table[hash];
(gdb) s
class_table_internal_table_get_cell (table=0xa331e009540, key=0x7f7ffffc0090) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:341
341             if (!MAP_TABLE_VALUE_NULL(cell->value))
(gdb) print cell
$20 = (class_table_internal_table_cell) 0xa32bda0fe80
(gdb) print cell->value
$21 = (void *) 0xa32a18f9620 <_OBJC_CLASS_IBConnectionRecord>
(gdb) s
class_table_internal_is_null (value=0xa32a18f9620 <_OBJC_CLASS_IBConnectionRecord>) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:77
77              return value == NULL;
(gdb) list
72      #endif
73      #ifndef MAP_TABLE_VALUE_TYPE
74      #       define MAP_TABLE_VALUE_TYPE void*
75      static BOOL PREFIX(_is_null)(void *value)
76      {
77              return value == NULL;
78      }
79      #       define MAP_TABLE_TYPES_BITMAP 1
80      #       define MAP_TABLE_VALUE_NULL PREFIX(_is_null)
81      #       define MAP_TABLE_VALUE_PLACEHOLDER NULL
(gdb) print value
$22 = (void *) 0xa32a18f9620 <_OBJC_CLASS_IBConnectionRecord>
(gdb) s
class_table_internal_table_get_cell (table=0xa331e009540, key=0x7f7ffffc0090) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:343
343                     if (MAP_TABLE_COMPARE_FUNCTION(key, cell->value))
(gdb) print key
$23 = (const void *) 0x7f7ffffc0090
(gdb) print cell->value
$24 = (void *) 0xa32a18f9620 <_OBJC_CLASS_IBConnectionRecord>
(gdb) s
class_compare (name=0x7f7ffffc0090 "GSBackend", class=0xa32a18f9620 <_OBJC_CLASS_IBConnectionRecord>)
    at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/class_table.c:71
71              return string_compare(name, class->name);
(gdb) print name
$25 = 0x7f7ffffc0090 "GSBackend"
(gdb) print class->name
$26 = 0xa32a0c84d0e "IBConnectionRecord"
(gdb) s
string_compare (str1=0x7f7ffffc0090 "GSBackend", str2=0xa32a0c84d0e "IBConnectionRecord")
    at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/string_hash.h:25
25              if (str1 == str2)
(gdb) list
20       * Test two strings for equality.
21       */
22      __attribute__((unused))
23      static int string_compare(const char *str1, const char *str2)
24      {
25              if (str1 == str2)
26              {
27                      return 1;
28              }
29              if (str1 == NULL || str2 == NULL)
(gdb) s
29              if (str1 == NULL || str2 == NULL)
(gdb)
33              return strcmp(str1, str2) == 0;
(gdb)
strcmp () at /usr/src/lib/libc/arch/amd64/string/strcmp.S:12
12              RETGUARD_SETUP(strcmp, r11)
(gdb) n
18              testb   $7,%dil
(gdb)
19              je      .Ls1aligned
(gdb)
35              testb   $7,%sil
(gdb)
36              jne     .Lbyte_loop
(gdb)
59              movb    (%rdi),%al
(gdb)
60              incq    %rdi
(gdb)
61              movb    (%rsi),%dl
(gdb)
62              incq    %rsi
(gdb)
63              testb   %al,%al
(gdb)
64              je      .Ldone
(gdb)
65              cmpb    %al,%dl
(gdb)
66              je      .Lbyte_loop
(gdb)
69              movzbq  %al,%rax
(gdb)
70              movzbq  %dl,%rdx
(gdb)
71              subq    %rdx,%rax
(gdb)
72              RETGUARD_CHECK(strcmp, r11)
(gdb)
strcmp () at /usr/src/lib/libc/arch/amd64/string/strcmp.S:73
73              ret
(gdb)
string_compare (str1=0x7f7ffffc0090 "GSBackend", str2=0xa32a0c84d0e "IBConnectionRecord")
    at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/string_hash.h:34
34      }
(gdb)
class_table_internal_table_get_cell (table=0xa331e009540, key=0x7f7ffffc0090) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:347
347                     uint32_t jump = cell->secondMaps;
(gdb) list
342             {
343                     if (MAP_TABLE_COMPARE_FUNCTION(key, cell->value))
344                     {
345                             return cell;
346                     }
347                     uint32_t jump = cell->secondMaps;
348                     // Look at each offset defined by the jump table to find the displaced location.
349                     for (int hop = __builtin_ffs(jump) ; hop > 0 ; hop = __builtin_ffs(jump))
350                     {
351                             PREFIX(_table_cell) hopCell = PREFIX(_table_lookup)(table, hash+hop);
(gdb) print jump
$27 = 2207597367
(gdb) s
349                     for (int hop = __builtin_ffs(jump) ; hop > 0 ; hop = __builtin_ffs(jump))
(gdb)
359             }
(gdb) print hop
No symbol "hop" in current context.
(gdb) n
361             if (table->old)
(gdb) list
356                             // Clear the most significant bit and try again.
357                             jump &= ~(1 << (hop-1));
358                     }
359             }
360     #ifndef MAP_TABLE_STATIC_SIZE
361             if (table->old)
362             {
363                     return PREFIX(_table_get_cell)(table->old, key);
364             }
365     #endif
(gdb) print table->old
$28 = (struct class_table_internal_table_struct *) 0x0
(gdb) n
366             return NULL;
(gdb)
367     }
(gdb) list
362             {
363                     return PREFIX(_table_get_cell)(table->old, key);
364             }
365     #endif
366             return NULL;
367     }
368
369     __attribute__((unused))
370     static void PREFIX(_table_move_second)(PREFIX(_table) *table,
371                     PREFIX(_table_cell) emptyCell)
(gdb) n
class_table_internal_table_get (table=0xa331e009540, key=0x7f7ffffc0090) at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/hash_table.h:419
419             if (NULL == cell)
(gdb) print cell
$29 = (class_table_internal_table_cell) 0x0
(gdb) n
424                     return MAP_TABLE_VALUE_PLACEHOLDER;
(gdb) list
419             if (NULL == cell)
420             {
421     #ifdef MAP_TABLE_ACCESS_BY_REFERENCE
422                     return NULL;
423     #else
424                     return MAP_TABLE_VALUE_PLACEHOLDER;
425     #endif
426             }
427     #ifdef MAP_TABLE_ACCESS_BY_REFERENCE
428             return &cell->value;
(gdb) print MAP_TABLE_VALUE_PLACEHOLDER
No symbol "MAP_TABLE_VALUE_PLACEHOLDER" in current context.
(gdb) n
432     }
(gdb)
class_table_get_safe (class_name=0x7f7ffffc0090 "GSBackend") at /home/ports/pobj/amd64/gnustep-libobjc2-1.8.1/libobjc2-1.8.1/class_table.c:133
133     }
(gdb) list
128
129     PRIVATE Class class_table_get_safe(const char *class_name)
130     {
131             if (NULL == class_name) { return Nil; }
132             return class_table_internal_table_get(class_table, class_name);
133     }
134
135     PRIVATE Class class_table_next(void **e)
136     {
137             return class_table_internal_next(class_table,
(gdb) s
NSClassFromString (aClassName=0xa32a1719fe0 <.objc_str.393>) at NSObjCRuntime.m:117
117         }
(gdb)
119     }
(gdb)
initialize_gnustep_backend () at NSApplication.m:322
322             NSCAssert1 (backend != Nil,


_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

David Chisnall-7
On 25 Nov 2018, at 18:30, Sebastian Reitenbach <[hidden email]> wrote:
>
> So, the thing is, when I replace all /usr/bin/ld* with the /usr/bin/ld.bfd, and rebuild everything,
> then GUI apps, as well as SOGo start up. But I can't do that when building packages :(

You can do that with -fuse-ld=bfd in LDFLAGS, but I agree it’s not the right solution.

The bugs that you’re seeing look as if they may be symptoms of the hash table bugs that I fixed in libobjc2 a month or two ago.  Can you check if they’re still there with the 1.9 release branch?

David


_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

Sebastian Reitenbach-2
Hi,
 
Am Sonntag, November 25, 2018 21:22 CET, David Chisnall <[hidden email]> schrieb:
 
> On 25 Nov 2018, at 18:30, Sebastian Reitenbach <[hidden email]> wrote:
> >
> > So, the thing is, when I replace all /usr/bin/ld* with the /usr/bin/ld.bfd, and rebuild everything,
> > then GUI apps, as well as SOGo start up. But I can't do that when building packages :(
>
> You can do that with -fuse-ld=bfd in LDFLAGS, but I agree it’s not the right solution.

This workaround is good for the time being getting things to work again.

>
> The bugs that you’re seeing look as if they may be symptoms of the hash table bugs that I fixed in libobjc2 a month or two ago.  Can you check if they’re still there with the 1.9 release branch?

Installing the 1.9 branch doesn't seem to help, the error persists. First when creating the package for the 1.9 branch, I got some
error when the ports infrastructued atempted to install it into the fake-root:

===>  Faking installation for gnustep-libobjc2-1.9.0
[0/1] cd /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/build-amd64 && /usr/local/bin/cmake -P cmake_install.cmake
-- Install configuration: "Release"
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/lib/libobjc2.so.1.1
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/lib/libobjc2.a
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/Availability.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/Object.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/Protocol.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/blocks_private.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/blocks_runtime.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/capabilities.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/developer.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/encoding.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/hooks.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/message.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/objc-api.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/objc-arc.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/objc-auto.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/objc-class.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/objc-runtime.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/objc.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/runtime-deprecated.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/runtime.h
-- Installing: /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/slot.h
failed to create symbolic link 'include/Block.h': No such file or directory
-- Symlinking: include/Block.h -> include/gnustep/objc/blocks_runtime.h
failed to create symbolic link 'include/Block_private.h': No such file or directory
-- Symlinking: include/Block_private.h -> include/gnustep/objc/blocks_private.h
sebastia@communicator:/home/ports/x11/gnustep/libobjc2> find /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0 -name Block.h                    
sebastia@communicator:/home/ports/x11/gnustep/libobjc2> find /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0 -name blocks_runtime.h
/home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/blocks_runtime.h
/home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/objc/blocks_runtime.h
/home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/fake-amd64/usr/local/include/gnustep/objc/blocks_runtime.h

In order to get me going, I created this symlink, and the Block_private.h symlink manually, and commented out the two
lines creating the symlinks from the CMakeLists.txt file.
With that manual editing I got the 1.9 branch installed, and rebuilt all the rest of GNUstep.

However, the problem is still there, see new stepping through gdb at the end.
Let me know if there is any more info I can provide, or if there is something else I should test.

thanks,
Sebastian


sebastia@communicator:/tmp> egdb /usr/local/bin/GMines                                                                                                                          
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-openbsd6.4".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/GMines...done.
(gdb) r
Starting program: /usr/local/bin/GMines

Program received signal SIGFPE, Arithmetic exception.
0x00000527770d024c in _dl_find_symbol_obj (obj=0x52722e05c00, sl=0x7f7fffff5108) at /usr/src/libexec/ld.so/resolve.c:584
584             for (si = obj->buckets[sl->sl_elf_hash % obj->nbuckets];
(gdb) bt    
#0  0x00000527770d024c in _dl_find_symbol_obj (obj=0x52722e05c00, sl=0x7f7fffff5108) at /usr/src/libexec/ld.so/resolve.c:584
#1  0x00000527770d0068 in _dl_find_symbol (name=0x526ae984ea5 "getpid", this=0x7f7fffff51a8, flags=48, ref_sym=0x526ae9194c8, req_obj=<optimized out>, pobj=0x7f7fffff51a0)
    at /usr/src/libexec/ld.so/resolve.c:663
#2  0x00000527770cef1a in _dl_bind (object=0x526d8585800, index=<optimized out>) at /usr/src/libexec/ld.so/amd64/rtld_machine.c:357
#3  0x00000527770d0fed in _dl_bind_start () at /usr/src/libexec/ld.so/amd64/ldasm.S:108
#4  0x00000526aedbe4d4 in NSLogv (format=0x526be50df08, args=0x7f7fffff54f0) at NSLog.m:350
#5  0x00000526aecc6d05 in -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] (self=0x526cc013ef8, _cmd=0x52731dc3a18 <.objc_selector_list+1984>,
    functionName=0x52737e9bc88, fileName=0x5271bbe0988, line=323, format=0x52731dc10e8 <.objc_str.404>) at NSAssertionHandler.m:101
#6  0x0000052731a32c57 in initialize_gnustep_backend () at NSApplication.m:322
#7  0x0000052731a3522b in -[NSApplication _init] (self=0x5270bc8e308, _cmd=0x52731dc3558 <.objc_selector_list+768>) at NSApplication.m:878
#8  0x00000526aede1522 in -[NSObject performSelector:withObject:] (self=0x5270bc8e308, _cmd=0x526af008360 <.objc_selector_list>,
    aSelector=0x52731dc3558 <.objc_selector_list+768>, anObject=0x5270bc8e308) at NSObject.m:2000
#9  0x00000526aee7773a in -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] (self=0x5270bc8e308,
    _cmd=0x526af0085c0 <.objc_selector_list+608>, aSelector=0x52731dc3558 <.objc_selector_list+768>, aThread=0x5269ef8eb08, anObject=0x5270bc8e308, aFlag=1 '\001',
    anArray=0x52754df30c8) at NSThread.m:1672
#10 0x00000526aee773f3 in -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:modes:] (self=0x5270bc8e308,
    _cmd=0x526af008600 <.objc_selector_list+672>, aSelector=0x52731dc3558 <.objc_selector_list+768>, anObject=0x5270bc8e308, aFlag=1 '\001', anArray=0x52754df30c8)
    at NSThread.m:1627
#11 0x00000526aee7748e in -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] (self=0x5270bc8e308,
    _cmd=0x52731dc3358 <.objc_selector_list+256>, aSelector=0x52731dc3558 <.objc_selector_list+768>, anObject=0x5270bc8e308, aFlag=1 '\001') at NSThread.m:1638
#12 0x0000052731a35995 in -[NSApplication init] (self=0x5270bc8e308, _cmd=0x52731dc3b78 <.objc_selector_list+2336>) at NSApplication.m:978
#13 0x0000052731a3519d in +[NSApplication sharedApplication] (self=0x52731dc28b8 <_OBJC_CLASS_NSApplication>, _cmd=0x524923ff1d8 <.objc_selector_list+16>) at NSApplication.m:850
#14 0x00000524923f1fc2 in gnustep_base_user_main (argc=1, argv=0x7f7fffff5b78, env=0x7f7fffff5b88) at main.m:44
#15 0x00000526aee152f7 in main (argc=1, argv=0x7f7fffff5b78, env=0x7f7fffff5b88) at NSProcessInfo.m:1002
#16 0x00000524923ee056 in ___start ()
#17 0x0000000000000000 in ?? ()
(gdb) fram 6
#6  0x0000052731a32c57 in initialize_gnustep_backend () at NSApplication.m:322
322             NSCAssert1 (backend != Nil,
(gdb) list
317                         path);
318            
319             /* Now get the GSBackend class, which should have just been loaded
320              * from the bundle.  */
321             backend = NSClassFromString (@"GSBackend");
322             NSCAssert1 (backend != Nil,
323               _(@"Backend at path %@ doesn't contain the GSBackend class"), path);
324             [backend initializeBackend];
325           }
326    
(gdb) break NSApplication.m:321
Breakpoint 1 at 0x52731a32b2e: file NSApplication.m, line 321.
(gdb) c
Continuing.

Program terminated with signal SIGFPE, Arithmetic exception.
The program no longer exists.
(gdb) r
Starting program: /usr/local/bin/GMines

Breakpoint 1, initialize_gnustep_backend () at NSApplication.m:321
321             backend = NSClassFromString (@"GSBackend");
(gdb) s
NSClassFromString (aClassName=0xe3b0ee55008) at NSObjCRuntime.m:107
107     {
(gdb)
108       if (aClassName != nil)
(gdb)
110           int       len = [aClassName length];
(gdb)
111           char      buf[len+1];
(gdb)
113           [aClassName getCString: buf
(gdb)
114                        maxLength: len + 1
(gdb)
113           [aClassName getCString: buf
(gdb)
116           return objc_lookUpClass (buf);
(gdb)
objc_lookUpClass (name=0xde02e335da7ed992 <error: Cannot access memory at address 0xde02e335da7ed992>)
    at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/class_table.c:530
530     {
(gdb) s
531             return (id)class_table_get_safe(name);
(gdb)
class_table_get_safe (class_name=0xe3aadc5663f <objc_lookUpClass+31> "H\203\304\bA[]L3\034$L;\035\237\354\001")
    at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/class_table.c:130
130     {
(gdb) list
125             }
126             class_table_internal_insert(class_table, class);
127     }
128    
129     PRIVATE Class class_table_get_safe(const char *class_name)
130     {
131             if (NULL == class_name) { return Nil; }
132             return class_table_internal_table_get(class_table, class_name);
133     }
134    
(gdb) s
131             if (NULL == class_name) { return Nil; }
(gdb)
132             return class_table_internal_table_get(class_table, class_name);
(gdb)
class_table_internal_table_get (table=0x7f7ffffe4ff0, key=0xa) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/hash_table.h:434
434     {
(gdb)
435             PREFIX(_table_cell) cell = PREFIX(_table_get_cell)(table, key);
(gdb)
class_table_internal_table_get_cell (table=0xe3b21ef2b80, key=0x7f7ffffe4ff0) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/hash_table.h:337
337     {
(gdb)
338             uint32_t hash = MAP_TABLE_HASH_KEY(key);
(gdb)
string_hash (str=0x7f7ffffe4fe0 "`P\376\377\177\177") at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/string_hash.h:9
9       {
(gdb)
10              uint32_t hash = 0;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
14                      hash = c + (hash << 6) + (hash << 16) - hash;
(gdb)
12              while ((c = *str++))
(gdb)
16              return hash;
(gdb)
class_table_internal_table_get_cell (table=0xe3b21ef2b80, key=0x7f7ffffe4ff0) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/hash_table.h:339
339             PREFIX(_table_cell) cell = PREFIX(_table_lookup)(table, hash);
(gdb) print hash
$1 = 4054769640
(gdb) print table
$2 = (class_table_internal_table *) 0xe3b21ef2b80
(gdb)
$3 = (class_table_internal_table *) 0xe3b21ef2b80
(gdb) s
class_table_internal_table_lookup (table=0x7f7ffffe4fe0, hash=3643) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/hash_table.h:218
218     {
(gdb)
219             hash = hash % TABLE_SIZE(table);
(gdb)
220             return &table->table[hash];
(gdb) print &table->table[hash]
$4 = (struct class_table_internal_table_cell_struct *) 0xe3b5cce3e80
(gdb) print table->table[hash]
$5 = {secondMaps = 0, value = 0xe3b5265a620 <_OBJC_CLASS_IBConnectionRecord>}
(gdb) s
class_table_internal_table_get_cell (table=0xe3b21ef2b80, key=0x7f7ffffe4ff0) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/hash_table.h:341
341             if (!MAP_TABLE_VALUE_NULL(cell->value))
(gdb) print cell->value
$6 = (void *) 0xe3b5265a620 <_OBJC_CLASS_IBConnectionRecord>
(gdb) s
class_table_internal_is_null (value=0x7f7ffffe4fe0) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/hash_table.h:76
76      {
(gdb)
77              return value == NULL;
(gdb)
class_table_internal_table_get_cell (table=0xe3b21ef2b80, key=0x7f7ffffe4ff0) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/hash_table.h:343
343                     if (MAP_TABLE_COMPARE_FUNCTION(key, cell->value))
(gdb) print key
$7 = (const void *) 0x7f7ffffe4ff0
(gdb) print (char *) key
$8 = 0x7f7ffffe4ff0 "GSBackend"
(gdb) print cell->value
$9 = (void *) 0xe3b5265a620 <_OBJC_CLASS_IBConnectionRecord>
(gdb) s
class_compare (name=0x7f7ffffe4fe0 "`P\376\377\177\177", class=0xe3b21ef2b80) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/class_table.c:70
70      {
(gdb)
71              return string_compare(name, class->name);
(gdb) print name
$10 = 0x7f7ffffe4ff0 "GSBackend"
(gdb) print class->name
$11 = 0xe3b519e5d0e "IBConnectionRecord"
(gdb) s
string_compare (str1=0xe3b5265a620 <_OBJC_CLASS_IBConnectionRecord> "\220\245eR;\016", str2=0xe3b75f04e10 <str_encoding_table> "\001")
    at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/string_hash.h:24
24      {
(gdb)
25              if (str1 == str2)
(gdb)
29              if (str1 == NULL || str2 == NULL)
(gdb)
33              return strcmp(str1, str2) == 0;
(gdb)
strcmp () at /usr/src/lib/libc/arch/amd64/string/strcmp.S:12
12              RETGUARD_SETUP(strcmp, r11)
(gdb) print str1
No symbol "str1" in current context.
(gdb)
No symbol "str1" in current context.
(gdb)
No symbol "str1" in current context.
(gdb) s
18              testb   $7,%dil
(gdb)
19              je      .Ls1aligned
(gdb)
35              testb   $7,%sil
(gdb)
36              jne     .Lbyte_loop
(gdb)
59              movb    (%rdi),%al
(gdb)
60              incq    %rdi
(gdb)
61              movb    (%rsi),%dl
(gdb)
62              incq    %rsi
(gdb)
63              testb   %al,%al
(gdb)
64              je      .Ldone
(gdb)
65              cmpb    %al,%dl
(gdb)
66              je      .Lbyte_loop
(gdb)
69              movzbq  %al,%rax
(gdb)
70              movzbq  %dl,%rdx
(gdb)
71              subq    %rdx,%rax
(gdb)
72              RETGUARD_CHECK(strcmp, r11)
(gdb)
strcmp () at /usr/src/lib/libc/arch/amd64/string/strcmp.S:73
73              ret
(gdb)
string_compare (str1=0x7f7ffffe4ff0 "GSBackend", str2=0xe3b519e5d0e "IBConnectionRecord") at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/string_hash.h:34
34      }
(gdb)
class_table_internal_table_get_cell (table=0xe3b21ef2b80, key=0x7f7ffffe4ff0) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/hash_table.h:347
347                     uint32_t jump = cell->secondMaps;
(gdb)
349                     for (int hop = __builtin_ffs(jump) ; hop > 0 ; hop = __builtin_ffs(jump))
(gdb)
359             }
(gdb) print hop
No symbol "hop" in current context.
(gdb)
No symbol "hop" in current context.
(gdb)
No symbol "hop" in current context.
(gdb) s
361             if (table->old)
(gdb)
366             return NULL;
(gdb)
367     }
(gdb)
class_table_internal_table_get (table=0xe3b21ef2b80, key=0x7f7ffffe4ff0) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/hash_table.h:436
436             if (NULL == cell)
(gdb) print cell
$12 = (class_table_internal_table_cell) 0x0
(gdb)
$13 = (class_table_internal_table_cell) 0x0
(gdb) s
441                     return MAP_TABLE_VALUE_PLACEHOLDER;
(gdb)
449     }
(gdb)
class_table_get_safe (class_name=0x7f7ffffe4ff0 "GSBackend") at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/class_table.c:133
133     }
(gdb)
NSClassFromString (aClassName=0xe3b5247afe0 <.objc_str.393>) at NSObjCRuntime.m:117
117         }
(gdb)
119     }
(gdb)
initialize_gnustep_backend () at NSApplication.m:322
322             NSCAssert1 (backend != Nil,
(gdb)


_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

David Chisnall-8
On 26/11/2018 08:47, Sebastian Reitenbach wrote:
> Program received signal SIGFPE, Arithmetic exception.
> 0x00000527770d024c in _dl_find_symbol_obj (obj=0x52722e05c00, sl=0x7f7fffff5108) at /usr/src/libexec/ld.so/resolve.c:584
> 584             for (si = obj->buckets[sl->sl_elf_hash % obj->nbuckets];
> (gdb) bt
> #0  0x00000527770d024c in _dl_find_symbol_obj (obj=0x52722e05c00, sl=0x7f7fffff5108) at /usr/src/libexec/ld.so/resolve.c:584
> #1  0x00000527770d0068 in _dl_find_symbol (name=0x526ae984ea5 "getpid", this=0x7f7fffff51a8, flags=48, ref_sym=0x526ae9194c8, req_obj=<optimized out>, pobj=0x7f7fffff51a0)
>      at /usr/src/libexec/ld.so/resolve.c:663
> #2  0x00000527770cef1a in _dl_bind (object=0x526d8585800, index=<optimized out>) at /usr/src/libexec/ld.so/amd64/rtld_machine.c:357
> #3  0x00000527770d0fed in _dl_bind_start () at /usr/src/libexec/ld.so/amd64/ldasm.S:108

The top bit of this backtrace makes me slightly suspicious.  It looks as
if we're seeing memory corruption.  I can think of two plausible causes
of this:

1. Something in GNUstep is corrupting some heap state and this happens
to be hitting something in OpenBSD's run-time linker.  Given OpenBSD's
aggressive ASLR, this doesn't seem very likely to happen deterministically.
2. lld is generating something in the object file that is not supported
by OpenBSD's run-time linker.  This seems more likely, because
Objective-C tends to use a few bits of ELF that aren't as widely used by
C/C++ and may not be well-tested code paths in OpenBSD's linker.

Did the dlopen of the back end definitely succeed?  Did it call
__objc_exec_class correctly (or __objc_load if you're using the v2 ABI)?

David

_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

Sebastian Reitenbach-2
Am Montag, November 26, 2018 12:22 CET, David Chisnall <gnustep=@theravensnest.org> schrieb:
 

> On 26/11/2018 08:47, Sebastian Reitenbach wrote:
> > Program received signal SIGFPE, Arithmetic exception.
> > 0x00000527770d024c in _dl_find_symbol_obj (obj=0x52722e05c00, sl=0x7f7fffff5108) at /usr/src/libexec/ld.so/resolve.c:584
> > 584             for (si = obj->buckets[sl->sl_elf_hash % obj->nbuckets];
> > (gdb) bt
> > #0  0x00000527770d024c in _dl_find_symbol_obj (obj=0x52722e05c00, sl=0x7f7fffff5108) at /usr/src/libexec/ld.so/resolve.c:584
> > #1  0x00000527770d0068 in _dl_find_symbol (name=0x526ae984ea5 "getpid", this=0x7f7fffff51a8, flags=48, ref_sym=0x526ae9194c8, req_obj=<optimized out>, pobj=0x7f7fffff51a0)
> >      at /usr/src/libexec/ld.so/resolve.c:663
> > #2  0x00000527770cef1a in _dl_bind (object=0x526d8585800, index=<optimized out>) at /usr/src/libexec/ld.so/amd64/rtld_machine.c:357
> > #3  0x00000527770d0fed in _dl_bind_start () at /usr/src/libexec/ld.so/amd64/ldasm.S:108
>
> The top bit of this backtrace makes me slightly suspicious.  It looks as
> if we're seeing memory corruption.  I can think of two plausible causes
> of this:
>
> 1. Something in GNUstep is corrupting some heap state and this happens
> to be hitting something in OpenBSD's run-time linker.  Given OpenBSD's
> aggressive ASLR, this doesn't seem very likely to happen deterministically.
> 2. lld is generating something in the object file that is not supported
> by OpenBSD's run-time linker.  This seems more likely, because
> Objective-C tends to use a few bits of ELF that aren't as widely used by
> C/C++ and may not be well-tested code paths in OpenBSD's linker.
>
> Did the dlopen of the back end definitely succeed?  Did it call
> __objc_exec_class correctly (or __objc_load if you're using the v2 ABI)?

I did hit the
Breakpoint 1, __objc_exec_class (module=0x8f61a4aa800) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/loader.c:47

functions I think maybe a hundred of times, so, not sure which of these really is the culprit, since there are soo many hits,
I haven't yet managed to get to the last one and step through it.

However, from where the problem come from is  in -guis NSApplication.m:



BOOL
initialize_gnustep_backend(void)
{
  static int first = 1;

  if (first)
    {
      Class backend;

      /*
      Remember which thread we are running in. This thread will be the
      -gui thread, ie. the only thread that may do any rendering. With
      the exception of a few methods explicitly marked as thread-safe,
      other threads should not call any methods in -gui.
      */
      GSAppKitThread = [NSThread currentThread];

      first = 0;
#ifdef BACKEND_BUNDLE
      {
        NSBundle *theBundle;
        NSString *path, *bundleName;
        NSUserDefaults  *defs = [NSUserDefaults standardUserDefaults];

        /* What backend ? */
        bundleName = [defs stringForKey: @"GSBackend"];
        path = gnustep_backend_framework (bundleName);
        if (path == nil)
          {
            NSDebugLLog(@"BackendBundle", @"Did not find backend framework.");
            path = gnustep_backend_bundle (bundleName);
          }

        /* FIXME/TODO - update localized error messages.  */

        /* Backend found ? */
        if (bundleName == nil)
          bundleName = @"back";
        NSCAssert1(path != nil, _(@"Unable to find backend %@"), bundleName);
        NSDebugLog(@"Loading Backend from %@", path);
        NSDebugFLLog(@"BackendBundle", @"Loading Backend from %@", path);

        /* Create a bundle object.  (Should normally succeed).  */
        theBundle = [NSBundle bundleWithPath: path];
        NSCAssert1(theBundle != nil,
                   _(@"Can't create NSBundle object for backend at path %@"),
                   path);

        /* Now load the object file from the bundle.  */
        NSCAssert1 ([theBundle load],
                    _(@"Can't load object file from backend at path %@"),
                    path);

        /* Now get the GSBackend class, which should have just been loaded
         * from the bundle.  */
        backend = NSClassFromString (@"GSBackend");
        NSCAssert1 (backend != Nil,
          _(@"Backend at path %@ doesn't contain the GSBackend class"), path);
        [backend initializeBackend];
      }

#else
      /* GSBackend will be in a separate library linked in with the app.
       This would be cleaner with ...classNamed: @"GSBackend", but that
       doesn't work in some cases (Mac OS X for instance).  */
      [GSBackend initializeBackend];
#endif
    }
  return YES;
}

From the stacktrace, It's the last NSCAssert1 that fires, right after that line:
backend = NSClassFromString (@"GSBackend");

So before that, there's the other NSCAssert1, [theBundle load], and since
this doesn't fire, I think loading it, went OK?
But I might well be on the wrong track.

Sebastian


>
> David


_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

David Chisnall-7
On 26/11/2018 15:03, Sebastian Reitenbach wrote:
>  From the stacktrace, It's the last NSCAssert1 that fires, right after that line:
> backend = NSClassFromString (@"GSBackend");

Yup.  That makes me think either:

- The dlopen failed.
- The dlopen returned success, but didn't call the constructor, so it
didn't call __objc_exec_class.
- The library was loaded but some memory was corrupted.

> So before that, there's the other NSCAssert1, [theBundle load], and since
> this doesn't fire, I think loading it, went OK?
> But I might well be on the wrong track.

Can you disable the breakpoint on __objc_exec_class until just before
the [theBundle load] line, then enable it and make sure that it's called
*after* the dlopen call?  Can you also check in the code that we're
actually checking the return from dlopen correctly (I'm pretty sure we are).

If all this works, can you check in each __objc_exec_class call and see
if one of the classes that it loads is called GSBackend?  If so, then it
looks as if there's still something wrong with the hash table in
libobjc2.  I think I back-ported all of the fixes to the 1.9 branch, but
I might have missed one...

David

_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

Sebastian Reitenbach-2
Am Montag, November 26, 2018 16:14 CET, David Chisnall <[hidden email]> schrieb:
 

> On 26/11/2018 15:03, Sebastian Reitenbach wrote:
> >  From the stacktrace, It's the last NSCAssert1 that fires, right after that line:
> > backend = NSClassFromString (@"GSBackend");
>
> Yup.  That makes me think either:
>
> - The dlopen failed.
> - The dlopen returned success, but didn't call the constructor, so it
> didn't call __objc_exec_class.
> - The library was loaded but some memory was corrupted.
>
> > So before that, there's the other NSCAssert1, [theBundle load], and since
> > this doesn't fire, I think loading it, went OK?
> > But I might well be on the wrong track.
>
> Can you disable the breakpoint on __objc_exec_class until just before
> the [theBundle load] line, then enable it and make sure that it's called
> *after* the dlopen call?  Can you also check in the code that we're
> actually checking the return from dlopen correctly (I'm pretty sure we are).
>
> If all this works, can you check in each __objc_exec_class call and see
> if one of the classes that it loads is called GSBackend?  If so, then it
> looks as if there's still something wrong with the hash table in
> libobjc2.  I think I back-ported all of the fixes to the 1.9 branch, but
> I might have missed one...
>
> David
 
 I think I finally found where the dlopen() is called, in gnustep base
dynamic-load.h (which is generated while building it, took me a while
to find that ;)

From what I can see, things look good as it successfully dlopens
the gnustep-back backend file, but then it never calls __objc_exec_class??

Sebastian

Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (NSApplication.m:309) pending.
(gdb) break NSBundle.m:1989
No source file named NSBundle.m.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (NSBundle.m:1989) pending.
(gdb) break dynamic-load.h:63
No source file named dynamic-load.h.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 3 (dynamic-load.h:63) pending.
(gdb) r
Starting program: /usr/local/bin/GMines

Breakpoint 1, initialize_gnustep_backend () at NSApplication.m:309
309             theBundle = [NSBundle bundleWithPath: path];
(gdb) c
Continuing.

Breakpoint 2, -[NSBundle load] (self=0xda79dff5e08, _cmd=0xda79dff5608) at NSBundle.m:1989
1989    - (BOOL) load
(gdb) c
Continuing.

Breakpoint 3, __objc_dynamic_link (module=0xda7dfb59148 "8*\033k\250\r", mode=3496,
    debug_file=0xda83944f8e0 <__sF+304> "") at ././dynamic-load.h:64
warning: Source file is more recent than executable.
64      {
(gdb) list
59      /* Link in the module given by the name 'module'.  Return a handle which can
60         be used to get information about the loded code.
61      */
62      static dl_handle_t
63      __objc_dynamic_link(const char* module, int mode, const char* debug_file)
64      {
65      #ifdef RTLD_NOLOAD
66              /*
67               * If we've got RTLD_NOLOAD, then ask the dynamic linker first to check if
68               * the library is already loaded.  If it is, then just return a handle to
(gdb) n
77          return (dl_handle_t)dlopen(module, RTLD_LAZY | RTLD_GLOBAL);
(gdb) print module
$1 = 0xda79dff5390 "/usr/local/lib/GNUstep/Bundles/libgnustep-back-026.bundle/libgnustep-back-026"
(gdb) s
GSPrivateLoadModule (filename=0xda82c10fd08, errorStream=0xda83944f8e0 <__sF+304>,
    loadCallback=0xda86af147c0 <_bundle_load_callback>, header=0x0, debugFilename=0x0) at objc-load.m:173
173       if (handle == 0)
(gdb) list
168    
169       /* Link in the object file */
170       NSDebugFLLog(@"NSBundle", @"Debug (objc-load): Linking file %@\n", filename);
171       handle = __objc_dynamic_link((FSCHAR*)[filename fileSystemRepresentation],
172         1, (FSCHAR*)[debugFilename fileSystemRepresentation]);
173       if (handle == 0)
174         {
175           if (errorStream)
176             {
177               __objc_dynamic_error(errorStream, "Error (objc-load)");
(gdb) print handle
$2 = (dl_handle_t) 0xda7eddb7000
(gdb)(gdb) break loader.c:46
Breakpoint 4 at 0xda836645ae0: file /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/loader.c, line 46.
(gdb) c
Continuing.

Program received signal SIGFPE, Arithmetic exception.
0x00000da7b5b0a24c in _dl_find_symbol_obj (obj=0xda7eddb7000, sl=0x7f7ffffc5678)
    at /usr/src/libexec/ld.so/resolve.c:584
584             for (si = obj->buckets[sl->sl_elf_hash % obj->nbuckets];


_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

David Chisnall-7
On 26/11/2018 20:40, Sebastian Reitenbach wrote:
>   I think I finally found where the dlopen() is called, in gnustep base
> dynamic-load.h (which is generated while building it, took me a while
> to find that ;)
>
>  From what I can see, things look good as it successfully dlopens
> the gnustep-back backend file, but then it never calls __objc_exec_class??

I can't tell for sure from your debugging log, but it looks as if you
don't have a breakpoint set on __objc_exec_class when you step over the
dlopen call.  You won't be able to step into dlopen (unless you want to
recompile rtld with debug info, but I wouldn't recommend that), so you
need to make sure that you set the breakpoint before you let the process
call dlopen.  You can then step into the __objc_exec_class calls and see
if it's actually loading things correctly.

David

_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

Matt Rice-2
In reply to this post by David Chisnall-7
On Mon, Nov 26, 2018 at 7:18 AM David Chisnall
<[hidden email]> wrote:

>
> On 26/11/2018 15:03, Sebastian Reitenbach wrote:
> >  From the stacktrace, It's the last NSCAssert1 that fires, right after that line:
> > backend = NSClassFromString (@"GSBackend");
>
> Yup.  That makes me think either:
>
> - The dlopen failed.
> - The dlopen returned success, but didn't call the constructor, so it
> didn't call __objc_exec_class.
> - The library was loaded but some memory was corrupted.

ISTR constructor call order is undefined, and openbsd (has/had) a
called constructors in an order which was
reversed from the order that glibc calls them, so possibly
a) openbsd changed their order,
b) something was added which relies upon the order of calls happening
in the glibc order

could cause the second? i.e. the constructor would eventually be
called, but hasn't been called yet.

> > So before that, there's the other NSCAssert1, [theBundle load], and since
> > this doesn't fire, I think loading it, went OK?
> > But I might well be on the wrong track.
>
> Can you disable the breakpoint on __objc_exec_class until just before
> the [theBundle load] line, then enable it and make sure that it's called
> *after* the dlopen call?  Can you also check in the code that we're
> actually checking the return from dlopen correctly (I'm pretty sure we are).
>
> If all this works, can you check in each __objc_exec_class call and see
> if one of the classes that it loads is called GSBackend?  If so, then it
> looks as if there's still something wrong with the hash table in
> libobjc2.  I think I back-ported all of the fixes to the 1.9 branch, but
> I might have missed one...
>
> David
>
> _______________________________________________
> Discuss-gnustep mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep

_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

Sebastian Reitenbach-2
In reply to this post by David Chisnall-7
Am Dienstag, November 27, 2018 11:02 CET, David Chisnall <[hidden email]> schrieb:
 

> On 26/11/2018 20:40, Sebastian Reitenbach wrote:
> >   I think I finally found where the dlopen() is called, in gnustep base
> > dynamic-load.h (which is generated while building it, took me a while
> > to find that ;)
> >
> >  From what I can see, things look good as it successfully dlopens
> > the gnustep-back backend file, but then it never calls __objc_exec_class??
>
> I can't tell for sure from your debugging log, but it looks as if you
> don't have a breakpoint set on __objc_exec_class when you step over the
> dlopen call.  You won't be able to step into dlopen (unless you want to
> recompile rtld with debug info, but I wouldn't recommend that), so you
> need to make sure that you set the breakpoint before you let the process
> call dlopen.  You can then step into the __objc_exec_class calls and see
> if it's actually loading things correctly.

Sorry, my update to fix gnustep on openbsd broke some other shit's that I had
to fix first ;)
Now back here:

(gdb) bt
#0  initialize_gnustep_backend () at NSApplication.m:309
#1  0x0000093f1dcb033b in -[NSApplication _init] (self=0x93ecbd3a008, _cmd=0x93f1e03eef8 <.objc_selector_list+3232>) at NSApplication.m:878
#2  0x0000093ec2a28428 in -[NSObject performSelector:withObject:] (self=0x93ecbd3a008, _cmd=0x93ec2c4f460 <.objc_selector_list+256>,
    aSelector=0x93f1e03eef8 <.objc_selector_list+3232>, anObject=0x93ecbd3a008) at NSObject.m:2000
#3  0x0000093ec2abe4f3 in -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] (self=0x93ecbd3a008,
    _cmd=0x93ec2c4f5e0 <.objc_selector_list+640>, aSelector=0x93f1e03eef8 <.objc_selector_list+3232>, aThread=0x93ecbd3ae08, anObject=0x93ecbd3a008, aFlag=1 '\001',
    anArray=0x93f1b8f3dc8) at NSThread.m:1672
#4  0x0000093ec2abe1a0 in -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:modes:] (self=0x93ecbd3a008,
    _cmd=0x93ec2c4f600 <.objc_selector_list+672>, aSelector=0x93f1e03eef8 <.objc_selector_list+3232>, anObject=0x93ecbd3a008, aFlag=1 '\001', anArray=0x93f1b8f3dc8)
    at NSThread.m:1627
#5  0x0000093ec2abe23e in -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] (self=0x93ecbd3a008,
    _cmd=0x93f1e03f088 <.objc_selector_list+3632>, aSelector=0x93f1e03eef8 <.objc_selector_list+3232>, anObject=0x93ecbd3a008, aFlag=1 '\001') at NSThread.m:1638
#6  0x0000093f1dcb0aa5 in -[NSApplication init] (self=0x93ecbd3a008, _cmd=0x93f1e03f748 <.objc_selector_list+5360>) at NSApplication.m:978
#7  0x0000093f1dcb02ad in +[NSApplication sharedApplication] (self=0x93f1e03d8b8 <_OBJC_CLASS_NSApplication>, _cmd=0x93c629652b8 <.objc_selector_list+240>)
    at NSApplication.m:850
#8  0x0000093c62957f95 in gnustep_base_user_main (argc=1, argv=0x7f7ffffd3e68, env=0x7f7ffffd3e78) at main.m:44
#9  0x0000093ec2a5c017 in main (argc=1, argv=0x7f7ffffd3e68, env=0x7f7ffffd3e78) at NSProcessInfo.m:1002
#10 0x0000093c62954056 in ___start ()
#11 0x0000000000000000 in ?? ()
(gdb) info break
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000093f1dcad9a2 in initialize_gnustep_backend at NSApplication.m:309
        breakpoint already hit 1 time
2       breakpoint     keep y   0x0000093ec291a170 in -[NSBundle load] at NSBundle.m:1989
3       breakpoint     keep y   0x0000093ec2b2a750 in __objc_dynamic_link at ././dynamic-load.h:63
4       breakpoint     keep y   0x0000093ec2b2a750 in __objc_dynamic_link at ././dynamic-load.h:63
5       breakpoint     keep y   0x0000093e64843ae0 in __objc_exec_class at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/loader.c:46
(gdb) delete 4
(gdb) info break
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000093f1dcad9a2 in initialize_gnustep_backend at NSApplication.m:309
        breakpoint already hit 1 time
2       breakpoint     keep y   0x0000093ec291a170 in -[NSBundle load] at NSBundle.m:1989
3       breakpoint     keep y   0x0000093ec2b2a750 in __objc_dynamic_link at ././dynamic-load.h:63
5       breakpoint     keep y   0x0000093e64843ae0 in __objc_exec_class at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/loader.c:46
(gdb) c
Continuing.

Breakpoint 2, -[NSBundle load] (self=0x93e9baac588, _cmd=0x93e69deea88) at NSBundle.m:1989
1989    - (BOOL) load
(gdb)
Continuing.

Breakpoint 3, __objc_dynamic_link (module=0x93f0c45f248 "8\212\273\302>\t", mode=2366, debug_file=0x93f3d9fa8e0 <__sF+304> "") at ././dynamic-load.h:64
warning: Source file is more recent than executable.
64      {
(gdb)
Continuing.

Program received signal SIGFPE, Arithmetic exception.
0x0000093e70b4124c in _dl_find_symbol_obj (obj=0x93ecb3bbc00, sl=0x7f7ffffd33f8) at /usr/src/libexec/ld.so/resolve.c:584
584             for (si = obj->buckets[sl->sl_elf_hash % obj->nbuckets];

So I stopped at NSApplication.m:309, and then added the breakpoints in dynamic-load.h and in libobjc loader.c where the __objc_exec_class resides, and then continued to execute, but it doesn't hit the breakpoint 5 before throwing the FPE.

But when I set breakpoint on __objc_exec_class and restart the program from the beginning, I see it gets hit quite often, when I hit it, backtrace looks like:
Breakpoint 5, __objc_exec_class (module=0x81) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/loader.c:47
47      {
(gdb) bt
#0  __objc_exec_class (module=0x81) at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/loader.c:47
#1  0x00000cc580676f8f in .objc_load_function () from /usr/local/lib/libobjc2.so.1.1
#2  0x00000cc5806570d3 in _do_init () from /usr/local/lib/libobjc2.so.1.1
#3  0x00000cc5806779e9 in _init () from /usr/local/lib/libobjc2.so.1.1
#4  0x00007f7ffffea060 in ?? ()
#5  0x00000cc5eccab0c3 in _dl_call_init_recurse (object=0xcc579983400, initfirst=0) at /usr/src/libexec/ld.so/loader.c:770
#6  0x00000cc5eccab056 in _dl_call_init_recurse (object=0xcc5b2205c00, initfirst=0) at /usr/src/libexec/ld.so/loader.c:756
#7  0x00000cc5eccab056 in _dl_call_init_recurse (object=0xcc5b5534400, initfirst=0) at /usr/src/libexec/ld.so/loader.c:756
#8  0x00000cc5eccab056 in _dl_call_init_recurse (object=0xcc5b5534c00, initfirst=0) at /usr/src/libexec/ld.so/loader.c:756
#9  0x00000cc5eccaaaf1 in _dl_call_init (object=0xcc5b5534c00) at /usr/src/libexec/ld.so/loader.c:743
#10 _dl_boot (argv=0x7f7ffffea228, envp=<optimized out>, dyn_loff=14044220776448, dl_data=0x7f7ffffea190) at /usr/src/libexec/ld.so/loader.c:638
#11 0x00000cc5eccb5fb6 in _dl_start () at /usr/src/libexec/ld.so/amd64/ldasm.S:61
#12 0x0000000000000000 in ?? ()

Sebastian


_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

Sebastian Reitenbach-2
In reply to this post by Matt Rice-2
Am Dienstag, November 27, 2018 19:26 CET, Matt Rice <[hidden email]> schrieb:
 

> On Mon, Nov 26, 2018 at 7:18 AM David Chisnall
> <[hidden email]> wrote:
> >
> > On 26/11/2018 15:03, Sebastian Reitenbach wrote:
> > >  From the stacktrace, It's the last NSCAssert1 that fires, right after that line:
> > > backend = NSClassFromString (@"GSBackend");
> >
> > Yup.  That makes me think either:
> >
> > - The dlopen failed.
> > - The dlopen returned success, but didn't call the constructor, so it
> > didn't call __objc_exec_class.
> > - The library was loaded but some memory was corrupted.
>
> ISTR constructor call order is undefined, and openbsd (has/had) a
> called constructors in an order which was
> reversed from the order that glibc calls them, so possibly
> a) openbsd changed their order,
> b) something was added which relies upon the order of calls happening
> in the glibc order
>
> could cause the second? i.e. the constructor would eventually be
> called, but hasn't been called yet.

The thing that changed was the linker, at 22nd of October, the default linker
on amd64 platform changed from the good old bfd linker to the lld linker from
llvm.

As a workaround for the time being, I pass -fuse-ld=bfd, as David suggested,
to unbreak all the GNUstep applications in the ports tree. So the lld linker is
doing something different to the resulting binary than the old bfd linker did.

Will it help to run nm, or objdump or the like on the binary, or the libraries
to compare output between what it produces when using lld or bfd linkers?

Sebastian

>
> > > So before that, there's the other NSCAssert1, [theBundle load], and since
> > > this doesn't fire, I think loading it, went OK?
> > > But I might well be on the wrong track.
> >
> > Can you disable the breakpoint on __objc_exec_class until just before
> > the [theBundle load] line, then enable it and make sure that it's called
> > *after* the dlopen call?  Can you also check in the code that we're
> > actually checking the return from dlopen correctly (I'm pretty sure we are).
> >
> > If all this works, can you check in each __objc_exec_class call and see
> > if one of the classes that it loads is called GSBackend?  If so, then it
> > looks as if there's still something wrong with the hash table in
> > libobjc2.  I think I back-ported all of the fixes to the 1.9 branch, but
> > I might have missed one...
> >
> > David
> >
> > _______________________________________________
> > Discuss-gnustep mailing list
> > [hidden email]
> > https://lists.gnu.org/mailman/listinfo/discuss-gnustep


_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

David Chisnall-7
In reply to this post by Sebastian Reitenbach-2
On 28/11/2018 11:35, Sebastian Reitenbach wrote:

> (gdb) info break
> Num     Type           Disp Enb Address            What
> 1       breakpoint     keep y   0x0000093f1dcad9a2 in initialize_gnustep_backend at NSApplication.m:309
>          breakpoint already hit 1 time
> 2       breakpoint     keep y   0x0000093ec291a170 in -[NSBundle load] at NSBundle.m:1989
> 3       breakpoint     keep y   0x0000093ec2b2a750 in __objc_dynamic_link at ././dynamic-load.h:63
> 5       breakpoint     keep y   0x0000093e64843ae0 in __objc_exec_class at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/loader.c:46
> (gdb) c
> Continuing.
>
> Breakpoint 2, -[NSBundle load] (self=0x93e9baac588, _cmd=0x93e69deea88) at NSBundle.m:1989
> 1989    - (BOOL) load
> (gdb)
> Continuing.
>
> Breakpoint 3, __objc_dynamic_link (module=0x93f0c45f248 "8\212\273\302>\t", mode=2366, debug_file=0x93f3d9fa8e0 <__sF+304> "") at ././dynamic-load.h:64
> warning: Source file is more recent than executable.
> 64      {
> (gdb)
> Continuing.
>
> Program received signal SIGFPE, Arithmetic exception.
> 0x0000093e70b4124c in _dl_find_symbol_obj (obj=0x93ecb3bbc00, sl=0x7f7ffffd33f8) at /usr/src/libexec/ld.so/resolve.c:584
> 584             for (si = obj->buckets[sl->sl_elf_hash % obj->nbuckets];
>
> So I stopped at NSApplication.m:309, and then added the breakpoints in dynamic-load.h and in libobjc loader.c where the __objc_exec_class resides, and then continued to execute, but it doesn't hit the breakpoint 5 before throwing the FPE.


Okay, it looks as if libraries that are linked with lld are not getting
their global constructors called on OpenBSD.  Can you try this test?

=$ cat lib.c
#include <stdio.h>

__attribute__((constructor))
void load(void)
{
         puts("Library loaded");
}
[theraven@FBSDVM /tmp]$ cat loadlib.c
#include <dlfcn.h>
#include <stdio.h>

int main(void)
{
         puts("Program started");
         dlopen("./lib.so", RTLD_LAZY | RTLD_GLOBAL);
         return 0;
}
$ clang60 lib.c -shared -o lib.so -fPIC -fuse-ld=lld
$ clang loadlib.c
$ ./a.out
Program started
Library loaded


If it prints both of the lines above, the library was correctly loaded
and the global constructors were run.  If it works with -fuse-ld=lld but
not -fuse-ld=bfd, then that tells us that this really is the problem.
Objdump of the bfd and lld versions of lib.so should help us identify
the differences.

David

_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

Sebastian Reitenbach-2
Am Mittwoch, November 28, 2018 13:42 CET, David Chisnall <[hidden email]> schrieb:

> On 28/11/2018 11:35, Sebastian Reitenbach wrote:
> > (gdb) info break
> > Num     Type           Disp Enb Address            What
> > 1       breakpoint     keep y   0x0000093f1dcad9a2 in initialize_gnustep_backend at NSApplication.m:309
> >          breakpoint already hit 1 time
> > 2       breakpoint     keep y   0x0000093ec291a170 in -[NSBundle load] at NSBundle.m:1989
> > 3       breakpoint     keep y   0x0000093ec2b2a750 in __objc_dynamic_link at ././dynamic-load.h:63
> > 5       breakpoint     keep y   0x0000093e64843ae0 in __objc_exec_class at /home/ports/pobj/amd64/gnustep-libobjc2-1.9.0/libobjc2-1.9.0/loader.c:46
> > (gdb) c
> > Continuing.
> >
> > Breakpoint 2, -[NSBundle load] (self=0x93e9baac588, _cmd=0x93e69deea88) at NSBundle.m:1989
> > 1989    - (BOOL) load
> > (gdb)
> > Continuing.
> >
> > Breakpoint 3, __objc_dynamic_link (module=0x93f0c45f248 "8\212\273\302>\t", mode=2366, debug_file=0x93f3d9fa8e0 <__sF+304> "") at ././dynamic-load.h:64
> > warning: Source file is more recent than executable.
> > 64      {
> > (gdb)
> > Continuing.
> >
> > Program received signal SIGFPE, Arithmetic exception.
> > 0x0000093e70b4124c in _dl_find_symbol_obj (obj=0x93ecb3bbc00, sl=0x7f7ffffd33f8) at /usr/src/libexec/ld.so/resolve.c:584
> > 584             for (si = obj->buckets[sl->sl_elf_hash % obj->nbuckets];
> >
> > So I stopped at NSApplication.m:309, and then added the breakpoints in dynamic-load.h and in libobjc loader.c where the __objc_exec_class resides, and then continued to execute, but it doesn't hit the breakpoint 5 before throwing the FPE.
>
>
> Okay, it looks as if libraries that are linked with lld are not getting
> their global constructors called on OpenBSD.  Can you try this test?
>
> =$ cat lib.c
> #include <stdio.h>
>
> __attribute__((constructor))
> void load(void)
> {
>          puts("Library loaded");
> }
> [theraven@FBSDVM /tmp]$ cat loadlib.c
> #include <dlfcn.h>
> #include <stdio.h>
>
> int main(void)
> {
>          puts("Program started");
>          dlopen("./lib.so", RTLD_LAZY | RTLD_GLOBAL);
>          return 0;
> }
> $ clang60 lib.c -shared -o lib.so -fPIC -fuse-ld=lld
> $ clang loadlib.c
> $ ./a.out
> Program started
> Library loaded
>
>
> If it prints both of the lines above, the library was correctly loaded
> and the global constructors were run.  If it works with -fuse-ld=lld but
> not -fuse-ld=bfd, then that tells us that this really is the problem.
> Objdump of the bfd and lld versions of lib.so should help us identify
> the differences.
>
> David
sebastia@communicator:~> vi lib.c
sebastia@communicator:~> vi loadlib.c
sebastia@communicator:~> clang lib.c -shared -o lib.so -fPIC -fuse-ld=lld
sebastia@communicator:~> clang loadlib.c                                                                                                      
sebastia@communicator:~> ./a.out                                                                                                              
Program started
Library loaded
sebastia@communicator:~> rm lib.so a.out                                                                                                      
sebastia@communicator:~> clang lib.c -shared -o lib.so -fPIC -fuse-ld=bfd
sebastia@communicator:~> clang loadlib.c                              
sebastia@communicator:~> ./a.out                                                                                                              
Program started
Library loaded
sebastia@communicator:~>


 since both work, don't know how helpful the objdump will be. I ran objdump -x
on both, find it attached.


Sebastian

_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

objdump_bfd (11K) Download Attachment
objdump_lld (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

David Chisnall-7
On 28/11/2018 12:55, Sebastian Reitenbach wrote:
>   since both work, don't know how helpful the objdump will be.

Not very.  Can you try making lib.c into a lib.m that implements a class
with a +load method (and add -lobjc to the compile command for loadlib.c)?

David

_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Reply | Threaded
Open this post in threaded view
|

Re: loading bundles stopped working

Sebastian Reitenbach-2
Hi,
 
Am Mittwoch, November 28, 2018 14:03 CET, David Chisnall <[hidden email]> schrieb:
 
> On 28/11/2018 12:55, Sebastian Reitenbach wrote:
> >   since both work, don't know how helpful the objdump will be.
>
> Not very.  Can you try making lib.c into a lib.m that implements a class
> with a +load method (and add -lobjc to the compile command for loadlib.c)?
>
> David

so I used this as the lib.m:

#include <stdio.h>

#import <Foundation/Foundation.h>

@interface testlib: NSObject
{
}
@end

@implementation testlib
+ (void) load {
        puts("Library loaded");
}
@end

And this command to compile it:
clang -shared -fPIC  -Wl,-E -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -pthread  -fexceptions -o lib.so -L/usr/local/lib -lstdc++ -lm -lgnustep-base    -lpthread -lobjc2 -fobjc-nonfragile-abi   -lm -lc++abi

and your loadlib.c:
#include <dlfcn.h>
#include <stdio.h>

int main(void)
{
puts("Program started");
dlopen("./lib.so", RTLD_LAZY | RTLD_GLOBAL);
return 0;
}

and then clang loadlib.c

then it only prints:
Program started
in both cases.

I guess I miss something, since its not working for both cases.
When not using the -fuse-ld flag, I also had gnustep-base compiled without that flag, using lld.
When compiling lib.m with -fuse-ld=bfd, I had rebuilt gnustep-base compiled with that flag as well.


Sebastian


_______________________________________________
Discuss-gnustep mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep