4 ms·
I have a vaguely related story of a baffling segfault bug a few months ago. It was in some reference-counting code deep inside the Boost shared pointer implemen
by twic 9y ago
I have a vaguely related story of a baffling segfault bug a few months ago. It was in some reference-counting code deep inside the Boost shared pointer implementation. It wasn't deterministic, and from correlating the crash log with the Boost code, i couldn't see how there could be a dodgy memory access at that point. Poking around with GDB, it seemed fine.
Eventually i realised that i had compiled my application against one version of Boost, and then dynamically linked to a library i had compiled against a different version. This was all due to bad library path hygiene - my OS had one version of Boost installed, and i was trying to use another that i had installed locally, but GCC was ignoring my path options and getting seduced by the system Boost. After this, i learned about the --sysroot flag to GCC, which has helped to prevent this happening again.
So yeah, protip: know what it is you're actually running. Also, never use C/C++.
- danieldk 9y agoIt was in some reference-counting code deep inside the Boost shared pointer implementation. [...] Eventually i realised that i had compiled my application against one version of Boost, and then dynamically linked to a library i had compiled against a different version. Interesting. Boost's shared pointer implementation is header-only. Are they using shared_ptr in an API for a non-header Boost library? https://stackoverflow.com/questions/10334511/why-do-c-libraries-and-frameworks-never-use-smart-pointers/10342299#10342299 https://stackoverflow.com/questions/10334511/why-do-c-librar...
- twic 9y agoThe library i was dynamically linking to was not a Boost library, it was some random other thing, which used Boost and used shared_ptr liberally in its API.