Recent

Author Topic: Lacking error reporting Sqlite?  (Read 2960 times)

Benjiro

  • Guest
Lacking error reporting Sqlite?
« on: July 08, 2017, 02:05:11 am »
Supposed we have a little program under Windows/32 like this:

Code: Pascal  [Select][+][-]
  1. program sqlite;
  2. {$mode objfpc}
  3.  
  4. uses
  5.     sqlite3db, strings, classes;
  6.  
  7. var
  8.   DB: TSQLite;
  9.   SQL: String;
  10. begin
  11.     Writeln('Creating class');
  12.     DB := TSQLite.Create('test.db');
  13.      // .....
  14.     DB.Free;
  15.  

When there is no sqlite3.dll present, you expect a compilation error or the executable to fail. Yet, this compiles correctly with fpc and will execute. But no output is shown ( including no writeln ). It actually eats all errors on the TSQLite.Create, while the exiting the program like nothing had gone wrong. Making it look like the program runs but it becomes unclear as to what the real issue is...

Technically this is very old code but its still included in the example section of FPC. And even worse the DB variable was called MySQL, when it was using Sqlite. Copy and past job without replacing the variables.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Lacking error reporting Sqlite?
« Reply #1 on: July 08, 2017, 01:50:18 pm »
are you sure its the tsqlite that creates the problem and not the writeln? Have you checked the project's options to make sure that the win32 GUI option is not set? IF it is set then there is no console to writeln to.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Benjiro

  • Guest
Re: Lacking error reporting Sqlite?
« Reply #2 on: July 08, 2017, 02:07:52 pm »
are you sure its the tsqlite that creates the problem and not the writeln? Have you checked the project's options to make sure that the win32 GUI option is not set? IF it is set then there is no console to writeln to.

Its run under Visual Studio Code with pure command line Fpc compilation. I have other pieces of code, where this is not a issue. Forcing it to use -WC still result in the same lack of output. Your right, running it as a stand alone executable trigger a GUI error, what makes no sense.

Fpc sqlite.pas
* Console:= No error, no output
* Starting exe from file explorer. Console Box + GUI Error

Fpc -WC sqlite.pas
* Console:= No error, no output
* Starting exe from file explorer. Console Box + GUI Error

Fpc -WG sqlite.pas
* Console:= No error, no output
* Starting exe from file explorer. GUI Error

For some reason, the sqlite3db TSQLite is triggering a GUI despite being compiled to console. Looks like a bug in sqlite3db...

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Lacking error reporting Sqlite?
« Reply #3 on: July 08, 2017, 02:21:30 pm »
if you place a break point in the first writeln does the debuger stop there before the exception? or it never does? If it never does check the initialization sections of the used units something in there triggers the error.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Benjiro

  • Guest
Re: Lacking error reporting Sqlite?
« Reply #4 on: July 08, 2017, 02:43:17 pm »
Seems to be the dynamic library loading that is the issue. When it initializes, it trigger a GUI error and never runs the actual code. So the writeln never gets shown. So your right, the moment it initialises the Sqlite3(db) unit, it trigger this error.

Now is the issue still why a GUI error is triggered. Currently taking a look in the source but still a bit new to Pascal to figure it all out :)

https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/sqlite/src/sqlite3.inc?view=markup

I am not seeing anything related to the GUI. Unless the fpc unit release has been compiled with -WG / GUI, that can also be the issue...

 

TinyPortal © 2005-2018