From mboxrd@z Thu Jan 1 00:00:00 1970 From: stefan_seefeld@mentor.com (Stefan Seefeld) Date: Fri, 14 Feb 2014 09:46:26 -0500 Subject: [lttng-dev] [PATCH] Force static_alloc setup to be written into memory In-Reply-To: References: <1392385505-13405-1-git-send-email-paul_woegerer@mentor.com> Message-ID: <52FE2C42.4030005@mentor.com> On 02/14/2014 09:23 AM, Alexander Monakov wrote: > > On Fri, 14 Feb 2014, Paul Woegerer wrote: > >> As explained by Alexander Monakov, dlsym() is defined to be pure, thus the >> compiler is allowed to assume that there is no need to write the changes >> performed by setup_static_allocator() into memory prior to calling dlsym(). >> The added cmm_barrier() forces the compiler to write the changes into memory. >> >> For more details refer to: >> http://lists.lttng.org/pipermail/lttng-dev/2014-February/022389.html > If everyone here agrees that this is a workaround for a glibc bug, please add > a note to that effect in the patch and please notify glibc upstream (again). I'v just submitted https://sourceware.org/bugzilla/show_bug.cgi?id=16585 > FWIW, when toying with a similar code I implemented a different workaround > along the lines of > > #define dlsym glibc_dlsym_proto_lies_about_leafness > #include > #undef dlsym > > extern void *dlsym(void *, const char *); > > > Thus avoiding the need to sprinkle unneeded compiler memory barriers in code. Right, this looks very clean indeed. Stefan -- Stefan Seefeld CodeSourcery / Mentor Graphics http://www.mentor.com/embedded-software/