< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] Weird problem with Mutex


Hi,
 
I was finally able to find a minimal piece of code to reproduce
an issue I am fighting against during the last days. To reproduce
you just need to paste the following code to the start of the
main() function in basicRegister for example:
 

#include "resip/dum/UserAuthInfo.hxx"

resip::SipStack* mStack;
resip::DialogUsageManager* mDum;

mStack = new resip::SipStack();
mDum = new
resip::DialogUsageManager(*mStack);

mDum->addTransport(UDP,5060);
mDum->addTransport(TCP,5060);

UserAuthInfo* msg = new UserAuthInfo("asd","asd","asd","asd");
mDum->post(msg);


Now, the following happens during mDum->post:

in TransactionUser::post(Message* msg), mFifo.add is called.

then in TimeLimitFifo<Msg>::add it constructs the lock object:

Lock::Lock(Lockable & lockable, LockType lockType)

in this constructor, I get an access violation when it tries to
call myLockable.lock();

When I examine the myLockable I can see that the virtual function
pointers seem corrupted:

Usually (that means, when post is called from the dum or stack 
thread in my application) in the vfptr[] array I can see valid pointers,
but in this case they are wrong.

The mID (Windows Critical Section structure) member of the
Mutex (which inherits from Lockable) seems to remain OK,
just the vfptr to the base methods  is wrong.

I don't really have an idea why this is happening and I feel like
banging my head gainst the wall. In my application everything works
fine. If I put a breakpoint in one of these functions during normal
operation (inbound, outbound calls, client registration etc.), the
lockable is always OK, but as soon as I call mDum->post
manually, the lockable seems to be damaged and I get an access
violation exception.

If I compile the application in debug mode, the problem does not exist!

I am using VS 2005. Here are the relevant configuration settings I
am using for basicRegister:

Optimization: Disabled
Inline Function Expansion: Default
Favor Size or Speed: Neither
Omit Frame Pointers: No
Enable String Pooling: No
Runtime Library: Multi-threaded DLL
Buffer security check: Yes

Linker:

Generate Debug Info: Yes
References: Default
Enable COMDAT Folding: Default
Link time Code Generation: Use Link Time CG

I would be very thankful for any comments as I am running out of
ideas on this subject (apart from implementing a simple critical
section directly without the lockable and mutex objects).

Thanks and best regards,

Matthias Moetje

TERASENS GmbH
Augustenstraße 24
80333 Munich
GERMANY
 
Phone:
Fax:
e-mail:
Web:
+49.89.143370-0
+49.89.143370-22
info@xxxxxxxxxxxx
www.terasens.com