Recent

Author Topic: Why is an exe not running when Lazarus IDE is not used ?  (Read 5152 times)

WimVan

  • Jr. Member
  • **
  • Posts: 76
Why is an exe not running when Lazarus IDE is not used ?
« on: December 13, 2018, 08:23:04 am »
All,
I have a very strange behavour and I hope someone can help me.
Situation
2 different PC's.
  One with Windows10, Intel I7, 16 GB RAM, 64bit.  I'll name this PC
  The other one is also WIndows10, but i5, 16 GB RAM, 64 bit . A Laptop.  I'll name it laptop
On both I installed the same Lazarus
1.8.4,
SVN; 57972 
X86-64-win64-win32/win64

No extra packages are installed.
Next components are used:
-SQLconnect
-SQLtransaction
-SQLQuery
-Datasource
-DBgrid
-Buttom
Pagecontrol and tabsheets, labels, panels, edit ... and TImage

When I edit sources on the PC and compile them, the application opens and I can test it.
Outside Lazarus, the executable  also runs correct on the PC and on the Laptop
Development of the same application (with the same sources) on the laptop is successful and created exe's runs also on the PC as on the Laptop.
SO far so good.

BUT,  suddenly (I assume when adding a second form to the project) I have a very strange behavour.
1) development on the Laptop and on the PC can be done
But and now it becomes tricky
Any development on the PC is successful.  I can even test the application by compiling and running it in the IDE.
Leaving Lazarus, the created exe is running correct on the PC.
But, when trying to run that exe on the Laptop, the exe is loaded and directly the exe is left. I see a flashup of blank window and directly the exe closes.
2) Move all sources to the Laptop.  When I open Lazarus I can edit the project, sources.
But now, I can't run it.  Compiling is successful without any error-remark.  But, the application just flashes up and closes.  I can't run the exe while developing.
Leaving Lazarus and trying to run the created executable is NOT successful. the exe is loaded and directly the exe is left. I see a flashup of blank window and directly the exe closes.

Someone can help me in this for me severe problem.
In the past I developed several little apps that run on the PC as well on the laptop, even when edited, created on the Laptop.
I think there is a problem with the second form but I'm not sure and I tried to test it, writing new little apps, bt I can not really place when.  The only thing I know, once you can run it no more, you may delete the added form, remove all links to that forms, you can no more run it.  In Lazarus, neither outside Lazarus and NO error is reported.

What the most strange item is, is the fact that the exe that was produced on the LAPTOP and can't been run there, is usable on the PC.  Running the exe there is successful

CCRDude

  • Sr. Member
  • ****
  • Posts: 492
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #1 on: December 13, 2018, 09:18:47 am »
Sounds a lot like a DLL is missing or the wrong version on the laptop. Since you use a database, possibly one of those.

What I would do is use the debugger. Might be tedious, but step through the code line by line, and you'll find the culprit.

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #2 on: December 13, 2018, 01:56:56 pm »
The Lazarus-deployement was and is identical on the Laptop and the PC,
The database is the same (works on an external HD) which is mounted with USB
the database-dll is the same on the Laptop ant the PC.

Next, I'll try the debugger.

wp

  • Hero Member
  • *****
  • Posts: 6140
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #3 on: December 13, 2018, 02:04:27 pm »
Sounds a lot like a DLL is missing or the wrong version on the laptop.
Or an antivirus issue. Antivirus software has become the enemy of software development these days. Do both computers have the same antivirus? Deactivate the antivirus on the laptop and see if it fixes the issue. I had to remove my BitDefender because it used to delete fpc and related tools. I am using now Windows Defender, no problems so far with it (although putting the Lazarus program and project folders on the white list is a MUST here too).
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Thaddy

  • Hero Member
  • *****
  • Posts: 8673
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #4 on: December 13, 2018, 02:16:35 pm »
I am using now Windows Defender, no problems so far with it (although putting the Lazarus program and project folders on the white list is a MUST here too).
Yes? I also use just Windows Defender (which is quite good, actually) I didn't white-list anything. May be an OPM issue? Because I have no issues at all.

I also suspect that a database dll is missing or of the wrong bitness. So what's the database?
« Last Edit: December 13, 2018, 02:18:54 pm by Thaddy »
Most people that want to use threading should learn to patch their jeans first: use a needle.

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #5 on: December 13, 2018, 02:25:51 pm »
Laptop has another Anti-virus (Symantec).  PC has Avast.
But, I run the debugger ....
After a long time I got an error
External SIGILL
Looking further I got the concerned pas
LAZUTF8.PAS
Line 3451

It is a part a a function ...  When looking to it, I saw that even before the begin-statement another function is inserted

