Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Dec 2003 01:27:40 -0600
From:      Eric Timme <timothy@voidnet.com>(by way of Eric Timme <timothy@voidnet.com>)
To:        freebsd-questions@freebsd.org
Subject:   Porting a linuxthreads app to FreeBSD problems
Message-ID:  <200312240127.40834.timothy@voidnet.com>

next in thread | raw e-mail | index | archive | help
4.9-PRERELEASE FreeBSD 4.9-PRERELEASE #0: Mon Sep 22 05:40:14 CDT 2003

gcc 3.2

I'm trying to port an app (C++) over to FreeBSD utilizing devel/linuxthreads,
 and have it to the point it will compile. I've made the appropriate changes
 to the compilation options, so everything seems kosher. Starting up the app,
 however, it just stalls at a particular point every time. I was wondering if
 anyone had encountered this before, and if so, how they solved the problem.
 I'm including output from strace and ltrace at the end of my email.

The problem seems to revolve around mutexes, judging by the point at which
 the app locks up - for reference, the app utilizes one mutex, of type
 PTHREAD_MUTEX_RECURSIVE_NP.

Reading the README.FreeBSD from the devel/linuxthreads port there is a blurb:

  c) The mutex wrapper functions only provide standard linuxthreads mutexes
  (i.e. non-recursive mutexes).  This might lead to deadlocks if libc
  depends on recursive mutexes.

However, I've gotten previous versions of the application (which also used
 PTHREAD_MUTEX_RECURSIVE_NP) working without stalling.

I'm grateful for any insight people can offer..I'm not really sure how to 
approach debugging this problem, since it seems like it stalls before it ever 
really begins running the application's code.

=======================================================================

ltrace.out

_spinlock(0x081a90a4, 0x080dcb81, 0xbfbffa64, 0x080dcb81, 1) = 0
_spinlock(0x081a90a4, 0x080dcb81, 0xbfbffa64, 0x080dcb81, 1) = 0
_spinlock(0x081a90a4, 0x080dcb81, 0xbfbffa54, 0x080dcb81, 1) = 0
pthread_mutex_lock(0x081a9098, 0x081f20bc, 322832, 0x080db296, 32768) = 0
pthread_mutex_unlock(0x081a9098, 0x081f20bc, 322832, 0x080db296, 32768) = 0
_spinlock(0x081a92a4, 0x080e7a1d, 0xbfbff9d0, 0x080e7a1d, 16) = 0
__error(16, 16, 0xbfbffaa4, 0x081bdd00, 0x081bdd00) = 0x081cbd5c
__error(2, 0x080e6dac, 0x08122774, 0xbfbff960, 63) = 0x081cbd5c
__error(0x08122774, 0xbfbff960, 63, 0x080e6d97, 16) = 0x081cbd5c
_spinlock(0x081a92a4, 0x080e7a1d, 0xbfbff9a0, 0x080e7a1d, 24) = 0
pthread_mutexattr_init(0xbfbff9cc, 65535, 1, 0x08291030, 65535) = 0
pthread_mutexattr_settype(0xbfbff9cc, 1, 1, 0x08291030, 65535) = 0
pthread_mutex_init(0x08290040, 0xbfbff9cc, 1, 0x08291030, 65535) = 0
pthread_mutexattr_destroy(0xbfbff9cc, 0xbfbff9cc, 1, 0x08291030, 65535) = 0
_spinlock(0x081a92a4, 0x080e7a1d, 0xbfbff980, 0x080e7a1d, 16) = 0
_spinlock(0x081a92a4, 0x080e7a1d, 0xbfbff980, 0x080e7a1d, 16) = 0
_spinlock(0x081a92a4, 0x080e7a1d, 0xbfbff980, 0x080e7a1d, 4) = 0
_spinlock(0x081a92a4, 0x080e7a1d, 0xbfbff9a0, 0x080e7a1d, 24) = 0
pthread_mutexattr_init(0xbfbff9cc, 0xbfbff9cc, 1, 0x08291030, 0x08290040) = 0
pthread_mutexattr_settype(0xbfbff9cc, 1, 1, 0x08291030, 0x08290040) = 0
pthread_mutex_init(0x08290060, 0xbfbff9cc, 1, 0x08291030, 0x08290040) = 0
pthread_mutexattr_destroy(0xbfbff9cc, 0xbfbff9cc, 1, 0x08291030, 0x08290040)
 = 0 _spinlock(0x081a92a4, 0x080e7a1d, 0xbfbff9a0, 0x080e7a1d, 24) = 0
