From owner-freebsd-threads@freebsd.org Sun Jun 9 21:01:24 2019 Return-Path: Delivered-To: freebsd-threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04FAF15AB709 for ; Sun, 9 Jun 2019 21:01:24 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 8AE67867B6 for ; Sun, 9 Jun 2019 21:01:23 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: by mailman.ysv.freebsd.org (Postfix) id 439F415AB703; Sun, 9 Jun 2019 21:01:23 +0000 (UTC) Delivered-To: threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 315DD15AB702 for ; Sun, 9 Jun 2019 21:01:23 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C3568867A3 for ; Sun, 9 Jun 2019 21:01:22 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id E842B25A2 for ; Sun, 9 Jun 2019 21:01:21 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x59L1L2b011261 for ; Sun, 9 Jun 2019 21:01:21 GMT (envelope-from bugzilla-noreply@FreeBSD.org) Received: (from bugzilla@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x59L1L5I011260 for threads@FreeBSD.org; Sun, 9 Jun 2019 21:01:21 GMT (envelope-from bugzilla-noreply@FreeBSD.org) Message-Id: <201906092101.x59L1L5I011260@kenobi.freebsd.org> X-Authentication-Warning: kenobi.freebsd.org: bugzilla set sender to bugzilla-noreply@FreeBSD.org using -f From: bugzilla-noreply@FreeBSD.org To: threads@FreeBSD.org Subject: Problem reports for threads@FreeBSD.org that need special attention Date: Sun, 9 Jun 2019 21:01:21 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Jun 2019 21:01:24 -0000 To view an individual PR, use: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=(Bug Id). The following is a listing of current problems submitted by FreeBSD users, which need special attention. These represent problem reports covering all versions including experimental development code and obsolete releases. Status | Bug Id | Description ------------+-----------+--------------------------------------------------- Open | 237195 | pthread_mutex_unlock crash as unlocked mutex dest 1 problems total for which you should take action. From owner-freebsd-threads@freebsd.org Tue Jun 11 06:55:33 2019 Return-Path: Delivered-To: freebsd-threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66EAD15B0307 for ; Tue, 11 Jun 2019 06:55:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id F3EEA76F21 for ; Tue, 11 Jun 2019 06:55:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id B7A1F15B0304; Tue, 11 Jun 2019 06:55:32 +0000 (UTC) Delivered-To: threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93E4215B0302 for ; Tue, 11 Jun 2019 06:55:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 30BF576F1F for ; Tue, 11 Jun 2019 06:55:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id 6386914BC1 for ; Tue, 11 Jun 2019 06:55:31 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x5B6tVl5005334 for ; Tue, 11 Jun 2019 06:55:31 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x5B6tV81005332 for threads@FreeBSD.org; Tue, 11 Jun 2019 06:55:31 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: threads@FreeBSD.org Subject: [Bug 238485] Failed to read TLS variables for -static -lpthread executables Date: Tue, 11 Jun 2019 06:55:30 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: threads X-Bugzilla-Version: 12.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: rajendra.sy@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: threads@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jun 2019 06:55:33 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D238485 Bug ID: 238485 Summary: Failed to read TLS variables for -static -lpthread executables Product: Base System Version: 12.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: threads Assignee: threads@FreeBSD.org Reporter: rajendra.sy@gmail.com On any platform build test app as below & print a TLS variable to see the e= rror message. $ clang -static -g -o tls src/tls.c -lpthread ADM64: FreeBSD-12 ----- [amd64-fbsd12] # lldb ./tls (lldb) target create "./tls" Current executable set to './tls' (x86_64). (lldb) b 12 Breakpoint 1: where =3D tls`start_thread + 97 at tls.c:13, address =3D 0x0000000000222341 (lldb) r Process 84810 launching Process 84810 launched: './tls' (x86_64) foo is 0xbad1 boo is 0xcab1 thread sleeping for 5 seconds Process 84810 stopped * thread #2, name =3D 'tls', stop reason =3D breakpoint 1.1 frame #0: 0x0000000000222341 tls`start_thread(in=3D0x00000000004c9ed0) = at tls.c:13 10 boo =3D (*(int *)in)+51888; // 0xcab_ 11 printf("foo is 0x%x boo is 0x%x thread sleeping for 5 seconds\n= ", foo, boo); 12 while (1) { -> 13 sleep(5); 14 break; 15 } 16 return NULL; (lldb) p foo error: Couldn't materialize: couldn't get the value of variable foo: No TLS data currently exists for this thread. error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression RPI-2: FreeBSD-11 ----- rpi2-fbsd11] # /usr/bin/gdb ./tls GNU gdb 6.1.1 [FreeBSD] (gdb) b 12 Breakpoint 1 at 0x84e0: file src/tls.c, line 12. (gdb) r (gdb) p foo Cannot find executable file `/b/syrajendra/test/lldb/test-prgms/step/tls' link_map in dynamic linker's module list [rpi2-fbsd11] # /usr/local/bin/gdb ./tls GNU gdb (GDB) 8.2.1 [GDB v8.2.1 for FreeBSD] (gdb) b 12 Breakpoint 1 at 0x84e0: file src/tls.c, line 12. (gdb) r (gdb) p foo Cannot find thread-local variables on this target ADM64: FreeBSD-11 ------ [amd64-fbsd11] # /usr/local/bin/gdb ./tls GNU gdb (GDB) 8.1 [GDB v8.1 for FreeBSD] (gdb) b 12 Breakpoint 1 at 0x400521: file src/tls.c, line 12. (gdb) r (gdb) p foo Cannot find thread-local variables on this target ****** On Linux: debuggers use these below 2 API's from "thread_db.h" to fetch TLS= var address. 1. For executables with shared libs: td_thr_tls_get_addr() 2. For executables with static libs: td_thr_tlsbase() On FreeBSD, I see only td_thr_tls_get_addr() API. Is possible to add td_thr_tlsbase() API? Or=20 How to get TLS variable address without td_thr_tlsbase() API from a static executable? Here is the tls.c code: #include #include #include #define MAX_THREADS 5 int __thread foo; int __thread boo; void* start_thread(void *in) { foo =3D (*(int *)in)+47824; // 0xbad_ boo =3D (*(int *)in)+51888; // 0xcab_ printf("foo is 0x%x boo is 0x%x thread sleeping for 5 seconds\n", foo, boo); while (1) { sleep(5); break; } return NULL; } int main(void) { pthread_t threads[MAX_THREADS]; int i; static int count[MAX_THREADS]; for (i=3D0; i