On Wed, Jul 27, 2016 at 12:39:13AM +0000, Allen Samuels wrote: > I don't think is the problem that John and Kefu described. > > Seems that the problem is that there are two dynamic libraries that think each one of them is responsible for static run-time initialization of the same global variable. This violates the "One Definition Rule". I agree, I believe this is a violation of the ODR as well. > > I'm guessing that the source of the problem is that the AsyncMessager.cc file is included twice, one in each library. If so, then the solution is to break out the offending *.cc file into a separate third library that's linked in the right combination with the others so that there's no duplication. > I believe the problem can also be solved with a static member function or a wrapper function for the static variable. I tried this and it appears to resolve the issue. It would be possible to audit use of such variables using nm or objdump but this might be a bit difficult to maintain? Since this is easy to reproduce it would also be simple to write a test to check for this specific issue along the lines of the following. $ g++ -O2 -x c++ - -Wl,--rpath=./lib -L./lib -lrados -lcephfs<<EOF int main(int, char**) { return 0; } EOF ./a.out *** Error in `./a.out': double free or corruption (fasttop): 0x0000000000ad45c0 *** ... Aborted (core dumped) I'd be happy to create a test that covers this case if we think it is worthwhile? > I have no idea why this appears to work with autotools. > > > Allen Samuels > SanDisk |a Western Digital brand > 951 SanDisk Drive, Milpitas, CA 95035 > T: +1 408 801 7030| M: +1 408 780 6416 > allen.samuels@xxxxxxxxxxx > > > -----Original Message----- > > From: ceph-devel-owner@xxxxxxxxxxxxxxx [mailto:ceph-devel- > > owner@xxxxxxxxxxxxxxx] On Behalf Of Jesse Williamson > > Sent: Tuesday, July 26, 2016 5:12 PM > > To: kefu chai <tchaikov@xxxxxxxxx> > > Cc: John Spray <jspray@xxxxxxxxxx>; ceph-devel@xxxxxxxxxxxxxxx > > Subject: Re: static member variable in libcommon and double free > > > > > > Folks, > > > > I hope this will help. > > > > Three are some issues that you need to know about when you're writing > > computer programs in C++. Before you decide to change away from the > > whole > > structure, consider what it is currently accomplishing. > > > > Here is one of them. It may be exactly what you're running in to: > > https://isocpp.org/wiki/faq/ctors#static-init-order > > > > Please feel free to ask questions. > > > > -Jesse > > > > -- > > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > > the body of a message to majordomo@xxxxxxxxxxxxxxx > > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Cheers, Brad -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html