| Ticket UUID: | 3480471 | |||
| Title: | tk_getOpenFile crashes on Win64 | |||
| Type: | Bug | Version: | obsolete: 8.5.10 | |
| Submitter: | halex-ecs | Created on: | 2012-01-27 09:50:33 | |
| Subsystem: | 68. Win Window Operations | Assigned To: | jan.nijtmans | |
| Priority: | 9 Immediate | Severity: | ||
| Status: | Closed | Last Modified: | 2014-03-13 09:11:33 | |
| Resolution: | Fixed | Closed By: | nijtmans | |
| Closed on: | 2012-01-27 22:15:45 | |||
| Description: |
On Windows x64, when running a 64bit wish 8.5.10 and after allocating and using lots of memory (above 2GB), wish crashes immediately when selecting a File in a tk_getOpenFile dialog. We tracked the problem down to the function OFNHookProcW in tkWinDialog.c. Referencing tk 8.5.10, in line 1035-1040 of tkWinDialog.c, there is the following piece of code: SendMessageW(hdlg, CDM_GETFOLDERPATH, dirsize, (int) buffer); buffer += dirsize; SendMessageW(hdlg, CDM_GETSPEC, selsize, (int) buffer); The crash is caught by the debugger in the line buffer += dirsize; but the mistake resides in the lines above and below: The last argument of SendMessageW is declared as LPARAM (see http://msdn.microsoft.com/en-us/library/windows/desktop/ms644950(v=vs.85).aspx), which is defined as LONG_PTR which is defined as __int64 when building with 64bit (see http://msdn.microsoft.com/en-us/library/aa383751(v=VS.85).aspx) When buffer starts above 2GB adress (this makes it a little difficult to reproduce this error), the cast to int cuts the upper part of the adress and things become very wrong and wish crashes. Changing those lines to SendMessageW(hdlg, CDM_GETFOLDERPATH, dirsize, (__int64) buffer); buffer += dirsize; SendMessageW(hdlg, CDM_GETSPEC, selsize, (__int64) buffer); makes everything fine. The correct all-platform fix should cast to (LONG_PTR), imho. This error also occours in tk 8.5.11 (although these lines are different, but PTR2INT makes the same mistake as the int-cast) and in tk 8.6b2 | |||
| User Comments: |
nijtmans added on 2012-01-28 05:15:45:
allow_comments - 1 Fixed on core-8-5-branch and trunk (was already correct on core-8-4-branch) nijtmans added on 2012-01-27 19:00:58: Agreed with the analysis. I would simply cast to (LPARAM), as is done in various other places. nijtmans added on 2012-01-27 18:51:32: I will have a look at this | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki