![]() ![]() I haven’t done a public-facing writeup on this, but this public-facing writeup shows how to solve a harder version of the same bug. Better to find out now than much farther down the road. On the plus side, I found out that my current backups strategy is potentially vulnerable to corruption, so Ill be switching to dar or dump soon. Here was my fix, which didn’t touch SQLite code at all and instead ensured that, in this code, writes to a file descriptor only happen on the thread that will close the file descriptor. I tried a bunch of different approaches, all of which only partially succeeded, and in the end restored from backups. I then searched for "stop" to find the code that caused the issue. Reading this corrupted area as a sequence of bytes, I saw that someone had written the C string "stop" to the DB, causing the corruption. GDB showed me that an int had a value of 115, which was impossible if only SQLite were writing to the DB file. ![]() I then compiled it with all optimizations off, and stepped through it with GDB. I was able to debug this issue by writing a C program that ran PRAGMA integrity_check on my DB. When you write to a closed file descriptor, you’re playing Russian Roulette with the files you currently have open, and there’s a chance you’ll write unspecified data to an unspecified place in your SQLite DB, instead of writing to the file you wanted to write to. The root cause of the corruption was that unrelated code in HHVM was sometimes writing to a closed file descriptor. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |