Toolbar button configuration dialog leaks file handle

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Toolbar button configuration dialog leaks file handle

Post by *gdpr deleted 6 »

Affected: TC32 and TC64 (9.12, older versions not tested)
OS: MS Windows 7 Pro x64, english

The toolbar button configuration dialog leaks a file handle of the file that is used as the source of the icon. This effectively locks the icon file until TC is closed.

The bug happens if the file providing the icon is an .EXE, .DLL, or .ICL.
The problem does not happen when using .ICO files.

As far as i can tell, the (eventually leaked) file handle is created at the moment when the icon view of the button configuration dialog is showing/reading the icons from the chosen icon file (.EXE, .DLL, .ICL). When closing the dialog, this file handle is not closed, i.e., it is leaked.


Important to know for anyone trying to reproduce the problem: The leaked file handle (which seems to be a file mapping/memory-mapped I/O handle) will not prevent another process from renaming the file or moving it to another directory on the same(!) drive/volume. However, it does not permit deleting or overwriting the file (deletion would also include trying to move the file to another drive/volume). This means, renaming or moving the file on the same drive does not help in determining whether there is an open/leaked handle for this file. Keep this in mind when trying to reproduce the problem.


How to reproduce:

1. Put a copy of a .EXE, .DLL, or .ICL file with icons in a test folder.

2. Start TC (with a clean/fresh INI to avoid any unwanted interactions with plug-ins and such...)

3. Open the toolbar button configuration dialog.

4. In the dialog, set the exe/dll/icl file in the test folder as "icon file". Make sure the icon view shows the icons contained in this exe/dll/icl file.

5. Keep the toolbar button configuration dialog open.

6. In another TC instance (or Windows file explorer), try overwriting the exe/dll/icl file in the test folder (with its original version, for example).
Result: The file cannot be overwritten.

7. Close the toolbar button configuration dialog (either with OK or Cancel), and retry step #6.
Result: The file can still not be overwritten.

8. Close the offending TC instance (the one in which you opened the toolbar button configuration dialog). Try step #6 once more.
Result: This time the file can be overwritten again.


Side notes:

When selecting and viewing different exe/dll/icl icon files in the same dialog instance, the file handle of the previous icon file will be closed properly, as it seems. This suggests a possible bug fix could perhaps be as easy as "de-initializing"/resetting the icon view control explicitly in the dialog close/closing event handler or something similar...
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

Confirmed in TC 9.12 x32 and x64 under Windows 10 (1709 build 16299.192)

Not Confirmed in TC 9.0a x32 and x64 under Windows 10 (1709 build 16299.192)
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Post by *gdpr deleted 6 »

ts4242 wrote:Confirmed in TC 9.12 x32 and x64 under Windows 10 (1709 build 16299.192)

Not Confirmed in TC 9.0a x32 and x64 under Windows 10 (1709 build 16299.192)
Damn, you are quick :)
Was going to cross check with TC8.52a on the weekend to see whether this is an "old" bug, but it seems you took that task away from me. Thanks :)
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

I have tested in reverse order 9.12, 9.10 and 9.0a, I stopped once I found a clean version.
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

Fixed in TC 9.20 ß1 x32 & x64
Post Reply