Сontinuation of bug report:
http://code.google.com/p/csharp-sqlite/issues/detail?id=156
What steps will reproduce the problem?
Attached console application shows problem.
What is the expected output? What do you see instead?
Application should finish succesfully, but instead hangs forever.
What version of the product are you using? On what operating system?
Windows 7 (64-bit), csharp-sqlite_3_7_7_1_71.zip
Problem caused by two bugs:
1. InitializeCriticalSection/DeleteCriticalSection in _Custom.cs should not
take/release ownership of mutex object. It is just initialization/cleanup
procuderes. They are not needed for Monitor.
2. Method winMutexLeave in mutex_w32.cs contains typo.
LeaveCriticalSection( p.mutex ) should be called independently of
condition (p.nRef == 0). In native SQLite version this part looks as follows:
#ifndef NDEBUG
DWORD tid = GetCurrentThreadId();
assert( p->nRef>0 );
assert( p->owner==tid );
p->nRef--;
if( p->nRef==0 ) p->owner = 0;
assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
#endif
LeaveCriticalSection(&p->mutex);
Both bugs cause infinite wait. Attached fixed versions of _Custom.cs and
mutex_w32.cs.
Original issue reported on code.google.com by iyu...@gmail.com on 17 May 2012 at 8:33
Original issue reported on code.google.com by
iyu...@gmail.com
on 17 May 2012 at 8:33Attachments: