Hello,
I found a problem using the latest version of lazarus (1.8.0 64bit FPC 3.0.4) in debug mode. On Windows 10 64bit.
In the imjmorecfg.pas file I saw:
uInt = Cardinal;
This I think is a problem for 64bit systems
For FPC if I replace with
uInt = NativeUInt
I do not perform more dangerous crashes
Also I think there is a similar problem (I have not tested) for:
imzutil.pas
uInt = cardinal; -> NativeUInt
ptr2int = uInt; -> PtrUInt
(but the message "Nomssi" under "ptr2int" is not very clear)
I noticed that through the lazarus compiler, several "warning" and "hint" messages appear.
For "justified Hints" it is possible to disable them (to avoid having to run many already verified messages).
example
FillChar(TmpInfo, SizeOf(TmpInfo), 0);
show variable message not initialized
it is due to the use of "var" but here it is correct then
FillChar({%H-}TmpInfo, SizeOf(TmpInfo), 0);
avoid the message (it is filtered by lazarus itself)
Finally, the compilation on the ImagingPcx.pas unit is blocked
ifMono: TImageFormat = TImageFormat (250);
...
I do not know if it's correct.
I know that the SizeOf () dimension of the "enum" types can change depending on the number of elements.
The compiler writes:
ImagingPcx.pas(91,43) Error: range check error while evaluating constants (250 must be between 0 and 206)
(sorry for my English)
Thanks
The crash I found is a memory violation (unfortunately, too much time has passed and I do not remember what happened. The original source has been heavily modified. Probably there was an anomaly in the program or a violation message of memory by the debugger). The application is very large and also uses several third-party libraries. I isolated the problem by excluding source parts. Finally, by applying the change reported, I no longer detected problems with memory.
So providing a source that can show a problem like this is very difficult :(.
But these resources should help:
(1)
From http://wiki.freepascal.org/Code_Conversion_Guide
32bit / 64 bit support
Pointers under 64bit need 8 bytes instead of 4 on 32bit. The 'Integer' type remains for compatibility 32bit. This means you can no longer typecast pointers into integers and back. FPC defines two new types: PtrInt and PtrUInt. PtrInt is a 32bit signed integer on 32 bit platforms and a 64bit signed integer on 64bit platforms. The same for PtrUInt, but unsigned integer instead. Use for code that should work with Delphi and FPC:
{$IFNDEF FPC} for 32bit
type
PtrInt = Longint;
PtrUInt = DWord;
{$ENDIF}
{$IFNDEF FPC} for 64bit
type
PtrInt = Int64;
PtrUInt = QWord;
{$ENDIF}
(2)
http://wiki.freepascal.org/Cardinal
NOTE: pointers are unsigned integer
Thank! :)
Quote from: Phoenix on 15 October 2018, 10:47:41Sorry for the late reply (I'm enjoying safe browsing with ExpressVPN (https://www.timesunion.com/marketplace/article/expressvpn-review-17408299.php) and not registered on the site and I do not receive an email alert).
IMPORTANT NOTE
Even if you use Windows 64bit, if you compile for example with Lazarus 32bit you can not have this problem.
Unfortunately, the memory violation has unpredictable effects.
- You can try to change the two lines of suspicious code
If you use Lazarus (32 / 64bit):
uInt = NativeUInt
ptr2int = PtrUInt
If you use Delphi (depends on the version):
http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.NativeUInt
in theory for 64bit if you use "Int64" it's ok
For ptr2int see my post
- RESTART the computer (in Windows 10, shut down the system should be similar to a hibernation) to "clean" the corrupted memory.
- Build the library (separately if you use it as a package) and the program
If you see differences with your problem you will have confirmation ;).
I might be having this very issue. I'm also on Windows 10 64-bit. How can I make sure this is the same exact issue btw?
Sorry for the late reply (I'm not registered on the site and I do not receive an email alert).
IMPORTANT NOTE
Even if you use Windows 64bit, if you compile for example with Lazarus 32bit you can not have this problem.
Unfortunately, the memory violation has unpredictable effects.
- You can try to change the two lines of suspicious code
If you use Lazarus (32 / 64bit):
uInt = NativeUInt
ptr2int = PtrUInt
If you use Delphi (depends on the version):
http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.NativeUInt
in theory for 64bit if you use "Int64" it's ok
For ptr2int see my post
- RESTART the computer (in Windows 10, shut down the system should be similar to a hibernation) to "clean" the corrupted memory.
- Build the library (separately if you use it as a package) and the program
If you see differences with your problem you will have confirmation ;).
Thank you for sharing the information.