On Fri Oct 31, 2003 at 13:05:19 +1100, Tiwari, Rajnish wrote:
>hi All,
>
>       I have a multithreaded c/c++ app containing a simple
>(self-developed)
>       queue. 3 operations -'insert(..)',  'retrieve()' & 'length()'.
>       As part of 'retrieve' a call to 'delete' is made to remove the
>       head of the queue. Only 2 threads ever use this queue - strictly one
>for
>       inserting and another for retrieving ( and yes access is mutex
>protected
>       on all 3 operations ).
>
>       Although very _infrequent_, the problem is that the call
>       to delete in retrieve causes segmentation violation. It is a real
>nuisance as
>       one may run the app many times without fail but on some occassions 
>       it fails. 
>
>       Has anyone encountered/resolved simliar problems in anyother app ? 
>       Could this issue be the result of word alignment ? 
>       I suspect a memory corruption - but I cannot seem to figure out 
>       when/where/how it could happen.
>
>       One characteristic of the app is that this queue is hammered quite
>       intensively - both inserts and retrieves.
>
>       Any hints much appreciated. Thanks in advance.

You have probably corrupted the heap by not having two threads updated
the data structure at the same time. Do you have locks to ensure the threads
aren't trashing stuff?

Benno
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to