Hi.

  I'm trying to compile sawfish wm. librep and libgmp already compiled.
  I've performed basic tests like evaluating expressions, using large
  integers, load(), open() - it seems to work.

  Now I'm trying to compile rep-gtk and I'm in stuck with GTK module
  dynamic loading. After entering ",load gtk" in rep command line it
  spins forever. Closer examinations with GDB show an endless loop
  in __spin_lock_solid().

user> ,load gtk
^C
Program received signal SIGINT, Interrupt.
0x1433c in __swtch_pri () from /lib/ld.so
(gdb) bt
#0  0x1433c in __swtch_pri () from /lib/ld.so
#1  0x1431f in __spin_lock_solid (lock=0x20728) at spin-solid.c:27
#2  0x1246b in __mutex_lock_solid (lock=0x20728) at mutex-solid.c:31
#3  0x980d in add_dependency (undef_map=0x80756d8, map=0x8077940)
    at ../mach/lock-intern.h:77
...

  Full typescript is in attachment.

  Now a bunch of questions. Sorry, somewhat hairy.


  I've found following comment in libc/mach/mutex-solid.c

/* If cthreads is linked in, it will define these functions itself to do
   real cthreads mutex locks.  This file will only be linked in when
   cthreads is not used, and mutexes' are in fact just spin locks (and
   some unused storage).  */

void
__mutex_lock_solid (void *lock)
...

  Does it mean, that Hurd libthreads must be linked in, by supplying
  explicit -l in gcc command line, for dynamic loading to work
  correctly?
  Why there are two implementations of locking primitives?

  Loading other librep modules doesn't trigger such behavior...(?)

  I'm not familar with ELF and other clever linker stuff, so what
  exactly should be linked against libthreads? librep itself,
  librep.so, or librep gtk module? I think, linking librep is enough.

  Also what about recursive mutexes? In libc/elf/dl-open.c:

/* During the program run we must not modify the global data of
   loaded shared object simultanously in two threads.  Therefore we
   protect _dl_open' and _dl_close' in dl-close.c.
      
   This must be a recursive lock since the initializer function of
   the loaded object might as well require a call to this function.
   At this time it is not anymore a problem to modify the tables.  */
__libc_lock_define (extern, _dl_load_lock)

  libc/sysdeps/mach/bits/libc-lock.h:
                 
