From owner-freebsd-questions@FreeBSD.ORG Tue Dec 23 23:27:53 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2150916A4CE for ; Tue, 23 Dec 2003 23:27:53 -0800 (PST) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id 20C3F43D5C for ; Tue, 23 Dec 2003 23:27:48 -0800 (PST) (envelope-from timothy@voidnet.com) Received: from repose (c-24-0-112-81.client.comcast.net[24.0.112.81]) by comcast.net (rwcrmhc11) with SMTP id <20031224072743013006pskte>; Wed, 24 Dec 2003 07:27:47 +0000 From: Eric Timme (by way of Eric Timme ) Date: Wed, 24 Dec 2003 01:27:40 -0600 User-Agent: KMail/1.5.4 To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200312240127.40834.timothy@voidnet.com> Subject: Porting a linuxthreads app to FreeBSD problems X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Dec 2003 07:27:53 -0000 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 --- 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