Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RevertPatchedMethods in PngImageList couse exception in DLL DataModule #14

Open
KG-PL opened this issue Sep 27, 2024 · 0 comments
Open

Comments

@KG-PL
Copy link

KG-PL commented Sep 27, 2024

Using Delphi 10.4, package downloaded via GetIt. Build of x64 DLL.

As title stated, exception is thrown when RevertPatchedMethods is called on disposing DataModule in which TPngImageList is contained. This happens to me only during DLL registration via regsvr32.exe with /S switch. With no /S switch it is not triggered. I suspect that patched references are disposed before method is called in final memory cleanup of memory manager.
I also suspect unit PngImageList finalization section to not properly handle marking of disposed MethodPatches. Variable ImageListCount in such situation should be set to eg. negative value or MethodPatches should be set to nil and RevertPatchedMethods should check if reference is nil for MethodPatches.
I would like to remind that double freeing of an object is programming bug (silenced in x86; raises exception in x64). Also finalization section should check if MethodPatches is nil, as calling Free on nil is also a bug.

This can be prevented right now by declaring proper initialization/finalization section in DataModule auto generated code which by default use units begin section with no finalization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant