Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-05 Thread Marcus Grimm
>> > change this code: >> > typedef struct NiuRoutingStruct { >> > sqlite3_vtab vtab; >> > } NiuRouting; >> > to this: >> > struct NiuRouting : public sqlite3_vtab vtab { >> > ... // your implementation, eventually >> > }; >> > >> > This way, the casting is

[sqlite] Segmentation fault on sqlite3_create_module

2012-02-04 Thread larry_brasfield
> > change this code: > > typedef struct NiuRoutingStruct { > > sqlite3_vtab vtab; > > } NiuRouting; > > to this: > > struct NiuRouting : public sqlite3_vtab vtab { > > ... // your implementation, eventually > > }; > > > > This way, the casting is unnecessary

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Marcus Grimm
> Stephan Beal wrote: >> 2012/2/3 Jorge Eliécer Osorio Caro >> >> >*ppVTab = (sqlite3_vtab*) nr; >> > ((sqlite3_vtab*) nr)->zErrMsg = NULL; >> > >> >> Please try changing those to the variants from my previous post. i'm not >> 100% convinced that that cast is strictly

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Larry Brasfield
Stephan Beal wrote: 2012/2/3 Jorge Eliécer Osorio Caro >*ppVTab = (sqlite3_vtab*) nr; > ((sqlite3_vtab*) nr)->zErrMsg = NULL; > Please try changing those to the variants from my previous post. i'm not 100% convinced that that cast is strictly legal in C++. It will

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Larry Brasfield
Marcus wrote: >> So, you might have a calling convencion issue... >> >> Just a guess, though. > > The sqlite3.h header has proper, "extern "C" {" wrappers around its > declarations, guarded by "#ifdef __cplusplus", so this is not an issue. > It is perfectly reasonable to call into the SQLite

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Marcus Grimm
> Marcus wrote: >> Just a guess: >> It looks you are compiling/using c++, on Windows that wouldn't work >> if the sqlite library is compiled as C (which is the usual case). >> >> So, you might have a calling convencion issue... >> >> Just a guess, though. > > The sqlite3.h header has proper,

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Larry Brasfield
Marcus wrote: Just a guess: It looks you are compiling/using c++, on Windows that wouldn't work if the sqlite library is compiled as C (which is the usual case). So, you might have a calling convencion issue... Just a guess, though. The sqlite3.h header has proper, "extern "C" {" wrappers

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Marcus Grimm
> Hi, > > I do this: > > const char *table_structure = "CREATE TABLE network (vertex_id INTEGER);"; > if (sqlite3_declare_vtab(db, table_structure) == SQLITE_OK) { > nr = (NiuRouting*) sqlite3_malloc(sizeof (NiuRouting)); > > if (nr == NULL) { >

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Stephan Beal
2012/2/3 Jorge Eliécer Osorio Caro >*ppVTab = (sqlite3_vtab*) nr; > ((sqlite3_vtab*) nr)->zErrMsg = NULL; > Please try changing those to the variants from my previous post. i'm not 100% convinced that that cast is strictly legal in C++.

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Jorge Eliécer Osorio Caro
Hi, I do this: const char *table_structure = "CREATE TABLE network (vertex_id INTEGER);"; if (sqlite3_declare_vtab(db, table_structure) == SQLITE_OK) { nr = (NiuRouting*) sqlite3_malloc(sizeof (NiuRouting)); if (nr == NULL) { //*pzErr =

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Stephan Beal
On Fri, Feb 3, 2012 at 8:25 PM, Stephan Beal wrote: > i take that back - if that were the case then the crash would almost > certainly happen later on (after your init routine returns). But it still > can't hurt to try. > But please try this: nr = (NiuRouting*)

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Stephan Beal
On Fri, Feb 3, 2012 at 8:22 PM, Stephan Beal wrote: > sqlite3_declare_vtab()[1] does not document the lifetime requirements of > the string passed to it, and it's "conceivable" that the lifetime of the > table_structure string is the problem. > i take that back - if that

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Stephan Beal
2012/2/3 Jorge Eliécer Osorio Caro > Yes, that's my code: > > http://paste.ideaslabs.com/show/OPNHBY7xPG > > this the backtrace: > > #0 0x0001001701d3 in initialize_niurouting () > Can you try the following (but i'm just guessing here); std::cerr <<

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Jorge Eliécer Osorio Caro
Yes, that's my code: http://paste.ideaslabs.com/show/OPNHBY7xPG this the backtrace: #0 0x0001001701d3 in initialize_niurouting () #1 0x0001001709d5 in sqlite3_extension_init () #2 0x0001000499a3 in sqlite3_load_extension (db=0x100200090, zFile=0x10020f206

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Stephan Beal
2012/2/3 Jorge Eliécer Osorio Caro > OK there is the trace: > > Program received signal EXC_BAD_ACCESS, Could not access memory. > Reason: KERN_INVALID_ADDRESS at address: 0x03b8 > 0x00010017024b in initialize_niurouting () > That's the reason for

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Jorge Eliécer Osorio Caro
OK there is the trace: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x03b8 0x00010017024b in initialize_niurouting () 2012/2/3 Stephan Beal > 2012/2/3 Jorge Eliécer Osorio Caro

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Stephan Beal
2012/2/3 Jorge Eliécer Osorio Caro > Ok, tthanks Stepha, how i can do that? i compile sqlite like ./configure > --enable-debug but i cant do a trace to see what happend > Assuming you're on a Linux (or similar) platform you can try: gdb --args sqlite3 dbfile then

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Jorge Eliécer Osorio Caro
Ok, tthanks Stepha, how i can do that? i compile sqlite like ./configure --enable-debug but i cant do a trace to see what happend 2012/2/3 Stephan Beal > But finding out exactly where it fails requires either adding debug output > to the plug or running it (in this case

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Stephan Beal
But finding out exactly where it fails requires either adding debug output to the plug or running it (in this case the sqlite shell) through a debugger. - stephan beal http://wanderinghorse.net/home/stephan/ http://gplus.to/sgbeal On Feb 3, 2012 4:35 PM, "Jorge Eliécer Osorio Caro" <

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Jorge Eliécer Osorio Caro
It's caused calling a sqlite_create_module trying to load an extension by sqlite3 shell. 2012/2/3 Stephan Beal > 2012/2/3 Jorge Eliécer Osorio Caro > > > Good morning every one, > > > > I having a issue when try to create a

Re: [sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Stephan Beal
2012/2/3 Jorge Eliécer Osorio Caro > Good morning every one, > > I having a issue when try to create a sqlite3_create_module. > > when try to load my extension im getting that error "Segmentation fault", > cause the sqlite3 cash. i dont know how it happend its my

[sqlite] Segmentation fault on sqlite3_create_module

2012-02-03 Thread Jorge Eliécer Osorio Caro
Good morning every one, I having a issue when try to create a sqlite3_create_module. when try to load my extension im getting that error "Segmentation fault", cause the sqlite3 cash. i dont know how it happend its my code: http://paste.ideaslabs.com/show/OPNHBY7xPG