[ This is observed on SQLite v 3.8.10.2 but seems to occur in previous versions too) Hits under windows, 64-bit, VS 2012. Not sure about Linux, could be windows only. ]
We are seeing crashes under windows in this usage pattern: Process A opens up sqlite file / WAL mode, in READ-ONLY (SQLITE_OPEN_READONLY ) and issues this pragma: PRAGMA mmap_size=N (N being far larger than the sqlite file opened). It then does a couple of reads. A few msecs later, process B opens up the same sqlite file / WAL mode in READ-WRITE mode (SQLITE_OPEN_READWRITE) without issuing the pragam for mmap_size and writes a little small data into a table of it. The wal file grows (as process A is opening the same file RO), then closes the file and exits cleanly. When process A tries to close the file, it crashes: it finds a WAL file is available and tries to roll it but ends up doing a memcpy into memory area which is page mapped as READ ONLY. The crash does NOT happen if "PRAGMA mmap_size=N" is not issued in process A. Or if the file is opened read-write by both processes. But we can do neither of these: the former improves read performance significantly (and we do not want to lose this); on the latter, we need certain processes to open the file read only, as they do not intend to write any data to it. This looks to be a bug but could also be incorrect usage; but incorrect usage should not cause a crash though. Any suggestion welcome. I am sure someone will request exact code to repro; that would be v hard to rip out of a large app code. Hopefully, the above description reveals some logical issue in the code? Many thanks !