hexresearch / hschain

Other
4 stars 0 forks source link

SQLite API misuse #594

Closed Shimuuar closed 4 years ago

Shimuuar commented 4 years ago
hschain-tests: SQLite3 returned ErrorMisuse while attempting to perform prepare "BEGIN TRANSACTION": bad parameter or other API misuse

It looks like that we have API misuse in how we work with SQLite (9/100) runs of tests has this issue. SQLite documentation considers this a rather serious problem:

SQLITE_MISUSE

The SQLITE_MISUSE return code might be returned if the application uses any SQLite interface in a way that is undefined or unsupported. For example, using a prepared statement after that prepared statement has been finalized might result in an SQLITE_MISUSE error.

SQLite tries to detect misuse and report the misuse using this result code. However, there is no guarantee that the detection of misuse will be successful. Misuse detection is probabilistic. Applications should never depend on an SQLITE_MISUSE return value.

If SQLite ever returns SQLITE_MISUSE from any interface, that means that the application is incorrectly coded and needs to be fixed. Do not ship an application that sometimes returns SQLITE_MISUSE from a standard SQLite interface because that application contains potentially serious bugs.

Part of hunt for #587

Shimuuar commented 4 years ago

311 could be related

Shimuuar commented 4 years ago

After running tests on master for an hour I wasn't able to identify bug. It neverthless happens on CI https://drone.hxr.dev/hexresearch/hschain/1000/1/3 Maybe problem only happens when running with GHC8.6?

Shimuuar commented 4 years ago

N.B, We don't convert ErrorMisuse to exception which is plain wrong!

Peers must connect:                                   
hschain-tests: SQLite3 returned ErrorMisuse while attempting to perform prepare "BEGIN TRANSACTION": bad parameter or other API misuse
hschain-tests: SQLite3 returned ErrorMisuse while attempting to perform prepare "BEGIN TRANSACTION": bad parameter or other API misuse
OK (0.50s)
Shimuuar commented 4 years ago

I take that back. Problem does reproduce on GHC8.4.4

Shimuuar commented 4 years ago

Hopefully fixed by #598