2014-08-08 23:34 GMT+02:00 Richard Hipp>:
> Please continue to test the latest snapshots and report any issues you find.
I already reported this to sqlite-dev, but without test-case exposing the
problem. Here is the test-case, which is 100% reproducable.
And below is a minimal patch which fixes this problem.
=============== main.c ================
#include <sqlite3.h>
int main(){
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE);
int rc = sqlite3_mutex_try(mutex);
if( rc == SQLITE_OK) sqlite3_mutex_leave(mutex);
}
======================================
Compile this using any Windows compiler (MSVC, MinGW, MinGW-w64)
with the following options.e.g.:
i686-w64-mingw32-gcc -o bug.exe -DNTDDI_VERSION=NTDDI_WINBLUE
-D_WIN32_WINNT=0x0400 -DSQLITE_THREADSAFE=1 main.c sqlite3.c
Then simply run "bug.exe", it will crash immediately in the function
sqlite3_win32_is_nt(), because osGetVersionExW is a NULL pointer.
Regards,
Jan Nijtmans
---------- Forwarded message ----------
From: Jan Nijtmans <[email protected]>
Date: 2014-08-05 13:24 GMT+02:00
Subject: Re: SQLite trunk on win32 broken with -DSQLITE_WIN32_NO_ANSI
To: sqlite-dev <[email protected]>
2014-08-03 9:37 GMT+02:00 Jan Nijtmans <[email protected]>:
> Fixed here:
> <http://www.sqlite.org/src/info/ba78265429>
>
> Thanks!
Actually, just discovered that it is still not fixed for
all cases: When SQLITE_WIN32_GETVERSIONEX
is equal to 0 (later MS SDK's), then any call to
sqlite3_win32_is_nt() will crash because the
function osGetVersionExW() is a null pointer ;-(
Suggested patch (current SQLite trunk) below.
Regards,
Jan Nijtmans
Index: src/os_win.c
==================================================================
--- src/os_win.c
+++ src/os_win.c
@@ -413,11 +413,11 @@
** In order to facilitate testing on a WinNT system, the test fixture
** can manually set this value to 1 to emulate Win98 behavior.
*/
#ifdef SQLITE_TEST
LONG volatile sqlite3_os_type = 0;
-#else
+#elif SQLITE_WIN32_GETVERSIONEX
static LONG volatile sqlite3_os_type = 0;
#endif
#ifndef SYSCALL
# define SYSCALL sqlite3_syscall_ptr
@@ -1308,10 +1308,11 @@
/*
** This function determines if the machine is running a version of Windows
** based on the NT kernel.
*/
int sqlite3_win32_is_nt(void){
+#if SQLITE_WIN32_GETVERSIONEX
if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){
#if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WIN8
OSVERSIONINFOW sInfo;
sInfo.dwOSVersionInfoSize = sizeof(sInfo);
osGetVersionExW(&sInfo);
@@ -1322,10 +1323,13 @@
#endif
osInterlockedCompareExchange(&sqlite3_os_type,
(sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0);
}
return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2;
+#else
+ return 1;
+#endif
}
#ifdef SQLITE_WIN32_MALLOC
/*
** Allocate nBytes of memory.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users