boost::format concurrency issues on mac intel
I am experiencing some strange errors in a multi-threaded environment on MAC OS X, dual core. I am receiving segfaults, bus errors and illegal instruction crashes regularily with simple calls to boost::format operations. Disabling one of the cores on my machine will completely remove the errors (just fyi). If I add a mutex lock around the calls to boost::format in my sample code (inside the for loop of threadRun) then no problems occur.
The following code can be used to reproduce the crash. It occurs perhaps one out of every 10 runs. It can crash (viewed by CrashReporter) in multiple places, mainly in ::parse(), and operator%.
I compile with -O0. If it would help, I can post the logs from CrashReporter.
#include
The following are two excerpts from the CrashReporter log (template parameters edited out for brevity). Might anyone have any hint or clue as to why we only see this on MAC OS X x86 and not on any other of our platforms?
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000148
Thread 1 Crashed:
0 libSystem.B.dylib 0x901509c2 swap_m88k_thread_state_xrf_t + 965
1 NodeConsole 0x001514a1 void boost::io::detail::put<...>(char const* const&, boost::io::detail::format_item<..> const&, boost::basic_format<..>::string_type&, char::internal_streambuf_t&, std::locale*) + 37 (feed_args.hpp:134)
2 NodeConsole 0x00151d3f void boost::io::detail::distribute<..>(boost::basic_format<..>&, char const* const&) + 279 (feed_args.hpp:239)
3 NodeConsole 0x00151d96 boost::basic_format<..>& boost::io::detail::feed<..>(boost::basic_format<..>&, char const* const&) + 46 (feed_args.hpp:252)
4 NodeConsole 0x00151e3c boost::basic_format<..>& boost::basic_format<..>::operator%
I apologize for replying to myself twice now in an empty thread. But the problem was 'fixed' by compiling the code using the latest GCC 4.2.0 (still in only pre-release stage 3). We were previously using GCC 4.0.1. Just in case anyone else encounters the same error.
participants (1)
-
Matthew Edwards