/* XXX until cthreads supports recursive locks */
#define __libc_lock_define_initialized_recursive __libc_lock_define_initialized

  hurd/libthreads/* seems not to contain special logic for recursive
  locks.

  But libc/elf/dl-open.c:_dl_open() grab _dl_load_lock first and the
  same do libc/elf/dl-lookup.c:add_dependency() later.
  ?

  If it matters, I'm compiling on Linux with cross-compiler. Waiting
  for packages with native compiler...

  Pretend you doesn't see "linux" in rep pathnames and banner -
  cross-compiling librep is just ugly hack.
  

arkadi.
-- 
Today my crystal ball isn't clear
enough to tell you truth.
Script started on Sun Mar 11 03:01:46 2001
hurd:~# gdb rep
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-gnu0.2"...
(gdb) r
Starting program: /usr/local/bin/rep 
rep 0.13.4, Copyright (C) 1999-2000 John Harper
rep comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING
Built Sat Mar 10 2001 by [EMAIL PROTECTED], for i586-pc-linux-gnu.

Enter `,help' to list commands.
user> ,load gtk
^C
Program received signal SIGINT, Interrupt.
0x1433c in __swtch_pri () from /lib/ld.so
(gdb) bt
#0  0x1433c in __swtch_pri () from /lib/ld.so
#1  0x1431f in __spin_lock_solid (lock=0x20728) at spin-solid.c:27
#2  0x1246b in __mutex_lock_solid (lock=0x20728) at mutex-solid.c:31
#3  0x980d in add_dependency (undef_map=0x80756d8, map=0x8077940)
    at ../mach/lock-intern.h:77
#4  0x9c59 in _dl_lookup_symbol (
    undef_name=0x1451865 "g_threads_got_initialized", undef_map=0x80756d8, 
    ref=0x10204dc, symbol_scope=0x807582c, reloc_type=6, explicit=0)
    at dl-lookup.c:213
#5  0xcd37 in _dl_relocate_object (l=0x80756d8, scope=0x807582c, lazy=1, 
    consider_profiling=0) at ../sysdeps/i386/dl-machine.h:325
#6  0x11e550b in dl_open_worker (a=0x102062c) at dl-open.c:312
#7  0xe65f in _dl_catch_error (objname=0x1020624, errstring=0x1020628, 
    operate=0x11e5178 <dl_open_worker>, args=0x102062c) at dl-error.c:149
#8  0x11e56b2 in _dl_open (
    file=0x1020754 "/usr/local/libexec/rep/i586-pc-linux-gnu/gtk.so", 
    mode=16909860, caller=0x1064606) at dl-open.c:380
#9  0x1077014 in dlopen_doit (a=0x102071c) at dlopen.c:39
#10 0xe65f in _dl_catch_error (objname=0x1078bb8, errstring=0x1078bbc, 
    operate=0x1076fe0 <dlopen_doit>, args=0x102071c) at dl-error.c:149
#11 0x107740d in _dlerror_run (operate=0x1076fe0 <dlopen_doit>, args=0x102071c)
    at dlerror.c:130
#12 0x1077053 in __dlopen_check (
    file=0x1020754 "/usr/local/libexec/rep/i586-pc-linux-gnu/gtk.so", mode=257)
---Type <return> to continue, or q <return> to quit---
    at dlopen.c:53
#13 0x1064606 in rep_open_dl_library (file_name=134638944) at unix_dl.c:311
#14 0x104c08f in Fload_dl_file (name=134638944, structure=134635080)
    at lispcmds.c:1337
#15 0x104c5a5 in Fload (file=134638624, noerr_p=17255624, nopath_p=17255624, 
    nosuf_p=17255624, unused=17255624) at lispcmds.c:1505
#16 0x105dd3c in Fintern_structure (name=134665088) at structures.c:1100
#17 0x104e83e in vm (code=134637560, consts=134615248, argc=1, argv=0x1020cc4, 
    v_stkreq=4, b_stkreq=1, s_stkreq=2) at lispmach.h:636
#18 0x105173e in rep_apply_bytecode (subr=134615264, nargs=1, args=0x1020cc4)
    at lispmach.h:499
#19 0x1047123 in funcall (fun=134615264, arglist=134653992, eval_args=0, 
    tail_posn=17255624) at lisp.c:1678
#20 0x1047234 in rep_funcall (fun=134576424, arglist=134653992, eval_args=0)
    at lisp.c:1710
#21 0x1047265 in rep_apply (fun=134576424, args=134653992) at lisp.c:1716
#22 0x1050c8a in vm (code=134637232, consts=134612560, argc=2, argv=0x1020e3c, 
    v_stkreq=5, b_stkreq=6, s_stkreq=2) at lispmach.h:1891
#23 0x105173e in rep_apply_bytecode (subr=134612064, nargs=0, args=0x0)
    at lispmach.h:499
#24 0x1047c26 in rep_call_lispn (fun=134576944, argc=0, argv=0x0)
    at lisp.c:2006
#25 0x1047ccf in rep_call_lisp0 (function=134576944) at lisp.c:2025
#26 0x104d6ff in Fcall_with_exception_handler (thunk=134576944, 
---Type <return> to continue, or q <return> to quit---
    handler_thunk=134576964) at lispcmds.c:2001
#27 0x104e8aa in vm (code=134637288, consts=134612832, argc=0, argv=0x102122c, 
    v_stkreq=4, b_stkreq=2, s_stkreq=3) at lispmach.h:649
#28 0x104ec37 in vm (code=134636224, consts=134634872, argc=0, argv=0x0, 
    v_stkreq=5, b_stkreq=1, s_stkreq=1) at lispmach.h:499
#29 0x10517f9 in Frun_byte_code (code=134636224, consts=134634872, 
    stkreq=4198422) at lispmach.c:104
#30 0x1046fbf in funcall (fun=17235656, arglist=17255624, eval_args=1, 
    tail_posn=134528156) at lisp.c:1627
#31 0x1047756 in eval (obj=134649352, tail_posn=134528156) at lisp.c:1860
#32 0x1047837 in rep_eval (obj=134649352, tail_posn=134528156) at lisp.c:1892
#33 0x1047af1 in Fprogn (args=134649856, tail_posn=134528156) at lisp.c:1977
#34 0x1046808 in eval_lambda (lambdaExp=134649776, argList=17255624, 
    eval_args=0, eval_in_env=0, tail_posn=17255624) at lisp.c:1380
#35 0x1047056 in funcall (fun=134649600, arglist=17255624, eval_args=0, 
    tail_posn=17255624) at lisp.c:1645
#36 0x1047234 in rep_funcall (fun=134576084, arglist=17255624, eval_args=0)
    at lisp.c:1710
#37 0x1047ca2 in rep_call_lispn (fun=134576084, argc=0, argv=0x0)
    at lisp.c:2018
#38 0x1047ccf in rep_call_lisp0 (function=134576084) at lisp.c:2025
#39 0x105d432 in Fmake_structure (sig=17255624, header_thunk=134576064, 
    body_thunk=134576084, name=134536124) at structures.c:763
#40 0x1046fdc in funcall (fun=17238340, arglist=17255624, eval_args=1, 
---Type <return> to continue, or q <return> to quit---
    tail_posn=17255624) at lisp.c:1630
#41 0x1047756 in eval (obj=134649648, tail_posn=17255624) at lisp.c:1860
#42 0x1047837 in rep_eval (obj=134649648, tail_posn=17255624) at lisp.c:1892
#43 0x1047663 in eval (obj=134649240, tail_posn=17255624) at lisp.c:1825
#44 0x1047837 in rep_eval (obj=134649240, tail_posn=17255624) at lisp.c:1892
#45 0x104bee4 in Fload_file (name=134636200, structure=134536384)
    at lispcmds.c:1290
#46 0x104c5bd in Fload (file=134514636, noerr_p=17255624, nopath_p=17255624, 
    nosuf_p=17255624, unused=17255624) at lispcmds.c:1508
#47 0x1052535 in rep_load_environment (file=134514636) at main.c:302
#48 0x103d210 in rep_call_with_barrier (
    callback=0x804858c <rep_load_environment>, arg=134514636, closed=1, in=0, 
    out=0, data=0x0) at continuations.c:346
#49 0x804874e in main (argc=0, argv=0x1021c74) at rep.c:24
#50 0x10f79e4 in __libc_start_main (main=0x8048708 <main>, argc=1, 
    ubp_av=0x1021c70, init=0x8048544 <_init>, fini=0x80487ac <_fini>, 
    rtld_fini=0xea58 <_dl_fini>, stack_end=0x1021c6c)
    at ../sysdeps/generic/libc-start.c:129
(gdb) bt
#0  0x1433c in __swtch_pri () from /lib/ld.so
#1  0x1431f in __spin_lock_solid (lock=0x20728) at spin-solid.c:27
#2  0x1246b in __mutex_lock_solid (lock=0x20728) at mutex-solid.c:31
#3  0x980d in add_dependency (undef_map=0x80756d8, map=0x8077940)
    at ../mach/lock-intern.h:77
#4  0x9c59 in _dl_lookup_symbol (
    undef_name=0x1451865 "g_threads_got_initialized", undef_map=0x80756d8, 
    ref=0x10204dc, symbol_scope=0x807582c, reloc_type=6, explicit=0)
    at dl-lookup.c:213
#5  0xcd37 in _dl_relocate_object (l=0x80756d8, scope=0x807582c, lazy=1, 
    consider_profiling=0) at ../sysdeps/i386/dl-machine.h:325
#6  0x11e550b in dl_open_worker (a=0x102062c) at dl-open.c:312
#7  0xe65f in _dl_catch_error (objname=0x1020624, errstring=0x1020628, 
    operate=0x11e5178 <dl_open_worker>, args=0x102062c) at dl-error.c:149
#8  0x11e56b2 in _dl_open (
    file=0x1020754 "/usr/local/libexec/rep/i586-pc-linux-gnu/gtk.so", 
    mode=16909860, caller=0x1064606) at dl-open.c:380
#9  0x1077014 in dlopen_doit (a=0x102071c) at dlopen.c:39
#10 0xe65f in _dl_catch_error (objname=0x1078bb8, errstring=0x1078bbc, 
    operate=0x1076fe0 <dlopen_doit>, args=0x102071c) at dl-error.c:149
#11 0x107740d in _dlerror_run (operate=0x1076fe0 <dlopen_doit>, args=0x102071c)
    at dlerror.c:130
#12 0x1077053 in __dlopen_check (
    file=0x1020754 "/usr/local/libexec/rep/i586-pc-linux-gnu/gtk.so", mode=257)
---Type <return> to continue, or q <return> to quit---q
 Quit
(gdb) up
#1  0x1431f in __spin_lock_solid (lock=0x20728) at spin-solid.c:27
27      spin-solid.c: No such file or directory.
(gdb) p lock
$1 = (int *) 0x20728
(gdb) p *lock
$2 = 1
(gdb) up
#2  0x1246b in __mutex_lock_solid (lock=0x20728) at mutex-solid.c:31
31      mutex-solid.c: No such file or directory.
(gdb) up
#3  0x980d in add_dependency (undef_map=0x80756d8, map=0x8077940)
    at ../mach/lock-intern.h:77
77      ../mach/lock-intern.h: No such file or directory.
(gdb) p map
$3 = (struct link_map *) 0x8077940
(gdb) p *map
$4 = {l_addr = 19382272, l_name = 0x8077920 "/lib/libglib-1.2.so.0", 
  l_ld = 0x129bc94, l_next = 0x80750a0, l_prev = 0x80776f0, 
  l_libname = 0x8077ae0, l_info = {0x0, 0x129bc94, 0x129bce4, 0x129bcdc, 
    0x129bcb4, 0x129bcbc, 0x129bcc4, 0x0, 0x0, 0x0, 0x129bccc, 0x129bcd4, 
    0x129bca4, 0x129bcac, 0x129bc9c, 0x0, 0x0, 0x129bcfc, 0x129bd04, 
    0x129bd0c, 0x129bcec, 0x0, 0x129bd14, 0x129bcf4, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x129bd24, 0x129bd1c, 0x0 <repeats 13 times>, 
    0x129bd2c, 0x0, 0x0, 0x0}, l_phdr = 0x127c034, l_entry = 19407568, 
  l_phnum = 3, l_ldnum = 21, l_searchlist = {r_list = 0x0, r_nlist = 0, 
    r_duplist = 0x0, r_nduplist = 0}, l_symbolic_searchlist = {r_list = 0x0, 
    r_nlist = 0, r_duplist = 0x0, r_nduplist = 0}, l_loader = 0x80776f0, 
  l_nbuckets = 263, l_buckets = 0x127c09c, l_chain = 0x127c4b8, 
  l_opencount = 1, l_type = lt_loaded, l_relocated = 1, l_init_called = 1, 
  l_global = 1, l_reserved = 0, l_phdr_allocated = 0, l_soname_added = 0, 
  l_faked = 0, l_nversions = 3, l_versions = 0x8077bd0, l_rpath_dirs = {
    dirs = 0x0, malloced = 0}, l_reloc_result = 0x0, l_versyms = 0x1280b60, 
  l_origin = 0x8077b08 "/lib", l_map_start = 19382272, l_map_end = 19512672, 
  l_scope = {0x10270f8, 0x80777e8, 0x0, 0x0}, l_local_scope = {0x8077a38, 
    0x0}, l_dev = 0, l_ino = 65472, l_runpath_dirs = {dirs = 0x0, 
    malloced = 0}, l_initfini = 0x8077b28, l_reldepsmax = 0, l_reldepsact = 0, 
  l_reldeps = 0x0, l_feature_1 = 0, l_flags_1 = 0, l_idx = 0}
(gdb) p *undef_map
$5 = {l_addr = 21303296, l_name = 0x80756b8 "/lib/libgmodule-1.2.so.0", 
  l_ld = 0x1453e1c, l_next = 0x80758e0, l_prev = 0x80754d8, 
  l_libname = 0x8075878, l_info = {0x0, 0x1453e1c, 0x1453e6c, 0x1453e64, 
    0x1453e3c, 0x1453e44, 0x1453e4c, 0x0, 0x0, 0x0, 0x1453e54, 0x1453e5c, 
    0x1453e2c, 0x1453e34, 0x1453e24, 0x0, 0x0, 0x1453e84, 0x1453e8c, 
    0x1453e94, 0x1453e74, 0x0, 0x1453e9c, 0x1453e7c, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x1453eac, 0x1453ea4, 0x0 <repeats 13 times>, 
    0x1453eb4, 0x0, 0x0, 0x0}, l_phdr = 0x1451034, l_entry = 21306624, 
  l_phnum = 3, l_ldnum = 21, l_searchlist = {r_list = 0x0, r_nlist = 0, 
    r_duplist = 0x0, r_nduplist = 0}, l_symbolic_searchlist = {r_list = 0x0, 
    r_nlist = 0, r_duplist = 0x0, r_nduplist = 0}, l_loader = 0x80750a0, 
  l_nbuckets = 67, l_buckets = 0x145109c, l_chain = 0x14511a8, 
  l_opencount = 0, l_type = lt_loaded, l_relocated = 0, l_init_called = 0, 
  l_global = 0, l_reserved = 0, l_phdr_allocated = 0, l_soname_added = 0, 
  l_faked = 0, l_nversions = 3, l_versions = 0x8076130, l_rpath_dirs = {
    dirs = 0x0, malloced = 0}, l_reloc_result = 0x0, l_versyms = 0x1451992, 
  l_origin = 0x80758a0 "/lib", l_map_start = 21303296, l_map_end = 21315292, 
  l_scope = {0x10270f8, 0x8075198, 0x0, 0x0}, l_local_scope = {0x80757d0, 
    0x0}, l_dev = 0, l_ino = 65473, l_runpath_dirs = {dirs = 0x0, 
    malloced = 0}, l_initfini = 0x8075f10, l_reldepsmax = 0, l_reldepsact = 0, 
  l_reldeps = 0x0, l_feature_1 = 0, l_flags_1 = 0, l_idx = 0}
(gdb) bt
#0  0x1433c in __swtch_pri () from /lib/ld.so
#1  0x1431f in __spin_lock_solid (lock=0x20728) at spin-solid.c:27
#2  0x1246b in __mutex_lock_solid (lock=0x20728) at mutex-solid.c:31
#3  0x980d in add_dependency (undef_map=0x80756d8, map=0x8077940)
    at ../mach/lock-intern.h:77
#4  0x9c59 in _dl_lookup_symbol (
    undef_name=0x1451865 "g_threads_got_initialized", undef_map=0x80756d8, 
    ref=0x10204dc, symbol_scope=0x807582c, reloc_type=6, explicit=0)
    at dl-lookup.c:213
#5  0xcd37 in _dl_relocate_object (l=0x80756d8, scope=0x807582c, lazy=1, 
    consider_profiling=0) at ../sysdeps/i386/dl-machine.h:325
#6  0x11e550b in dl_open_worker (a=0x102062c) at dl-open.c:312
#7  0xe65f in _dl_catch_error (objname=0x1020624, errstring=0x1020628, 
    operate=0x11e5178 <dl_open_worker>, args=0x102062c) at dl-error.c:149
#8  0x11e56b2 in _dl_open (
    file=0x1020754 "/usr/local/libexec/rep/i586-pc-linux-gnu/gtk.so", 
    mode=16909860, caller=0x1064606) at dl-open.c:380
#9  0x1077014 in dlopen_doit (a=0x102071c) at dlopen.c:39
#10 0xe65f in _dl_catch_error (objname=0x1078bb8, errstring=0x1078bbc, 
    operate=0x1076fe0 <dlopen_doit>, args=0x102071c) at dl-error.c:149
#11 0x107740d in _dlerror_run (operate=0x1076fe0 <dlopen_doit>, args=0x102071c)
    at dlerror.c:130
#12 0x1077053 in __dlopen_check (
    file=0x1020754 "/usr/local/libexec/rep/i586-pc-linux-gnu/gtk.so", mode=257)
---Type <return> to continue, or q <return> to quit---q
 Quit
(gdb) k
Kill the program being debugged? (y or n) y
(gdb) q
hurd:~# exit
exit

Script done on Sun Mar 11 03:05:04 2001

Reply via email to