On 02/14/2014 11:30 AM, Alexander Monakov wrote: > On Thu, 13 Feb 2014, Stefan Seefeld wrote: >> Our compilation unit defines a bunch of functions with external linkage, >> which access cur_alloc. And since gcc has no way to rule out that the >> call to dlsym() will not cause any of these functions to be called, it >> mustn't make any assumptions about whether or not the first >> initialization of cur_alloc is redundant or not, and thus shouldn't >> elide it. > Stefan, LTTng developers, > > The problem here is that glibc declares dlsym() with __attribute__((leaf)) > (see the definition of __THROW in /usr/include/sys/cdefs.h and the difference > from __THROWNL). Presence of the attribute allows the compiler to assume that > no functions from the current compilation unit will be called from dlsym, and > thus there's no need to write back potentially escaping data.
So the CMM_ACCESS_ONCE's I suggested would only be required if dlsym() would call back into the wrapper from another thread, right ? Thanks, Paul > > glibc used to have __THROW annotations on dlopen() as well, and they changed > it to __THROWNL (removing the "leaf" attribute) after it was pointed out that > dlopen will call constructors: > > https://sourceware.org/ml/libc-alpha/2013-08/msg00465.html > > Unfortunately when I pointed out that dlsym is not really "leaf" as well, my > argument was dismissed: > > https://sourceware.org/ml/libc-alpha/2013-09/msg00012.html > > Please consider filing a glibc bug or otherwise reopening that discussion. > > Hope that helps, > Alexander -- Paul Woegerer, SW Development Engineer Sourcery Analyzer <http://go.mentor.com/sourceryanalyzer> Mentor Graphics, Embedded Software Division _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
