pharo-users@lists.pharo.org

Any question about pharo is welcome

View all threads

SQLite3 primitiveFailed after FFI call

EM
Esteban Maringolo
Fri, Apr 30, 2021 12:11 PM

Hi all,

I'm having a strange issue when executing a query with the SQLite3
driver (via GLORP).

In:
SQLite3Library>>#apiPrepare: dbHandle withSQLText: anSQLText with:
textSize with: sHandle with: tail
"int sqlite3_prepare_v2(sqlite3*, const char*, int, sqlite3_stmt**,
const char **)"

^ self ffiCall: #(int sqlite3_prepare_v2 (sqlite3* dbHandle, String
anSQLText, int textSize, sqlite3_stmt** sHandle, const char** tail))

After the FFI call, I get a primitive failed error when some part of
the FFI machinery sends instVarAt: index to the undefined object.

This is the call stack:
PrimitiveFailed(Exception)>>signal
PrimitiveFailed class(SelectorException class)>>signalFor:
UndefinedObject(ProtoObject)>>primitiveFailed:
UndefinedObject(ProtoObject)>>primitiveFailed
UndefinedObject(Object)>>instVarAt:
SQLite3Library>>apiPrepare:withSQLText:with:with:with:
SQLite3Library>>prepare:on:with:
SQLite3PreparedStatement>>prepare:
SQLite3Connection(SQLite3BaseConnection)>>prepare:
SQLite3Connection>>execute:with:
SQLite3Driver>>basicExecuteSQLString:binding:
SQLite3Driver>>basicExecuteSQLString:
PharoDatabaseAccessor>>basicExecuteSQLString:
PharoDatabaseAccessor>>executeCommandUnbound:
QuerySelectCommand(DatabaseCommand)>>executeUnboundIn:

If I run the same query via an external SQL tool (sqlite3) it works,
returning a single row with a single value as expected.

What's weird is that this doesn't fail always, since it's a very
common query in the app.

Any ideas?

Esteban A. Maringolo

Hi all, I'm having a strange issue when executing a query with the SQLite3 driver (via GLORP). In: SQLite3Library>>#apiPrepare: dbHandle withSQLText: anSQLText with: textSize with: sHandle with: tail "int sqlite3_prepare_v2(sqlite3*, const char*, int, sqlite3_stmt**, const char **)" ^ self ffiCall: #(int sqlite3_prepare_v2 (sqlite3* dbHandle, String anSQLText, int textSize, sqlite3_stmt** sHandle, const char** tail)) After the FFI call, I get a primitive failed error when some part of the FFI machinery sends instVarAt: index to the undefined object. This is the call stack: PrimitiveFailed(Exception)>>signal PrimitiveFailed class(SelectorException class)>>signalFor: UndefinedObject(ProtoObject)>>primitiveFailed: UndefinedObject(ProtoObject)>>primitiveFailed UndefinedObject(Object)>>instVarAt: SQLite3Library>>apiPrepare:withSQLText:with:with:with: SQLite3Library>>prepare:on:with: SQLite3PreparedStatement>>prepare: SQLite3Connection(SQLite3BaseConnection)>>prepare: SQLite3Connection>>execute:with: SQLite3Driver>>basicExecuteSQLString:binding: SQLite3Driver>>basicExecuteSQLString: PharoDatabaseAccessor>>basicExecuteSQLString: PharoDatabaseAccessor>>executeCommandUnbound: QuerySelectCommand(DatabaseCommand)>>executeUnboundIn: If I run the same query via an external SQL tool (sqlite3) it works, returning a single row with a single value as expected. What's weird is that this doesn't fail always, since it's a very common query in the app. Any ideas? Esteban A. Maringolo