pthread_mutexattr_init(0xbfbff9cc, 0xbfbff9cc, 1, 0x08291030, 0x08290060) = 0
pthread_mutexattr_settype(0xbfbff9cc, 1, 1, 0x08291030, 0x08290060) = 0
pthread_mutex_init(0x08290080, 0xbfbff9cc, 1, 0x08291030, 0x08290060) = 0
pthread_mutexattr_destroy(0xbfbff9cc, 0xbfbff9cc, 1, 0x08291030, 0x08290060)
 = 0 _spinlock(0x081a92a4, 0x080e7a1d, 0xbfbff9a0, 0x080e7a1d, 24) = 0
pthread_mutexattr_init(0xbfbff9cc, 0xbfbff9cc, 1, 0x08291030, 0x08290080) = 0
pthread_mutexattr_settype(0xbfbff9cc, 1, 1, 0x08291030, 0x08290080) = 0
pthread_mutex_init(0x082900a0, 0xbfbff9cc, 1, 0x08291030, 0x08290080) = 0
pthread_mutexattr_destroy(0xbfbff9cc, 0xbfbff9cc, 1, 0x08291030, 0x08290080)
 = 0 _spinlock(0x081a92a4, 0x080e7a1d, 0xbfbff9a0, 0x080e7a1d, 24) = 0
pthread_mutexattr_init(0xbfbff9cc, 0xbfbff9cc, 1, 0x08291030, 0x082900a0) = 0
pthread_mutexattr_settype(0xbfbff9cc, 1, 1, 0x08291030, 0x082900a0) = 0
pthread_mutex_init(0x082900c0, 0xbfbff9cc, 1, 0x08291030, 0x082900a0) = 0
pthread_mutexattr_destroy(0xbfbff9cc, 0xbfbff9cc, 1, 0x08291030, 0x082900a0)
 = 0 pthread_mutex_lock(0x081a88b4, 1, 0xbfbff9d0, 0x0807d6ba, 0xbfbff9cc
 <unfinished ...> --- SIGINT (Interrupt) ---
--- SIGINT (Interrupt) ---
+++ killed by SIGINT +++


=======================================================================

strace.out

execve("./world", ["./world"], [/* 31 vars */]) = 0
mmap(0, 1976, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0) = 0x2813b000
munmap(0x2813b000, 1976)                = 0
__sysctl([hw.pagesize], 2, "\0\20\0\0", [4], NULL, 0) = 0
mmap(0, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0) =
 0x2813b000 geteuid(0xbfbffa90)                     = 1001
getuid()                                = 1001 (euid 1001)
getegid(0xbfbffa90)                     = 1001
getgid()                                = 1001 (egid 1001)
open("/var/run/ld-elf.so.hints", O_RDONLY) = 3
read(3, "Ehnt\1\0\0\0\200\0\0\0z\0\0\0\0\0\0\0y\0\0\0\0\0\0\0\0"..., 128) =
 128 lseek(3, 128, SEEK_SET)                 = 128
read(3, "/usr/lib:/usr/lib/compat:/usr/X1"..., 122) = 122
close(3)                                = 0
access("/usr/lib/liblthread.so.2", F_OK) = -1 ENOENT (No such file or
 directory) access("/usr/lib/compat/liblthread.so.2", F_OK) = -1 ENOENT (No
 such file or directory) access("/usr/X11R6/lib/liblthread.so.2", F_OK) = -1
 ENOENT (No such file or directory) access("/usr/local/lib/liblthread.so.2",
 F_OK) = 0
open("/usr/local/lib/liblthread.so.2", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=123704, ...}) = 0
read(3, "\177ELF\1\1\1\t\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0<k\0\000"..., 4096) =
 4096 mmap(0, 147456, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_NOCORE, 3, 0) =
 0x28143000 mprotect(0x28159000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x28159000, 4096, PROT_READ|PROT_EXEC) = 0
mmap(0x2815a000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
 0x16000) = 0x2815a000 mmap(0x28162000, 20480, PROT_READ|PROT_WRITE,
 MAP_PRIVATE|MAP_FIXED|MAP_ANON, -1, 0) = 0x28162000 close(3)                
                = 0
access("/usr/lib/libmysqlclient.so.10", F_OK) = -1 ENOENT (No such file or
 directory) access("/usr/lib/compat/libmysqlclient.so.10", F_OK) = -1 ENOENT
 (No such file or directory) access("/usr/X11R6/lib/libmysqlclient.so.10",
 F_OK) = -1 ENOENT (No such file or directory)
 access("/usr/local/lib/libmysqlclient.so.10", F_OK) = -1 ENOENT (No such
 file or directory) access("/usr/local/lib/mysql/libmysqlclient.so.10", F_OK)
 = 0
open("/usr/local/lib/mysql/libmysqlclient.so.10", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=134787, ...}) = 0
read(3, "\177ELF\1\1\1\t\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\300Z\0"..., 4096) =
 4096 mmap(0, 114688, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_NOCORE, 3, 0) =
 0x28167000 mprotect(0x2817e000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x2817e000, 4096, PROT_READ|PROT_EXEC) = 0
mmap(0x2817f000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
 0x17000) = 0x2817f000 close(3)                                = 0
access("/usr/lib/libz.so.2", F_OK)      = 0
open("/usr/lib/libz.so.2", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=52684, ...}) = 0
read(3, "\177ELF\1\1\1\t\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\314\26"..., 4096) =
 4096 mmap(0, 57344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_NOCORE, 3, 0) =
 0x28183000 mprotect(0x2818d000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x2818d000, 4096, PROT_READ|PROT_EXEC) = 0
mmap(0x2818e000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
 0xa000) = 0x2818e000 close(3)                                = 0
access("/usr/lib/libcrypt.so.2", F_OK)  = 0
open("/usr/lib/libcrypt.so.2", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=28720, ...}) = 0
read(3, "\177ELF\1\1\1\t\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0l\16\0\000"..., 4096)
 = 4096 mmap(0, 102400, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_NOCORE, 3, 0) =
 0x28191000 mprotect(0x28197000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x28197000, 4096, PROT_READ|PROT_EXEC) = 0
mmap(0x28198000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
 0x6000) = 0x28198000 mmap(0x28199000, 69632, PROT_READ|PROT_WRITE,
 MAP_PRIVATE|MAP_FIXED|MAP_ANON, -1, 0) = 0x28199000 close(3)                
                = 0
access("/usr/lib/libm.so.2", F_OK)      = 0
open("/usr/lib/libm.so.2", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=118656, ...}) = 0
read(3, "\177ELF\1\1\1\t\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0L0\0\000"..., 4096) =
 4096 mmap(0, 114688, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_NOCORE, 3, 0) =
 0x281aa000 mprotect(0x281c0000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x281c0000, 4096, PROT_READ|PROT_EXEC) = 0
mmap(0x281c1000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
 0x16000) = 0x281c1000 close(3)                                = 0
access("/usr/local/lib/mysql/libz.so.2", F_OK) = -1 ENOENT (No such file or
 directory) access("/usr/lib/libz.so.2", F_OK)      = 0
access("/usr/local/lib/mysql/libcrypt.so.2", F_OK) = -1 ENOENT (No such file
 or directory) access("/usr/lib/libcrypt.so.2", F_OK)  = 0
access("/usr/local/lib/mysql/libm.so.2", F_OK) = -1 ENOENT (No such file or
 directory) access("/usr/lib/libm.so.2", F_OK)      = 0
mmap(0, 28368, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0) = 0x281c6000
munmap(0x281c6000, 28368)               = 0
mprotect(0x28143000, 94208, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mmap(0, 4552, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0) = 0x281c6000
munmap(0x281c6000, 4552)                = 0
mprotect(0x28143000, 94208, PROT_READ|PROT_EXEC) = 0
mmap(0, 3880, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0) = 0x281c6000
munmap(0x281c6000, 3880)                = 0
mmap(0, 968, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0) = 0x281c6000
munmap(0x281c6000, 968)                 = 0
mmap(0, 632, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0) = 0x281c6000
munmap(0x281c6000, 632)                 = 0
mmap(0, 2208, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0) = 0x281c6000
munmap(0x281c6000, 2208)                = 0
sigaction(SIGILL, {0x2812b830, [], 0}, {SIG_DFL}) = 0
sigprocmask(SIG_BLOCK, NULL, [])        = 0
sigaction(SIGILL, {SIG_DFL}, NULL)      = 0
getpid()                                = 26601 (ppid 26600)
sigaction(SIGUSR2, {0x28155d18, [], 0}, NULL) = 0
sigaction(SIGUSR1, {0x28155da4, [], 0}, NULL) = 0
sigprocmask(SIG_BLOCK, [USR2], NULL)    = 0
__sysctl([hw.ncpu], 2, "\1\0\0\0", [4], NULL, 0) = 0
__sysctl([p1003_1b.priority_scheduling], 2, "\1\0\0\0", [4], NULL, 0) = 0
sigprocmask(SIG_BLOCK, ~[ILL TRAP ABRT EMT FPE BUS SEGV SYS], [USR2]) = 0
sigprocmask(SIG_SETMASK, [USR2], NULL)  = 0
break(0x828fadc)                        = 0
profil(0x81f20bc, 0x4ed10, 0x8075fa0, 0x8000) = 0
readlink("/etc/malloc.conf", 0xbfbff960, 63) = -1 ENOENT (No such file or
 directory) mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0)
 = 0x281c6000 break(0x8291000)                        = 0
break(0x8292000)                        = 0
sigprocmask(SIG_SETMASK, NULL, [USR2])  = 0
sigsuspend([] <unfinished ...>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312240127.40834.timothy>