public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "konstantin.s.serebryany at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/16291] New: feature request: provide simpler ways to compute stack and tls boundaries Date: Wed, 04 Dec 2013 04:49:00 -0000 [thread overview] Message-ID: <bug-16291-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=16291 Bug ID: 16291 Summary: feature request: provide simpler ways to compute stack and tls boundaries Product: glibc Version: unspecified Status: NEW Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: konstantin.s.serebryany at gmail dot com CC: drepper.fsp at gmail dot com This is both a feature request and a request for a suggestion. We are developing dynamic testing tools like AddressSanitizer and ThreadSanitizer which are now part of both LLVM and GCC distributions. The tools have a run-time library that needs to compute thread's stack and tls boundaries. Right now it is done with a series of ugly hacks. For non-main threads we get the stack boundaries by querying pthread_getattr_np and pthread_attr_getstack. This works, but is problematic because pthread_getattr_np calls malloc and we intercept malloc. For the main thread we get the stack boundaries by querying getrlimit, /proc/self/maps, and an address of a local variable because at the point when we need the info libpthread might not have initialized itself. Getting TLS boundaries is even more involved. Today we use the glibc's private symbol _dl_get_tls_static_info and then subtract a magic constant (size of the glibc's thread descriptor). Most of the code is here: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc?revision=195441 (GetThreadStackTopAndBottom and InitTlsSize) This works for us on a system we are testing (Ubuntu 12.04), but this is very fragile and is often broken on older Linux distros. Is it possible to compute the stack and tls boundaries more reliably today? If not, would it be possible to add some new functions to do that? For every thread (including the main one) we need to know its stack and tls boundaries and the functions that compute it for us should not call malloc or any other public library functions. For the main thread, these functions should work reliably very early (in pre_init functions) -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2013-12-04 4:49 UTC|newest] Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-12-04 4:49 konstantin.s.serebryany at gmail dot com [this message] 2013-12-04 9:19 ` [Bug libc/16291] " bugdal at aerifal dot cx 2013-12-04 9:34 ` konstantin.s.serebryany at gmail dot com 2013-12-04 9:56 ` bugdal at aerifal dot cx 2013-12-04 10:24 ` konstantin.s.serebryany at gmail dot com 2013-12-04 14:35 ` neleai at seznam dot cz 2013-12-04 14:49 ` konstantin.s.serebryany at gmail dot com 2013-12-04 15:46 ` bugdal at aerifal dot cx 2013-12-04 17:20 ` konstantin.s.serebryany at gmail dot com 2013-12-04 17:33 ` bugdal at aerifal dot cx 2013-12-05 3:54 ` konstantin.s.serebryany at gmail dot com 2013-12-11 11:01 ` konstantin.s.serebryany at gmail dot com 2013-12-11 15:14 ` bugdal at aerifal dot cx 2014-01-16 15:07 ` carlos at redhat dot com 2014-01-22 8:50 ` eugeni.stepanov at gmail dot com 2014-01-22 19:54 ` earthdok at google dot com 2014-01-23 15:45 ` konstantin.s.serebryany at gmail dot com 2014-01-23 15:57 ` konstantin.s.serebryany at gmail dot com 2014-01-23 16:07 ` ppluzhnikov at google dot com 2014-01-24 8:46 ` konstantin.s.serebryany at gmail dot com 2014-01-27 1:28 ` bugdal at aerifal dot cx 2014-01-27 7:16 ` konstantin.s.serebryany at gmail dot com 2014-01-29 10:00 ` konstantin.s.serebryany at gmail dot com 2014-01-29 10:26 ` bugdal at aerifal dot cx 2014-01-29 10:40 ` konstantin.s.serebryany at gmail dot com 2014-01-29 14:25 ` bugdal at aerifal dot cx 2014-01-29 15:23 ` konstantin.s.serebryany at gmail dot com 2014-01-29 18:21 ` bugdal at aerifal dot cx 2014-01-29 18:35 ` konstantin.s.serebryany at gmail dot com 2014-01-29 18:50 ` earthdok at google dot com 2014-01-30 5:10 ` bugdal at aerifal dot cx 2014-01-30 5:13 ` konstantin.s.serebryany at gmail dot com 2014-01-30 19:06 ` earthdok at google dot com 2014-01-30 19:21 ` carlos at redhat dot com 2014-01-30 19:43 ` earthdok at google dot com 2014-01-31 5:05 ` konstantin.s.serebryany at gmail dot com 2014-01-31 5:31 ` carlos at redhat dot com 2014-01-31 5:50 ` konstantin.s.serebryany at gmail dot com 2014-01-31 6:08 ` carlos at redhat dot com 2014-01-31 7:02 ` konstantin.s.serebryany at gmail dot com 2014-01-31 8:57 ` carlos at redhat dot com 2014-01-31 19:00 ` carlos at redhat dot com 2014-01-31 19:23 ` fche at redhat dot com 2014-01-31 19:40 ` bugdal at aerifal dot cx 2014-01-31 20:43 ` carlos at redhat dot com 2014-01-31 22:33 ` earthdok at google dot com 2014-02-03 8:14 ` konstantin.s.serebryany at gmail dot com 2014-02-03 9:11 ` octoploid at yandex dot com 2014-02-03 14:35 ` carlos at redhat dot com 2014-02-03 15:59 ` bugdal at aerifal dot cx 2014-02-04 14:18 ` konstantin.s.serebryany at gmail dot com 2014-02-04 14:30 ` joseph at codesourcery dot com 2014-02-04 18:50 ` bugdal at aerifal dot cx 2014-02-04 19:08 ` konstantin.s.serebryany at gmail dot com 2014-04-04 8:50 ` konstantin.s.serebryany at gmail dot com 2014-04-04 20:43 ` carlos at redhat dot com 2014-04-22 10:24 ` konstantin.s.serebryany at gmail dot com 2014-06-13 11:48 ` fweimer at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-16291-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).