I give up...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

I give up...

Sean Malloy-2
I've been banging my head against this damned sqlite library. I couldn't get
the squeak version working in dolphin. Someone mentioned to use the callback
features of sqlite, because dolphin supports callbacks nicely.

So I get callback version working. But I get these exceptions occurring.

a GPFault('Invalid access to memory location. Reading 0x68, IP 0x673E691F
(C:\Documents and Settings\Sean\My Documents\Dolphin Smalltalk 5.1\Sean
Malloy\SQLITE.dll)')

I've posted the code (Please note Sqlite Test.st is not unit tests, just a
simple couple of lines to show the error occurring)

http://www.arcturus.com.au/Dolphin_Sqlite.zip

My suspicion was that the callback block was being garbage collected, but
the output to the transcript is actually occurring, so the damn thing IS
being called. So I don't know what the hell is going on.

Anyone offer an explanation as to the cause of the exception?


Reply | Threaded
Open this post in threaded view
|

Re: I give up...

Chris Uppal-3
Sean Malloy wrote:

> So I get callback version working. But I get these exceptions occurring.
>
> a GPFault('Invalid access to memory location. Reading 0x68, IP 0x673E691F
> (C:\Documents and Settings\Sean\My Documents\Dolphin Smalltalk 5.1\Sean
> Malloy\SQLITE.dll)')

I think it's because the sqlite library is using the 'cdecl' calling
convention, rather than 'stdcall' (not that they bother to /tell/ you that
anywhere, not even in the source -- it must be a flag to the compiler).  If you
change SqliteLibrary>>resultForQuery:on:do: to read:

===================
resultForQuery: aString on: sqliteRef do: operation
 | descriptor callback error |
 descriptor := ExternalDescriptor fromString: 'cdecl: sdword void* dword char**
char**'.
 callback := ExternalCallback
    block: [ :a1 :a2 :a3 :a4 | operation value: a2 value: a3 value: a4. 0]
    descriptor: descriptor.
 error := ExternalAddress new.
 self apiExec: sqliteRef sql: aString callback: callback asParameter with: nil
error: error.
 self checkError: error.
===================

then you should be able to move on to the next stage of trying to make sense of
the LPVOIDs (which /always/ confuse me).

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: I give up...

Sean Malloy-2
> I think it's because the sqlite library is using the 'cdecl' calling
> convention, rather than 'stdcall' (not that they bother to /tell/ you that
> anywhere, not even in the source -- it must be a flag to the compiler).
If you
> change SqliteLibrary>>resultForQuery:on:do: to read:
>
> ===================
> resultForQuery: aString on: sqliteRef do: operation
>  | descriptor callback error |
>  descriptor := ExternalDescriptor fromString: 'cdecl: sdword void* dword
char**
> char**'.
>  callback := ExternalCallback
>     block: [ :a1 :a2 :a3 :a4 | operation value: a2 value: a3 value: a4. 0]
>     descriptor: descriptor.
>  error := ExternalAddress new.
>  self apiExec: sqliteRef sql: aString callback: callback asParameter with:
nil
> error: error.
>  self checkError: error.
> ===================
>
> then you should be able to move on to the next stage of trying to make
sense of
> the LPVOIDs (which /always/ confuse me).

Chris,

I've just leveled up. Bonus round time!

Thanks. That was it!!

Regards,

Sean