Closed tenko closed 2 years ago
I tried your code both on Mono and C and both versions return
Begin
Start
Finish
End
It seems that Sqlite.open("test.db", db)
even then returns OK if the file doesn't exist. Therefore raise() is never called.
Thanks for looking into this.
I believe you need to open a location without access or not existing like Sqlite.open("f:\test.db", db) where f: is not a valid location, otherwise it will create a new file or open an existing.
Got a traceback from GDB
Reading symbols from ./build/Test.exe...
(gdb) run
Starting program: C:\msys64\home\rute\tmp\oberonSqlite\build\Test.exe
[New Thread 9724.0x2f40]
[New Thread 9724.0x27a8]
[New Thread 9724.0x938]
[New Thread 9724.0x267c]
[New Thread 9724.0x2e74]
[New Thread 9724.0x59c]
Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff9f4c02cdb in msvcrt!_setjmp () from C:\Windows\System32\msvcrt.dll
I changed the proc tryDB line 11 to if Sqlite.open("f:/test.db", db) # Sqlite.OK then
and again run the program in Mono and compiled with gcc -O2 (on my Linux i386 machine); both seem to work; I get this output:
Begin
Start
unable to open database file
End
Since we already saw an issue with your mingw 12.x installation, maybe there are other ones; can you try with the MSVC compiler or with CLANG or with an older mingw? I will try to compile and run the code on some other compilers/platforms too.
EDIT: please note that there is yet another place where an explicit "extern" might be necessary; see in Test.h the line with struct Test2DBError$Class$ Test$DBError$class$;
If the compiler has a linkage issue maybe the accessed memory is wrongly initialized, which could explain the segmentation fault.
I tried with extern added to the line struct Test2DBError$Class$ Test$DBError$class$;
, but with the same result.
I will look into other compilers.
I found the issue: the OBX$PushJump() body in OBX.Runtime.c is missing the return statement; add return j;
to the end of the body; amazingly the code worked on Linux even though (and GCC not even put out a warning); just found it because I compiled and run on Windows with the MSVC compiler (which issued a warning).
Just pushed some fixes.
Excellent. I can confirm with the latest commit everything works as expected.
With the same Sqlite wrapper a simple test of pcall/raise seems to fail and return error 127 when run:
Nothing gets printed, so probably something crashed before entering the main function.