Lazarus

Programming => General => Topic started by: jshah on December 02, 2019, 12:15:39 pm

Title: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 12:15:39 pm

Cross compile platform : 
OS=WIN32, CPU FAMILY=i386, Target process=Try all of them none of them work

Deployment Platform Detail :
OS Name    Microsoft Windows XP Professional
Version                  5.1.2600 Service Pack 3 Build 2600
OS Manufacturer   Microsoft Corporation
System Type   X86-based PC
Processor   x86 Family 5 Model 8 Stepping 6 Vortex86 SoC ~933 Mhz
BIOS Version/Date   AdvanPOS CP-2010 BIOS Rev: 8.9" A5LCD (05/07/2010), 5/7/2010
Windows Directory   C:\Windows
System Directory   C:\Windows\system32
Boot Device   \Device\HarddiskVolume1
Hardware Abstraction Layer   Version = "5.1.2600.5512 (xpsp.080413-2111)"
Total Physical Memory   511.55 MB
Available Physical Memory   308.40 MB
Total Virtual Memory   2.00 GB
Available Virtual Memory   1.96 GB
Page File Space   1.22 GB
Page File   C:\pagefile.sys

Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: MarkMLl on December 02, 2019, 12:21:36 pm
What version of compiler etc.?
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 12:26:36 pm
Lazarus : 2.0.2
FPC     : 3.0.4
OS      : Ubuntu x86_64-linux-gtk2
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: 440bx on December 02, 2019, 01:11:46 pm
First, I want to make sure I understand the conditions that lead to the problem.

My questions are:

You compile the program on Ubuntu, specifying the target as Win32.  Correct ? (yes/no)

What O/S is giving you the CRC check failed ? also, when does the CRC check fail error occur ?  Is it when you try to run the executable in Windows or at some other time ?  Can you post a screenshot of the error message you're getting ?  Are you running the Windows program from a network drive ?

Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: marcov on December 02, 2019, 01:16:23 pm
(assuming you mean crosscompiling linux->windows)

To target 32-bit x86 targets use a 32-bit x86 compiler. IOW make sure your installed *nix compiler is 32-bit.

And show commandlines etc.
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 01:32:32 pm
@440bx

You compile the program on Ubuntu, specifying the target as Win32.  Correct ? -> Yes

What O/S is giving you the CRC check failed ? -> Window XP

also, when does the CRC check fail error occur ?  Is it when you try to run the executable in Windows or at some other time ?  ->
When try to run the executable

Can you post a screenshot of the error message you're getting ?  -> Attached

Are you running the Windows program from a network drive ?  -> NO
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 01:35:14 pm
Yes crosscommpiling form Linux -> Windows

Application is running in win32 window-7


(assuming you mean crosscompiling linux->windows)

To target 32-bit x86 targets use a 32-bit x86 compiler. IOW make sure your installed *nix compiler is 32-bit.

And show commandlines etc.
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: Handoko on December 02, 2019, 02:05:09 pm
Can you send me the binaries to my email? One using default configuration and the other one without any debug info. I will try to run it on my Windows and I will also try to compile the source (from my Linux 64 to Win32) and compare them with yours to find out what are the differences.

If you're interested, you can pm me then I'll give you my email address.

Please also provide the source code. A simple hello world program should be enough.
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: 440bx on December 02, 2019, 02:48:29 pm
Are you running the Windows program from a network drive ?  -> NO
The Windows loader doesn't check the executable.  It couldn't even do a CRC check since all there is in the executable, is a basic checksum (and the loader ignores it.)

The most likely reason you are getting that message box is because the executable is residing on a bad sector on your hard drive.

Run a chkdsk /r <drive_letter> on the drive.  Make sure /r is there to ensure the bad sector is isolated.

HTH.

Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: Zvoni on December 02, 2019, 03:09:00 pm
I remember a Thread some time ago, where the OP of that thread also had trouble running an executable.
The solution was the way of his deployment, since he deployed via FTP, but in the wrong mode (ascii vs. binary).

Oh, and never forget any possibly installed Anti-Vir-Programs.
That screenshot doesn't look like a "native" Windows-Message-box (wouldn't remember Windows using "graphical" Buttons in any of its Dialogs),
and doesn't MS use "Cancel" (and not "Abort") in its Dialogs?
And the "OK"-Button has an Accelerator ("O").....
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 03:15:47 pm
i try to download file in two different way
1. from http server
2. from ftp server

both way is same issue.
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: Zvoni on December 02, 2019, 03:16:57 pm
i try to download file in two different way
1. from http server
2. from ftp server

both way is same issue.

Transfer in binary mode?
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 03:18:11 pm
i am not sure about ftp-download-mode let me check
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 03:37:06 pm

copy into flash drive and run from flash same issue

copy file form flash drive into hard disk same issue.
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: Zvoni on December 02, 2019, 03:51:25 pm
Any AntiVir-Programs on that XP-RustBucket?
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: 440bx on December 02, 2019, 04:02:25 pm

copy into flash drive and run from flash same issue

copy file form flash drive into hard disk same issue.
Though it is unclear, based on the screenshot you posted, it looks like the program may be trying to access one or more files.

The one thing that is critical to recognize in the problem you're having is that CRC errors are almost always caused by a bad sector on a hard drive. 

The fact that you get the CRC check error even when you run the executable from a flash drive is almost guaranteed to indicate that some file(s) the program is attempting to access is on a bad sector.   

You should do what I told you to do in the previous post.  Run a chkdsk /r <drive_letter> against the drive.  At least that way, you'll know if the problem is caused by a bad sector on the hard drive.  It's almost a given that is the problem.

You can choose to ignore the advice but, ignoring it won't help you figure out the cause of the problem.
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 04:36:16 pm
No anti-virus
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 05:06:31 pm
run chkdsk : command not found.

run disk check result attached.
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 05:08:15 pm
Look like is related to platform issue
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: Handoko on December 02, 2019, 05:27:50 pm
Please send it to me.

Sending binaries via email, as far as I know will be blocked by some mail server. So you should compress them into a zip file first before sending.
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 05:30:53 pm
I have remove win32 gui application (-WG) and created new exe now it shows some detailed about this error

attached screen shot
Title: [SOLUTION] Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 05:35:28 pm
Application is running when Removed Application ICON
Title: Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 06:04:15 pm
Thank you everyone for support
Title: Re: [SOLUTION] Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: Handoko on December 02, 2019, 06:28:17 pm
Application is running when Removed Application ICON

Why that happened? Application icon causes the binary fail to start? Can anyone please explain?
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: ASBzone on December 02, 2019, 06:49:57 pm
He might have a corrupt image file...
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 07:15:50 pm
If you check the screenshot of dos command it shows there is PNGImageException
and my application dont have any image only application icon so I just
try and remove the icon and it works.

I dont know if i need to copy the icon file with exe.
Title: Re: [SOLUTION] Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: 440bx on December 02, 2019, 07:27:44 pm
Why that happened? Application icon causes the binary fail to start? Can anyone please explain?
The PNG format includes a CRC.  Based on the last screenshot he posted, a PNG that he included (and is using) in his program is corrupted (bad CRC.) 

As far as the O/S is concerned, the program is fine but, when the program attempts to use the PNG, it runs into the bad CRC. 

He might have a corrupt image file...
It is possible, actually quite likely, that the image file is fine.  The problem is most likely caused by his including a bad PNG in the exe (apparently as an icon.)
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 07:34:21 pm
Icon file is default created by project and this binary is running in win7 32bit computer without removing the icon.
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: Martin_fr on December 02, 2019, 07:49:13 pm
He might have a corrupt image file...
If he is right, and the same exe, with the same image, did work on win-7... Then it sounds like the png reader depends on something that is not working. Or at least not for some subsets of png...

But that is just a guess.
Title: Re: [SOLUTION] Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: ASBzone on December 02, 2019, 08:22:17 pm
He might have a corrupt image file...
It is possible, actually quite likely, that the image file is fine.  The problem is most likely caused by his including a bad PNG in the exe (apparently as an icon.)


Sorry, term overload.  I meant "image" as in graphics image, not binary executable image.   :P
Title: Re: [SOLUTION] Re: Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: 440bx on December 02, 2019, 08:59:10 pm
I meant "image" as in graphics image, not binary executable image.   :P
In this particular case the term "image" is rather ambiguous <chuckle>
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 02, 2019, 10:40:00 pm
Even same application cross-compile to RaspberryPI also working without any error so this must be issue related to the OS
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: avra on December 03, 2019, 01:16:51 am
What happens if you use these compiler switches:
Code: Pascal  [Select]
  1. -O2 -g- -Xs -CpPENTIUM4 -CfSSE3
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jamie on December 03, 2019, 02:43:23 am
I have had issues moving Projects created on newer OSes over to older one's via USB flash stick and have the OS refuse to load the file, claims to have CRC errors.

 But the same file will work on the newer OS, even from the USB stick .. That tells me the file format may have an issue.

 I did this with W2k one, an OLD file that should work on W2k would not execute when taking from a flash storage done by a newer OS.

Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: trev on December 03, 2019, 04:45:44 am
In my experience this usually occurs because the CPU in the newer operating system supports more instructions than the CPU in the older operating system. So not operating system dependent so much as CPU dependent.
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: jshah on December 03, 2019, 12:30:04 pm
Not working same issue
What happens if you use these compiler switches:
Code: Pascal  [Select]
  1. -O2 -g- -Xs -CpPENTIUM4 -CfSSE3
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: marcov on December 03, 2019, 12:50:18 pm
Vista and Win8 changed icons a lot. (larger, png instead only bmp). But for the icon, there would be no fcl-image exception, since those icons would be loaded by the explorer.

So the question remains where the image comes from
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: PascalDragon on December 03, 2019, 02:55:49 pm
To target 32-bit x86 targets use a 32-bit x86 compiler. IOW make sure your installed *nix compiler is 32-bit.
Compiling for i386 is only a problem with x86_64-win64 and any non-x86 target. x86_64-linux for example can compile for i386-win32 without any problems.

Vista and Win8 changed icons a lot. (larger, png instead only bmp). But for the icon, there would be no fcl-image exception, since those icons would be loaded by the explorer.

So the question remains where the image comes from
jshah wrote that removing the application icon solved it. Icon files have multiple sizes defined in them and in Vista and newer aside from bitmap data - as you wrote - can also contain PNG data. The default application icon of Lazarus does contain such data. Maybe the resource mechanism gets confused on XP with the PNG subicon or Lazarus somehow picks the wrong one.
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: marcov on December 03, 2019, 05:41:49 pm
To target 32-bit x86 targets use a 32-bit x86 compiler. IOW make sure your installed *nix compiler is 32-bit.
Compiling for i386 is only a problem with x86_64-win64 and any non-x86 target. x86_64-linux for example can compile for i386-win32 without any problems.

Whoops yes. *nix still uses FPU.

Quote
Vista and Win8 changed icons a lot. (larger, png instead only bmp). But for the icon, there would be no fcl-image exception, since those icons would be loaded by the explorer.

So the question remains where the image comes from
jshah wrote that removing the application icon solved it. Icon files have multiple sizes defined in them and in Vista and newer aside from bitmap data - as you wrote - can also contain PNG data. The default application icon of Lazarus does contain such data. Maybe the resource mechanism gets confused on XP with the PNG subicon or Lazarus somehow picks the wrong one.

If true that means actual lzarus code is mediator between resources and windows/explorer for the icons. That is IMHO somewhat doubtfull, since that would mean that the windows explorer would have to launch all exes to get the icon.

Still it could be that somehow Lazarus falsely manifests a "live icon" or so that makes that happen
Title: Re: [SOLVED] Compiled Win32 Exe not running on Window XP (CRC Check Failed)
Post by: PascalDragon on December 04, 2019, 09:17:34 am
Quote
Vista and Win8 changed icons a lot. (larger, png instead only bmp). But for the icon, there would be no fcl-image exception, since those icons would be loaded by the explorer.

So the question remains where the image comes from
jshah wrote that removing the application icon solved it. Icon files have multiple sizes defined in them and in Vista and newer aside from bitmap data - as you wrote - can also contain PNG data. The default application icon of Lazarus does contain such data. Maybe the resource mechanism gets confused on XP with the PNG subicon or Lazarus somehow picks the wrong one.

If true that means actual lzarus code is mediator between resources and windows/explorer for the icons. That is IMHO somewhat doubtfull, since that would mean that the windows explorer would have to launch all exes to get the icon.

Still it could be that somehow Lazarus falsely manifests a "live icon" or so that makes that happen
Not the Explorer, but the window/application icon. That is set by Lazarus code.