The inserted code starts at line 3395, line 3451 is the end; -statement at te bottom of the listed code
Code: Pascal  [Select]
  1. function ConvertUTF8ToUTF16(Dest: PWideChar; DestWideCharCount: SizeUInt;
  2.   Src: PChar; SrcCharCount: SizeUInt; Options: TConvertOptions;
  3.   out ActualWideCharCount: SizeUInt): TConvertResult;
  4. var
  5.   DestI, SrcI: SizeUInt;
  6.   B1, B2, B3, B4: Byte;
  7.   W: Word;
  8.   C: Cardinal;
  9.  
  10.   function UnfinishedCharError: Boolean;
  11.   begin
  12.     if toUnfinishedCharToSymbol in Options then
  13.     begin
  14.       Dest[DestI] := System.WideChar('?');
  15.       Inc(DestI);
  16.       Result := False;
  17.     end
  18.     else
  19.       if toUnfinishedCharError in Options then
  20.       begin
  21.         ConvertUTF8ToUTF16 := trUnfinishedChar;
  22.         Result := True;
  23.       end
  24.       else Result := False;
  25.   end;
  26.  
  27.   function InvalidCharError(Count: SizeUInt): Boolean; inline;
  28.   begin
  29.     if not (toInvalidCharError in Options) then
  30.     begin
  31.       if toInvalidCharToSymbol in Options then
  32.       begin
  33.         Dest[DestI] := System.WideChar('?');
  34.         Inc(DestI);
  35.       end;
  36.  
  37.       Dec(SrcI, Count);
  38.  
  39.       // skip trailing UTF-8 char bytes
  40.       while (Count > 0) do
  41.       begin
  42.         if (Byte(Src[SrcI]) and %11000000) <> %10000000 then Break;
  43.         Inc(SrcI);
  44.         Dec(Count);
  45.       end;
  46.  
  47.       Result := False;
  48.     end
  49.     else
  50.       if toInvalidCharError in Options then
  51.       begin
  52.         ConvertUTF8ToUTF16 := trUnfinishedChar;
  53.         Result := True;
  54.       end;
  55.   end;
  56.  
  57. begin
  58.   ActualWideCharCount := 0;
  59.              
  60.  

Can't stop antivirus because we do not have enough privilages ... So no test on that.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7354
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #6 on: December 13, 2018, 02:28:40 pm »
See if you can add excludes to the antivirus, all dirs that are relevant to lazarus

That is not as watertight as disabling, but it sometimes makes things more bearable.

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #7 on: December 13, 2018, 02:33:57 pm »
All, once more time.
1) Database is Mariadb and is installed and running on an external HD.
2) Used libmysql.dll for the database-access resides on the HD en is also copied into the application-map where the application is developed and is run.
3) Used libmysql.dll is also copied into the lazarus-development-folder
4) The error that I can run the application ... (It starts up and immediately closes) appears

I'll try to make a little schema with the conditions when this strange behavour appears.  I nowhere get an error.

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #8 on: December 13, 2018, 02:40:01 pm »
@marcov
I'll see if I can do this, n-but, it seems very strange to me, that suddenly this things appears after.  I have several applications developped with lazarus that run on the PC and Laptop without any problem.
The problem appears (I think) after adding a second form.  As long I was in developmode, I could test and run the application.
Leaving the Lazarus and restarting I can edit it an run.  I even can run it out the Lazarus-development, so as a stand alone app.
BUT, restarting the laptop and then trying ... I got the strange behavour.  The stand-alone app starts and closes immediately.  Opening Lazarus and trying to run the application ...  No erros, compiled ok, but I got never focus to the app.  It opens and immediately closes ...

So I do not understand why the antivirus in some case renders a problem ...

CCRDude

  • Sr. Member
  • ****
  • Posts: 492
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #9 on: December 13, 2018, 03:50:25 pm »
The biggest ObjectPascal AV issue ever was Delphi using a fixed timestamp (always the same 1992 date) in PE headers. After one Delphi malware was identified by AVs, they took the timestamp as a "perfect heuristic value" and flagged all software ever compiled with Delphi as malware :D

On a broader scope, these poor heuristics is what affects software developers the most. Files that change over time are a typical sign for polymorph viruses trying to avoid detection, so the executables created and recreated by developers share one common thing with malware.

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #10 on: December 13, 2018, 04:40:02 pm »
Updated situation.
When I use another laptop with AVAS on it (same avas as on the PC), the behavour is the same as the other laptop.  Application starts up and closed immediately.
Wen compiling on that laptop, the application does not open.  Only execution broken and returns to development.

Jezus, what a mess, what a mess ...  Time, a huge amount of time lost and still nothing I can deliver to my boss ...
I understand some problems, but he doesn't ...  Just a push-the-button-guy ...

This I can't explain to him.  I made the choice to Lazarus, Free Pascal ...  And yes, I know the Delphi-troubles too.  I once started with Delphi 1, where with Delphi 4 it was a catastrophe.  And any time all components must be revised


Thaddy

  • Hero Member
  • *****
  • Posts: 8673
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #11 on: December 13, 2018, 04:49:48 pm »
Not a mess: missing dll. What database do you expect.
Most people that want to use threading should learn to patch their jeans first: use a needle.

WimVan

  • Jr. Member
  • **
  • Posts: 76
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #12 on: December 13, 2018, 06:21:30 pm »
Nothing missing about Database.  Please read from the start.
libmysql.dll is used for all laptop, PC.  It is the same version.
Mariadb. 3.4.1

I have applications using the same database and they run on the both laptops and PC.  So, I'm sure that is correct.


josh

  • Hero Member
  • *****
  • Posts: 750
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #13 on: December 13, 2018, 06:30:27 pm »
Hi

Can you compile for the win 32 i386 target, does this work? (note you will need the 32bit dll's).

Just a test to see if issue with the x64 exe.


Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

wp

  • Hero Member
  • *****
  • Posts: 6140
Re: Why is an exe not running when Lazarus IDE is not used ?
« Reply #14 on: December 13, 2018, 06:35:55 pm »
Try to find out how far the exe is running on the laptop: Remove the checkmark of "Win32 gui application" on page "Config and target" of the project options, and add WriteLn(<unit name>, <procedure name>) at the beginning of important procedures through which the programm will be running. Then run the exe and watch on the console window which procedures are reached and which are not. For example put such a WriteLn before and after the statement which loads the DLL of the database: if you see only the statement "before", but not the one "after", you know that something is wrong with the DLL.
« Last Edit: December 13, 2018, 06:39:39 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10