-1

I have Delphi XE3, Windows 7 Pro 64bit. My application is working fine in my PC but my users told me application crashes upon start on their Win XP and also (!!) on their Win 7.

I tried to run the app on my Win 7 but logged as an ordinary user (no admin) - it works. So now I have installed virtual machine with Windows XP and really - app crashes upon startup.

I need to find what can be the problem but I'm helpless.

As far as I can't use debugger (I dont have Delphi on that VM installed), I tried to put some MessageBox(0, 'Hello', 'Test', MB_OK); in various places in my app to catch the place where it happens and this is what I found:

I have this in my project-source:

MessageBox(0, 'Hello', 'Test', MB_OK); // shows OK
Application.CreateForm(TfMain, fMain);
MessageBox(0, 'Hello', 'Test', MB_OK); // doesn't show - crash before this line

And this is in the OnCreate function of my main form called fMain:

procedure TfMain.FormCreate(Sender: TObject);
begin
  MessageBox(0, 'Hello', 'Test', MB_OK); // doesn't show - crash before this line
  ...

So where can this app crash?
Not even first line in the OnCreate executes....
I have no idea... Anybody?

Don't know if this is important: I have some units in fMain uses clause under interface and also under implementation. Should I look there? But what happens just before OnCreate of my main form ?

Kara
  • 6,115
  • 16
  • 50
  • 57
Enriqe
  • 567
  • 1
  • 6
  • 22
  • You can't debug because you don't have Delphi installed on your VM. You know there are a couple of really easy ways to fix that, right? – Rob Kennedy Aug 08 '13 at 21:26
  • 2
    @Rob Kennedy Hmmm if I knew, I would do that. Any tips? – Enriqe Aug 08 '13 at 21:48
  • 1
    I'm not Rob, but off the top of my head: 1) Install Delphi on that VM. 2) Use the remote debugger (see the Delphi [documentation](http://docwiki.embarcadero.com/RADStudio/en/Installing,_Starting,_and_Stopping_the_Remote_Debug_Server) for details). As far as "what happens just before `OnCreate`?", use the source. You'll find this in `Forms.pas`. – Ken White Aug 08 '13 at 22:16
  • 1
    "app crashes" is not an acceptable description of the error. If you could get the actual error message, that might lead to a solution. – MikeD Aug 09 '13 at 10:45
  • @MikeD Well... It just crashes. No exception, nothing. Just well-known Win XP dialog "Application has stopped responding bla bla bla. Do you want to send a report (or something like that)". – Enriqe Aug 09 '13 at 17:30
  • Yeah, the bla bla bla is important. You can click details then for more information in what module the crash is. – Rik Aug 09 '13 at 17:44
  • @Rik OK, there is: ModName:kernel32.dll , ModVer:5.1.2600.5781 , Offset:00012afb. Is it somehow usefull for me? Thanks. – Enriqe Aug 09 '13 at 19:26
  • 1
    Your initialize from your units in uses should not matter. They should already be executed before the formcreate. However... between the createform call and formcreate (oncreate) all the components on your form are created. Likely in one of those creations is your crash. Could you slim/strip down your form until it doesn't crash? Begin with stripping special non standard components. (I see @house of dexter already suggested this.) – Rik Aug 09 '13 at 19:54
  • @Rik So.... Here is an update. I installed Delphi XE3 on my Win XP virtual PC and .... everything compiles and executes without any problem ! I took whole code, copied it in the WinXP and compiled. No error, app runs without any problems! Bizzare. It looks like I will need another physical PC with WinXP to continue developing my app? Don't understand it... – Enriqe Aug 10 '13 at 07:11
  • It looks like my app is dependent on some module, which is not present in the Windows OS until I install Delphi XE3 there. But which one it is... No idea. I thought everything needed for running my app is packed in the Delphi app EXE file... – Enriqe Aug 10 '13 at 07:22
  • Create a new clean virtual machine with xp. See if it gives the error. If so, follow my and @houseofdexter's sugestion to strip the components until you don't get the error. Probably one of your (special or third party) components is causing the problem and needs some dll or library installed by Delphi. – Rik Aug 10 '13 at 10:58
  • @Rik I solved it ! See answer below. – Enriqe Aug 11 '13 at 16:00

2 Answers2

1

Finally I got it !

  • place PRINT DIALOG component on your form (TPrintDialog)
  • set COPIES = 1 (or more than default zero) in the object inspector during design time
  • try to run such application on WinXP where NO PRINTERS are installed

Application just crashes upon start and in the details you will see only some kernel32.dll address...

I didn't test it on Win 7 without printers. I have no such system around...

Enriqe
  • 567
  • 1
  • 6
  • 22
0

Here's another way to track this down without Delphi on the VM...

  • Copy your project.
  • Remove all the units from Project Source except your main form.
  • Launch your application from XP see if it crashes.

  • If it crashes...then look at the units being dragged in from your main form...start removing them until your program stops crashing.

  • If it doesn't crash...start adding units/forms back into your project source until it crashes.

Do you have JCL/JVCL installed(JEDI)?

If so create a Logger...note the Logger needs to be created and hooked before your MainForm code executes...You will also need to set up a detailed Stack Trace from Unhandled Exceptions, in Delphi select->Project/Options/Linker/Map file/Detailed}

You will need something like this in your Logger unit

procedure HookGlobalException(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean);
var
  a_List: TStringList;
begin
  if Assigned(TLogger._Instance) then
  begin
    a_List := TStringList.Create;
    try
      a_List.Add(cStar);
      a_List.Add(Format('{ Exception - %s }', [Exception(ExceptObj).Message]));
      JclLastExceptStackListToStrings(a_List, False, True, True, False);
      a_List.Add(cStar);
  // save the error with stack log to file
      TLogger._Instance.AddError(a_List);
    finally
      a_List.Free;
    end;
  end;
end;


initialization
  Lock := TCriticalSection.Create;
  Include(JclStackTrackingOptions, stTraceAllExceptions);
  Include(JclStackTrackingOptions, stRawMode);

  // Initialize Exception tracking
  JclStartExceptionTracking;

  JclAddExceptNotifier(HookGlobalException, npFirstChain);
  JclHookExceptions;

finalization
  JclUnhookExceptions;
  JclStopExceptionTracking;
  Lock.Free;
House of Dexter
  • 386
  • 1
  • 7