Why is an exe not running when Lazarus IDE is not used ? lazarus / 67-Windows ---------------------------------------------------------------------- WimVan · 2018-12-13 07:23 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 · 2018-12-13 08:18 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 · 2018-12-13 12:56 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 · 2018-12-13 13:04 Quote from: CCRDude on December 13, 2018, 09:18:47 amSounds 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). ---------------------------------------------------------------------- Thaddy · 2018-12-13 13:16 Quote from: wp on December 13, 2018, 02:04:27 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? ---------------------------------------------------------------------- WimVan · 2018-12-13 13:25 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function ConvertUTF8ToUTF16(Dest: PWideChar; DestWideCharCount: SizeUInt;  Src: PChar; SrcCharCount: SizeUInt; Options: TConvertOptions;  out ActualWideCharCount: SizeUInt): TConvertResult;var  DestI, SrcI: SizeUInt;  B1, B2, B3, B4: Byte;  W: Word;  C: Cardinal;   function UnfinishedCharError: Boolean;  begin    if toUnfinishedCharToSymbol in Options then    begin      Dest[DestI] := System.WideChar('?');      Inc(DestI);      Result := False;    end    else      if toUnfinishedCharError in Options then      begin        ConvertUTF8ToUTF16 := trUnfinishedChar;        Result := True;      end      else Result := False;  end;   function InvalidCharError(Count: SizeUInt): Boolean; inline;  begin    if not (toInvalidCharError in Options) then    begin      if toInvalidCharToSymbol in Options then      begin        Dest[DestI] := System.WideChar('?');        Inc(DestI);      end;       Dec(SrcI, Count);       // skip trailing UTF-8 char bytes      while (Count > 0) do      begin        if (Byte(Src[SrcI]) and %11000000) <> %10000000 then Break;        Inc(SrcI);        Dec(Count);      end;       Result := False;    end    else      if toInvalidCharError in Options then      begin        ConvertUTF8ToUTF16 := trUnfinishedChar;        Result := True;      end;  end; begin  ActualWideCharCount := 0;          Can't stop antivirus because we do not have enough privilages ... So no test on that. ---------------------------------------------------------------------- marcov · 2018-12-13 13:28 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 · 2018-12-13 13:33 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 · 2018-12-13 13:40 @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 · 2018-12-13 14:50 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 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 · 2018-12-13 15:40 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 · 2018-12-13 15:49 Not a mess: missing dll. What database do you expect. ---------------------------------------------------------------------- WimVan · 2018-12-13 17:21 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 · 2018-12-13 17:30 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. ---------------------------------------------------------------------- wp · 2018-12-13 17:35 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(, ) 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. ---------------------------------------------------------------------- WimVan · 2018-12-13 19:12 @Josh I did the test.  Nothing is resolved.  While compiling a cmd-box opens and I see a quick run of messages ...  to quick to follow. cmd-box closes automatically and popup of application and closing immediately.  No error-message seen. @wp I'll try it, but whom procedures must I change by inserting the writeln ... ? procedures of the application, or even procedures called in existent units ? If the last one, how can obtain a list of all procedures whom are used ? When I trace step by step while compiling I get out in LAZutf8.pas at line 3451, erro-message: External SIGILL ---------------------------------------------------------------------- wp · 2018-12-13 19:31 Ah, I forgot that you can step through the code with the debugger. Then the WriteLn's can be avoided. When the debugger stops with the error in LazUTF8 you should look at the stack-trace: View > Debug windows > Call stack. It shows the crashing line at the top, and, going down, the code lines which were called by the preceding line. Look at the source code at or before these lines and try to find if there is something strange. The error probably means that one of the PChar or PWideChar arguments of the Convert... function points to unassigned memory. ---------------------------------------------------------------------- WimVan · 2018-12-13 20:43 Remark: I did that step to step-debugging already. I let de debugger compile till the formcreate (*************-mark)  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ********************** procedure TMASTERform.FormCreate(Sender: TObject);var  cFile, cappl : string;  ntmp : integer;begin##############  cappl := ExtractFileName( Application.ExeName);  ntmp  := length(cappl)  ;  cappl := copy( cappl, 1, ntmp - 4);  cFile := ExtractFilePath( Application.ExeName) + cappl + '.def';  The debugger stops at (second marker###################) and from there I step throw the code ... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program collectie_beheer; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, collectie_beheer_1, collection_image_viewer  { you can add units after this }; {$R *.res} begin  RequireDerivedFormResource:=True;***********  Application.Initialize;  Application.CreateForm(TMASTERform, MASTERform);  Application.CreateForm(TVIEWERform, VIEWERform);  Application.Run;end.  Then I step further ... Application.inc is already open where the last procedures compiled successfully: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {---------- --------------------------------------------------------------------  Method: TApplication.GetTitle  Returns: title of application --------- ---------------------------------------------------------------------} function TApplication.GetTitle: string;begin  Result := inherited Title;  if Result = '' then    Result := ExtractFileNameOnly(GetExeName);end; Then LazUTF8.pas is used and the debugger jumps to line 3734 (marker) I can step further where at the second  line (indicated with ######### the debugger stops with the error : External SIGILL Hitting OK gives me the line 3451 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {---------- --------------------------------------------------------------------  Name:    UTF8ToUTF16  Params:  S - Source UTF-8 string  Returns: UTF-16 encoded string   Converts the specified UTF-8 encoded string to UTF-16 encoded (system endian)  Avoid copying the result string since on windows a widestring requires a full  copy ------------------------ ------------------------------------------------------}*********** function UTF8ToUTF16(const S: AnsiString): UnicodeString;begin  Result:=UTF8ToUTF16(PChar(S),length(S));end; function UTF8ToUTF16(const P: PChar; ByteCnt: SizeUInt): UnicodeString;var  L: SizeUInt;begin  if ByteCnt=0 then    exit('');  SetLength(Result, ByteCnt);  // wide chars of UTF-16 <= bytes of UTF-8 string#############  if ConvertUTF8ToUTF16(PWideChar(Result), Length(Result) + 1, P, ByteCnt,    [toInvalidCharToSymbol], L) = trNoError  then SetLength(Result, L - 1)  else Result := '';end;  I copied the function in LAZUTF8.pas where the debuggers finally stops and hitting F7 again I got the message execution broken ... wihtout an error-message. Line 3451 is marked in red ! Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   function InvalidCharError(Count: SizeUInt): Boolean; inline;  begin    if not (toInvalidCharError in Options) then    begin      if toInvalidCharToSymbol in Options then      begin        Dest[DestI] := System.WideChar('?');        Inc(DestI);      end;       Dec(SrcI, Count);       // skip trailing UTF-8 char bytes      while (Count > 0) do      begin        if (Byte(Src[SrcI]) and %11000000) <> %10000000 then Break;        Inc(SrcI);        Dec(Count);      end;       Result := False;    end    else      if toInvalidCharError in Options then      begin        ConvertUTF8ToUTF16 := trUnfinishedChar;        Result := True;      end;  end; **************  begin  ActualWideCharCount := 0;   if not Assigned(Src) then  begin    Result := trNullSrc;    Exit;  end;   if not Assigned(Dest) then  begin    Result := trNullDest;    Exit;  end;  SrcI := 0;  DestI := 0;  I hope this brings us somewhat further. ---------------------------------------------------------------------- rvk · 2018-12-13 21:37 Still think the problem is not in code. Is the location of the database on the same.path with both pc and laptop? If not, how are you filling those values (for databasepath/name)? Do you have any connection.active set to true in design time or is active false and you set it in run-time? Ps. Why do you, as a developer, don't have access to the antivirus- settings? ---------------------------------------------------------------------- WimVan · 2018-12-13 22:06 database is installed and running on an external HD.  Driveletter F: On the laptop 1, and Laptop 2 and the PC, taht external disk is knwon as the F-drive. Databse Mariadb is started up on the F:-disk So, whatever I use, the database is the same, paths are the same .. used libmysql.dll is the same. Why I have no priviledge to stop the anti-virus or modify it behaviour ?  Simple, that laptop resides in the network of the company where I work.  It is a request from audit, security that nobody has full admin-rights.  Only local and the several parameters of the laptop can't be change. The second laptop, I own full admin rights. When stopping Aanti-virus for some minutes, the application still not run ! ---------------------------------------------------------------------- wp · 2018-12-14 09:13 Quote from: WimVan on December 13, 2018, 09:43:27 pmRemark: I did that step to step-debugging already. ... Sorry I cannot follow these steps... Do I understand correctly that the crash happens in Application.CreateForm(TMasterForm, MasterForm) somewhere related to Application.GetTitle? But AFAICS this does not require the UTF8-to-UTF16 conversion... And what did you do that you can step into LCL units? Normally this is not possible. ---------------------------------------------------------------------- rvk · 2018-12-14 09:21 You said all this happened after adding the second form to the program (I guess TVIEWERform). What happens if you remove it? What is included in the uses of TVIEWERform what is missing in TMASTERform? You can look at the code all you want but I don't think you'll find the solution there (unless it is to debug where the crash happens). The .exe from the other machine also won't run on the laptop (while it runs on the PC just fine). To me, that says it must be an environment issue. Also, the fact you see a blank window just before the crash (TMasterform?) says the crash happens after FormCreate and even after FormShow. Try setting a Showmessage at the end of FormCreate and one in FormShow and see if that's true. ---------------------------------------------------------------------- WimVan · 2018-12-14 11:56 I'm out of resources ... I tried installing the 32/64 Lazarus-verision.  Installed the 32bits libmysql.dll. I can connect in development. But when I tried to compile I see a popup of the applications with  a great fart of the form and then it closes immediately.  A message is returned that the appilication-execution is broken. No error on codes, libmysql.dllI tried installing the 64 Lazarus-verision.  Installed the 64bits libmysql.dll. I can connect in development. But when I tried to compile I see a popup of the applications with  a great fart of the form and then it closes immediately.  A message is returned that the appilication-execution is broken. No error on codes, libmysql.dllWhen once this strange behavour occurs it becomes very difficult to find out when the application can be compiled and RUN.   I already tried this some times and in some cases it is sufficient to remove the second form, on other times I came to the point where only a pagecontrol, tabsheet and some labels and edit-components are left over . 32bit Laptop164bit Laptop132bit Laptop264bit Laptop32bit PC64bit PCRun on developmentNoNoNoNoYesYes Laptop1Laptop2PCRun as exeNoNoYesRun as exe created on Laptop1 32bitNoNoYesRun as exe created on Laptop1 64bitNoNoYesRun as exe created on Laptop2 32bitNoNoYesRun as exe created on Laptop2 64bitNoNoYesRun as exe created on PC 32bitNoNoYesRun as exe created on PC 64bitNoNoYes That the environment has an impact ? Laptop 2 and PC have the same windowsbuild (except of course of drivers, ... but Win10 was installed the same way and it owns the same updates. ---------------------------------------------------------------------- rvk · 2018-12-14 12:03 Did you try any of the things I mentioned below? i.e. removing TVIEWERForm again and/or putting Showmessage at several places. I still think some other program just kills the program when it started. Do you have some entries in the Windows Event Viewer (in Applications)? Quote from: rvk on December 14, 2018, 10:21:52 amYou said all this happened after adding the second form to the program (I guess TVIEWERform). What happens if you remove it? What is included in the uses of TVIEWERform what is missing in TMASTERform? You can look at the code all you want but I don't think you'll find the solution there (unless it is to debug where the crash happens). The .exe from the other machine also won't run on the laptop (while it runs on the PC just fine). To me, that says it must be an environment issue. Also, the fact you see a blank window just before the crash (TMasterform?) says the crash happens after FormCreate and even after FormShow. Try setting a Showmessage at the end of FormCreate and one in FormShow and see if that's true. ---------------------------------------------------------------------- af0815 · 2018-12-14 12:05 a) What kind of exe have you compiled Win32 or Win64 ? Have you used the correct dlls and are this dlls available for the programm. Maybe in the same dir like the executable. b)Have you tried to start the executable from a commandline ? Normally you see more information on the commandline. What is the message here ? c) Not the windowsbuild have the great impact, more impact have the installed libraries. ---------------------------------------------------------------------- BrunoK · 2018-12-14 12:55 It smells a too small buffer for conversion. Try to change line  (3786 ?) in LazUTf8 SetLength(Result, ByteCnt); to SetLength(Result, ByteCnt+8); // +8 or maybe a bigger value if it works you had a buffer overrun due to a bug (?), maybe due to the type of Utf8 char that could not be correctly be translated to UCS-2 (UTF-16). If that's the case you have to be very careful about what caused the ConvertUTF8ToUTF16 to put out an Unfinished character. ---------------------------------------------------------------------- rvk · 2018-12-14 12:59 Quote from: BrunoK on December 14, 2018, 01:55:58 pmIt smells a too small buffer for conversion. I wouldn't trust the debugger (note that we are talking about gdb here) to pinpoint the exact crash location in this case. When another program just kills the process, the gdb debugger will go completely nuts. Since the same .exe (both the one compiled on laptop and PC) runs just fine on PC, I can't imagine it is something in code. ---------------------------------------------------------------------- WimVan · 2018-12-14 13:36 Removed form2 then asked a clean build ...  No result. Same popup andclosing directly remove/add form2 and a clean build ... Nothing changes I have a form1create-procedure; putting a showmessage at the beginning and at the end let see both messages while compiling ... popup and closure .. For the rest, I have now & form with some components and I have about 15 procdures that are fired when the application got focus and when, then you request for something. Stupied question (more and more I will ask such). Can there be something about the path ? I also changed the value in LAZUTF8.pas as mentioned ... No impact at all... If someone wants the resources ... just ask for them. The DB I can deliver as  a ZIpped SQL ---------------------------------------------------------------------- rvk · 2018-12-14 13:44 You could still try something else... to determine it is something from the outside... *) Put Dialogs in the uses of your project.lpr and put a Showmessage('a'); above Application.Initialize; If the program still quits it is really something from the outside. Showmessage is run before Application.Initialize but a second later (before you can press OK) some other program realizes you started this program and kills it. *) What happens if you just create an empty project? Does that still work? (Just one form with a button and nothing else) (Did you already look in the Event Viewer of Windows?) ---------------------------------------------------------------------- WimVan · 2018-12-14 13:53 1) I inserted your suggestion.  While compiling I got the message. Hitting ok, form pops up and closes immediately? 2) I can start a new project ...  as long this strange behaviour does not appear I can edit, modify, build, run that application.  So do I have several tools I made that are running. The development for these tools is done on Laptop1 and when I'm at home on the PC.  The sources resides on an external portable HD.  Lazarus is installed the same way and on the Laptop or PC. But, once the error appears (when I edited the application on the PC and then moves to the Laptop) is it done for infinity. Problem is, it does not always happens and I can't tell when it happens because I edit several items and not just one line program collectie_beheer; {$mode objfpc}{$H+} uses   {$IFDEF UNIX}{$IFDEF UseCThreads}   cthreads,   {$ENDIF}{$ENDIF}   Interfaces, // this includes the LCL widgetset   Forms, collectie_beheer_1, Dialogs; {$R *.res} begin   RequireDerivedFormResource:=True;   Application.Initialize;   Application.CreateForm(TMASTERform, MASTERform);   Showmessage('a');   Application.Run; end. When I put the message after creation of the form, I got that message too.  So, problem somewhere when running Note. PC and Laptop & owns a Intel-rpocessor, Laptopé is an AMD It rends me sick ... ---------------------------------------------------------------------- BrunoK · 2018-12-14 14:00 QuoteIt smells a too small buffer for conversion. I was thinking about something like Issue : 33296  corrected in Revision: 57429 that did nicely crash programs. Quote from: rvk on December 14, 2018, 01:59:47 pmI wouldn't trust the debugger (note that we are talking about gdb here) to pinpoint the exact crash location in this case. When another program just kills the process, the gdb debugger will go completely nuts. I just find (Window 32bits) that GDB7.7.1 works bloody well for programs compiled : -O1 -gw2 -godwarfsets -gl @WimVan Can you post a minimal zipped project that cause the crash ? ---------------------------------------------------------------------- WimVan · 2018-12-14 14:16 Here the request for the project. I added to exe too, and the libmysql.dll 32bit Be ware, the connector point to fotospotter_web ... If needed, I can send an extract of the database too Form2 is removed from the project and all it's references too Exe is made on this setup Zip seems to great, it can be downloaded from here: https://fotospotter.be/download/collectie_beheer.zip Thanks ---------------------------------------------------------------------- wp · 2018-12-14 15:32 Yes please post something to be used as database - right now the program is crashing when it is trying to connect to the DB because the DB is not found. Or don't you get this far? And do the folders DIR_SLIDE, DIR_THUMB, DIR_ORIGINAL have to be created manually or are they created by the program? ---------------------------------------------------------------------- WimVan · 2018-12-14 15:50 I'll leave the connection so the program is not looking for data.  Even then it fails to open it. GIve now some time ---------------------------------------------------------------------- rvk · 2018-12-14 15:54 You could try stripping the program (first make a backup). Strip all the database components. Then strip all other components. In between test the program to see if it runs. Once it runs you'll know what components are causing the problem. (But my guess is still that it is from the outside but stripping components might provide some insight to when that process is going to kill your program) ---------------------------------------------------------------------- Josh · 2018-12-14 15:55 Hi Had a quick look at the code. Some things to check in form create What happens to these values when file is not found, also what happens if the file structure is not as you expect. strtoint could cause a crash if text is not an integer maybe use strtointdef instead, as it has extra parameter to set a default value if strtoint is invalid. Code: [Select]if fileexists( cFile ) then   begin     with tStringList.create do       try         LoadFromFile( cFile );         MASTERform.Top    := strtoint(Strings[0]);         MASTERform.Left   := strtoint(Strings[1]);         schijfeenheid.Text := trim( Strings[2] );         folder.Text        := trim( Strings[3] );         appl.Text          := trim( Strings[4] );         foto_base.Text     := trim( Strings[5] );         thumbhoogte.Text   := trim( Strings[6] );       finally         free;       end;   end; at end of form.create put a breakpoint and check all the values are what you think they should be. noticed various strtoint same as above. noticed that your dividing /  what would happen if this value is very low or even 0; I would add some checks before any division to stop odd behaviour/crashes.  Data is not always valid so always check data before any operations are done on them. Not sure of the use of thebutton in your button click event; when your assigning it to sender. could you use ? Code: [Select]if sender is tbutton then begin   if tbutton(sender).tag=1 then Just some quick observations; not have time to compile/test. ---------------------------------------------------------------------- WimVan · 2018-12-15 07:45 @Josh I left some stuff to render a smaller application. 1) all  used var are always initialized 2) When a file with parameter-values is not found, default values are used. 3) Division by zero ?  These were values that I normally enter and check. 4) The code for the button is working as it should. Why is that not present, I left all stuff till it should work. Be aware that the sources I send are a grabage-collection, a base without any control. @Josh @rvk This night I did the proposal stripping all stuff in the pas-source (Put in comment). And yes, suddenly I could run it again on the Laptop !  I put the same garbage-written source on the PC and as I expected ir run there too. Finally I found the place were things go wrong. As the little app must serve to access several database I try to modify the SQLConnection. While developing it is set to into the component.  This permits to see all needed info while developing (fdatafields ...) When you choose another database (in setup) I close all connection and enter a new databasename and reopen the connection. Strange, on the PC this runs !! however, on the Laptop this causes the strange behavour. You try to run and all is compiling correctly, BUT, the app pops up and closes directly without any error .. The new, read other databasename is stored in the 'parameter'-file and the default is fe 'test' which works correct. This parameter can been entered in setup and is the edit-component 'foto_base' At startup 'rerun) the stored value is entered in the SQLconnection- component.  This gives no error, but the application does not give focus on the Laptop.  The app pops up and closes immediately.  On the PC however it continues and there I get focus, but now I see that it does not change to another database if requested. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   MasterQuery.Close;  MasterQuery.Active              := False;  MasterSQLTransaction.Active := False;  DBConnection.Connected      := False;  DBConnection.d//  DBConnection.DatabaseName   := foto_base.Text;  DBConnection.HostName       := 'Localhost';  DBConnection.UserName       := 'root';  DBConnection.Connected      := True;  MasterSQLTransaction.Active := True;  MasterQuery.Active        := True;  For Information.  The application is for the moment a kind of POC, because I'll have to adap some components (new components) so they act as I, we want.  But before starting the real app, I must be sure that what we wish is possible and acts as we hope ...  So sorry if it looks like a program which should never have been made.  And I now, sometimes that may be dangerous.  No errorchecks, .... Now I'll look further why I can't change that database. Meanwhile I do not understand why on the PC it runs and gives focus, on the Laptop it runs too but closes. ---------------------------------------------------------------------- Josh · 2018-12-15 08:49 do you have a delay between closing and re-opening a new database SQLConnection?. is the opening and closing in a try except block? ---------------------------------------------------------------------- BrunoK · 2018-12-15 09:42 Try to run this little program on both the PC and the laptop. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program pgmCodePage; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Classes  { you can add units after this }; begin  WriteLn('DefaultSystemCodePage=',DefaultSystemCodePage);  WriteLn('DefaultUnicodeCodePage=',DefaultUnicodeCodePage);  { the code page to use when sending paths/file names to OS file system API    calls using single byte strings, and to interpret the results gotten back    from such API calls }  WriteLn('DefaultFileSystemCodePage=',DefaultFileSystemCodePage);  { the code page to use to return file names from single byte file system calls    in the RTL that return ansistrings (by default, same as a above) }  WriteLn('DefaultRTLFileSystemCodePage=',DefaultRTLFileSystem CodePage);  WriteLn('UTF8CompareLocale=',UTF8CompareLocale);  WriteLn;  WriteLn('Copy results and press enter to finish.');  ReadLn;end. Are the results identical on all the systems. Do you have accents in the paths/filenames ? This is regarding automatic conversions from UTF-16 to UTF-8 and back. Supposing you have a debug  version on the problematic laptop(s) and with the application you  published : place a stop (F5) at the beginning of TMASTERform.FormCreate and trace F8 from here. If the procedure finishes then so the same in TMASTERform.setup_uitvoerenClick F5 at beginind and F8 from there. so the same in TMASTERform.MASTERgridDrawColumnCell and TMASTERform.MASTERgridCellClick In the 2 last one I have doubts about the FieldByName('foto_dir').AsString and FieldByName('foto').AsString. Maybe they should be .AsText .Text ---------------------------------------------------------------------- WimVan · 2018-12-15 13:40 @josh closing and opening .... setup of all database-related components are set in a try -excep - block Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    DBConnection.Close(true);showmessage('hier 3');   DBConnection.DatabaseName   := foto_base.Text;    // default value is fotospotter_web, it should be changed to fe 'test' (Content of foto_base.Text is 'test')showmessage('hier 4');    DBConnection.HostName       := 'Localhost';    DBConnection.UserName     := 'root';    MasterQuery.SQL.Text           := 'SELECT * FROM img_fotos ORDER BY foto_id DESC';  (table exists in fotospotter_web, aswel as in 'test'showmessage('hier 5');    DBConnection.Open;showmessage('hier 6');    DBConnection.Connected    := True;showmessage('hier 7');    MasterSQLTransaction.Active := True;showmessage('hier 8');     MasterQuery.Active          := True;showmessage('hier 9');     MasterQuery.Open;showmessage('hier 10');  except  on E: EDatabaseError do    begin      MessageDlg('Error', 'A database error has occurred. Technical error message: ' +        E.Message, mtError, [mbOK], 0);    end;  end;showmessage('hier 11');  In this code, all messages appear from 1 to 11 Between message 5 to 6 there is a latency of some seconds ... After message 11 the program closes directly. ---------------------------------------------------------------------- wp · 2018-12-15 18:15 Quote from: WimVan on December 15, 2018, 08:45:20 amThis night I did the proposal stripping all stuff in the pas-source (Put in comment). And yes, suddenly I could run it again on the Laptop !  I put the same garbage-written source on the PC and as I expected ir run there too. Finally I found the place were things go wrong. As the little app must serve to access several database I try to modify the SQLConnection. While developing it is set to into the component.  This permits to see all needed info while developing (fdatafields ...) When you choose another database (in setup) I close all connection and enter a new databasename and reopen the connection. Strange, on the PC this runs !! however, on the Laptop this causes the strange behavour. You try to run and all is compiling correctly, BUT, the app pops up and closes directly without any error .. The new, read other databasename is stored in the 'parameter'-file and the default is fe 'test' which works correct. This parameter can been entered in setup and is the edit-component 'foto_base' At startup 'rerun) the stored value is entered in the SQLconnection- component.  This gives no error, but the application does not give focus on the Laptop.  The app pops up and closes immediately.  On the PC however it continues and there I get focus, but now I see that it does not change to another database if requested. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   MasterQuery.Close;  MasterQuery.Active              := False;  MasterSQLTransaction.Active := False;  DBConnection.Connected      := False;  DBConnection.d//  DBConnection.DatabaseName   := foto_base.Text;  DBConnection.HostName       := 'Localhost';  DBConnection.UserName       := 'root';  DBConnection.Connected      := True;  MasterSQLTransaction.Active := True;  MasterQuery.Active        := True; Did you try to save the project with DatabaseName cleared? Then, at runtime, you can set the DatabaseName (like you actually do). ---------------------------------------------------------------------- WimVan · 2018-12-15 22:22 Acts the same way as if it is filled in. Application pops up, and the closes ... ---------------------------------------------------------------------- rvk · 2018-12-15 22:40 Could you try creating a small project with just a dbgrid and the database components on the laptop and trying to run it. Just a minimalistic example. Just to make sure the dlls and database work. Because you reach point 11 I still think something is messing with the process. Btw. Close and active := false and open and active := true are the same on a query. So you don't need to do them both. The same goes for open and connected on the dbconnection. Just use one or the other but not both. ---------------------------------------------------------------------- WimVan · 2018-12-16 09:24 Reposition of the behaviour. 1) When the application is build, I have entered all neede parameters in TMySQL57Connection. All linked items are only made active when the application is build and run. Run in development, run as an only exe. 2) This runs good on the PC and on the Laptops 3) When I add an edit-component, so I can change the database while running, the I have following On the laptops, the application pops up and directly closes.  The value from the edit-component is inserted in the TMysql57Connection- component. On the PC it runs, BUT, the database has not changed.  Still data from the Database that was assigned at development. I'll check if perhaps that active and open ... is not the origine of that misbehviour.  Who knows ?