On 23 Mar 2018, at 12:54am, Deon Brewis <de...@outlook.com> wrote:

> However, what we see doesn't generally exhibit like the bug describes. The 
> bug as reported gives errors like this:
> "row 1 missing from index idx1"
> 
> Where we instead see things like:
> "database disk image is malformed"
> 
> Can it still be related to the same issue?

I don't think so.  That particular error was not at all caught by the 
'malformed' error you're seeing.  It was reported as a corrupt index.

> In general, is there anything dangerous that you can do in a custom function 
> inside an indexed expression that we need to watch out for?
> 
> Most of the time when the database gets corrupted, we don't crash, it 
> corrupts midway through valid SQL (no pattern to it - completely unrelated 
> SQL). I was thinking if the expression functions have bugs in them it could 
> cause corruption, but can't really imagine how.

Is the function deterministic ?  Is it marked as deterministic when you define 
it ?

<https://www.sqlite.org/c3ref/c_deterministic.html>

> We use sqlite3_result_* functions to report results, and even if we read 
> invalid memory or pass invalid memory to SQLITE, it should crash - not 
> corrupt.

None of this should be happening unless -- please excuse my boldness -- the 
fault is in your own code.  Can you run your code under a tool which checks 
memory allocation and release, just to see if memory really is your problem ?

> We use sqlite3_result_* functions to report results, and even if we read 
> invalid memory or pass invalid memory to SQLITE, it should crash - not 
> corrupt.

To keep things fast, SQLite tends to assume that it itself is sane and doesn't 
do all the checking it could do.  But errors of this sort aren't usually 
difficult to track down.

A possibility you haven't mentioned is bad hardware.  It possible you have no 
software problems at all and your corruption is purely a bad sector in your 
storage medium.  Other than that, you might want to read

<https://www.sqlite.org/howtocorrupt.html>

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to