Strict private class variable memory corruption in an overridden method inside a Lazarus package
Original Reporter info from Mantis: eugeneloza @EugeneLoza
-
Reporter name:
Original Reporter info from Mantis: eugeneloza @EugeneLoza
- Reporter name:
Description:
In case a class inherits another class and overrides a strict protected
method used as setter for a property
, the memory may become corrupted in the overridden method. An internal strict private
pointer variable may be no longer initialized to nil
, and can be either a random address, $baadf00dbaadf00d
or raise a SIGSEGV simply on trying to access the pointer address - depending on the contents of the unit (the last case appears in the attached example).
Reproduced only in a LPK package. If the unit is added "directly" to the Lazarus project, everything works correctly. Also, if the overridden method is changed, e.g. some operations are added before inherited
the bug also disappears.
The segmentation fault appears on Windows systems (tested on 7x64 and 10x64) since r43370 and is an issue up to at least r43677. Everything is working perfectly in r43369 and below; also not reproduced in latest stable/fixes release. Does not depend on Lazarus version.
Steps to reproduce:
Open the attached minimal project.
Locate the packages/fail.lpk
.
Compile & run.
SIGSEGV.
Additional information:
Tested FPC versions (working - yes/no):
r43677 ---- no (12.12)
r43672 ---- no (11.12)
r43670 ---- no (10.12)
r43665 ---- no (9.12)
r43655 ---- no (6.12)
r43618 ---- no (1.12)
r43609 ---- no (29.11)
r43466 ---- no (14.11)
r43400 ---- no (5.11)
r43386 ---- no (3.11)
r43382 ---- no
r43375 ---- no
r43370 ---- no <=========== here.
r43369 ---- yes
r43368 ---- yes
r43365 ---- yes (2.11)
r43352 ---- yes (1.11)
r43062 ---- yes
Might also be related to Internal error 2014010312. As it sometimes occurs when trying to move TSimpleTextureFont
into project1.lpr. However, I could not reproduce it on the minimal example attached.
Mantis conversion info:
- Mantis ID: 36428
- OS: Windows
- OS Build: 7x64; 10x64
- Build: 43677
- Platform: PC
- Version: 3.3.1
- Monitored by: » Cyrax (Cyrax), » @EugeneLoza (eugeneloza), » @michaliskambi (Michalis Kamburelis)