abouffard / csharp-sqlite

Automatically exported from code.google.com/p/csharp-sqlite
Other
0 stars 0 forks source link

Access to Sqlite3.sqlite3 in second thread causes infinite wait. #159

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
С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

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by noah.hart@gmail.com on 17 May 2012 at 8:45

GoogleCodeExporter commented 9 years ago
This issue was closed by revision c96088cf09ff.

Original comment by noah.hart@gmail.com on 18 May 2012 at 11:15