Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Segfault while using BiVector (Locking is too slow, suggestions?)
Segfault while using BiVector [message #56721] Tue, 06 April 2021 19:51 Go to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
I'm using a BiVector as a multimedia queue. I'm a noob as far as this stuff is concerned but what happens is I have a frame of audio/video that serves as a wrapper. Anyway I found out rather quickly that I can't use item& AddHead() method on BiVector because another thread will see it's inserted but not fully initialized and then try to dereference a null pointer. So I construct it, initialize it first and then insert it using pick, taking care that I set the prior reference to nullptr after the move so it won't try to delete it at the end of the loop.

Problem is it still seems to be doing it even when I do AddHead(item&&). I have been able to make it work using INTERLOCK but the demands on the queue are so high that it never fills up beyond one item with the locking added and I end up dropping many frames. I haven't looked at the code for BiVector yet (so forgive me if I'm wrong) but from the behavior I'm indirectly observing the container count seems to increment before the container actually "owns" the data unless I'm doing something wrong - which is probably more likely.

Re: Segfault while using BiVector [message #56722 is a reply to message #56721] Tue, 06 April 2021 21:51 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
OK, the problem seems to have manifested with ReAlloc. I reserved a bunch of elements and the problem went away.
Re: Segfault while using BiVector [message #56723 is a reply to message #56722] Wed, 07 April 2021 05:21 Go to previous message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
Nope, I was completely wrong. Oh well, that's multithreading for you. Very Happy
Fix ended up being what I started with - Mutexes, but making them more fine-grained.
Previous Topic: code to more than one database and your threads
Next Topic: httprequest fails getting entire url content
Goto Forum:
  


Current Time: Thu Mar 28 13:49:44 CET 2024

Total time taken to generate the page: 0.02115 seconds