c++ - Solaris thread contention on memory allocation and synchronization -


i getting sigsegv on memory contention in multithreaded c++ application on solaris 10. snippets of pstack of core shown below:

-----------------  lwp# 4 / thread# 4  --------------------  ff14cc20 memcntl  (e6400000, 653b8c0, 4, 0, 1, fffc00) + 8  001e4b38 msync__7mmapmgri (fb7ffd9c, 1, 0, ff1b9330, 1, ff1b3a20) + 84  001e4a8c rmmap__7mmapmgr (fb7ffd9c, fb7ffd9c, ff1b5900, 0, fc551200, 0) + 48  00159c08 droprecs__12reconinitmgr (fb7ffd78, 30b400, 506608, 0, fc551200, ff120400) + 1c  00159af8 _._12reconinitmgr (fb7ffd78, 2, 176950, 7a8da0, b4, 1) + 1c  0015afec preprocessinitlegs__8cdrreconrct6vector2zt12basic_string3zczt18string_char_traits 1zczt24__default_alloc_template2b0i0zt9allocator1zt12basic_string3zczt18string_char_traits1 zczt24__default_alloc_template2b0i0 (508058, fb7ffe70, 506668, 218a88, 15, 508bb8) + 368  0015a95c comparelegsbyswitch1__8cdrreconi (508058, 15, ff1b5900, 0, fc551200, ff142a78) + 300  00161c3c comparatorconsumer__8cdrrecon (508058, 161ab4, 0, 0, fc551200, 1) + 188  0011c760 processforcomp__fpv (508058, fb800000, 0, 0, 11c71c, 1) + 44  ff1494f0 _lwp_start (0, 0, 0, 0, 0, 0) -----------------  lwp# 5 / thread# 5  --------------------  ff14d1e4 _lwp_kill (6, 0, ff1b5090, ff12c928, ffffffff, 6) + 8  ff0c1bac abort    (1e5bf8, 1, 2534f4, ee930, ff1b34d8, 0) + 110  001e5d38 corehandler__7cdrsigsi (b, 0, faffeb18, 1, 0, 0) + 140  ff14961c __sighndlr (b, 0, faffeb18, 1e5bf8, 0, 1) + c  ff13dce8 call_user_handler (b, 0, 4, 0, fc551a00, faffeb18) + 3b8  ff13ded0 sigacthandler (b, 0, faffeb18, 11, 0, 0) + 60  --- called signal handler signal 11 (sigsegv) ---  001307cc allocate__t24__default_alloc_template2b0i0ui (20, 20, 30aad0, 1, 11, 0) + a4  0011e2cc __nw__q2t12basic_string3zczt18string_char_traits1zczt24__default_alloc_template2b 0i0_3repuiui (10, 10, 0, 0, 0, 0) + 14  0011e30c create__q2t12basic_string3zczt18string_char_traits1zczt24__default_alloc_template 2b0i0_3repui (a, a, 0, 0, 0, 0) + 24  0011e6d0 replace__t12basic_string3zczt18string_char_traits1zczt24__default_alloc_template2 b0i0uiuipccui (fafff608, 0, ffffffff, fafff6e0, a, 80808080) + 114  00134504 assign__t12basic_string3zczt18string_char_traits1zczt24__default_alloc_template2b 0i0pccui (fafff608, fafff6e0, a, 0, 0, 0) + 24  0013328c assign__t12basic_string3zczt18string_char_traits1zczt24__default_alloc_template2b 0i0pcc (fafff608, fafff6e0, 0, 0, 4e7ce8, ff1b03d8) + 24  0012ff84 __t12basic_string3zczt18string_char_traits1zczt24__default_alloc_template2b0i0pcc  (fafff608, fafff6e0, ff1b554c, 14, ff1b4fe8, ff1b5670) + 28  00201d70 addfile__12recordwriterpcct1i (1440b60, fafff6e0, fafff810, 11, 242000, ff1b554c)  + 138  00201954 write__12recordwriterpcvuiuii (1440b60, fafffa50, b8, 1, 11, 0) + 384 

my strong suspect msync / memcntl having contention new/allocate on basic_string. because, memory allocation routines not thread-safe. contention occurs not every time, in non-deterministic way, when there no such contention, application runs smoothly without trouble. question how avoid contention? if put mutex semaphore guard should put it? should have custom new / malloc may put mutex guard custom msync, possibly? there other way? thoughts, please.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -