Ticket UUID: | e6140f34047ea6f62a9aa636ae73dfe09bb6dafb | |||
Title: | Crashes in empty ttk::panedwindow | |||
Type: | Bug | Version: | 8.7b1 | |
Submitter: | serhiy.storchaka | Created on: | 2024-05-31 21:00:00 | |
Subsystem: | 88. Themed Tk | Assigned To: | apnadkarni | |
Priority: | 5 Medium | Severity: | Severe | |
Status: | Closed | Last Modified: | 2024-06-05 17:18:06 | |
Resolution: | Fixed | Closed By: | serhiy.storchaka | |
Closed on: | 2024-06-05 17:18:06 | |||
Description: |
The following example crashes: ``` ttk::panedwindow .p .p pane 0 ``` The "forget" subcommand also crashes. | |||
User Comments: |
serhiy.storchaka added on 2024-06-05 17:18:06:
Thank you, so I can use the "core-8-branch" branch for 8.7 (I looked for "core-8-7-branch", but it does not exist) and the "trunk" or "main" branch for 9.0. I tested with 8.7 first because Tkinter needed less changes to build with 8.7, and I expected that 8.7 is more compatible with 8.6. But now I see that they break similar number of tests, and the 8.7 branch may be less stable, so the main focus is now on 9.0. jan.nijtmans added on 2024-06-03 14:55:00: My recommendation would be to use Tk 9.0 as well: it is getting more thorough testing now. That said, Tk 9.0 was recently split off from Tk8.7. The only difference is four TIP's (#647, #678, #681, #683). All bugs found in Tk 9.0 were backported to 8.7 as well. Hope this helps oehhar added on 2024-06-03 13:54:19: Dear Serhiy, to get this, it is best to use the main branch, which is Tk 9.0. Tk 8.7 is currently postphoned and the branch may not be in best state. Or you may wait for upcomming Tk 9.0b3 release around end of this month. Take care, Harald jan.nijtmans added on 2024-06-03 12:19:00: Now also [ae8003f4f9516ce8|backported] to 8.7. Thanks, Ashok, for taking this ticket, and François for merging it. (and - of course - to Serhiy for filing this bug in the first place!) serhiy.storchaka added on 2024-06-03 11:17:21: Thank you for your quick fix. How can I get a 8.7 version with this fix? fvogel added on 2024-06-03 06:13:36: Thanks, now merged. apnadkarni added on 2024-06-03 02:42:33: Yes, that makes sense to me as the last valid index depends on whether a new window was added or not. fvogel added on 2024-06-02 19:44:03: [a37038ac67] lets notebook-9.2 pass (with no other test failing). What do you think? fvogel added on 2024-06-02 17:17:33: Understood. I think you were definitely right in choosing zero in this change in ttkNotebook.c (sorry that link was incorrect in my previous answer). To demonstrate why you were right I have added test notebook-9.1, which moves the last tab by numerical index. This test currently fails in trunk (but not in core-8-6-branch, modulo the changed wording of the error: 'Slave...' became 'Managed window...' in trunk). So we will keep your correct choice here, well done! While I was at it I have also added test notebook-9.2, which moves the first tab to the last position by numerical index. This test still fails in both trunk and our bugfix branch (whereas it passes, modulo the changed error text, in core-8-6-branch). See the added tests [4a45ebfd25|here]. apnadkarni added on 2024-06-02 13:36:24: It is true I was debating whether to avoid changing unrelated functionality or do the "logically" right thing to forestall undiscovered bugs. I went with the latter though I admit that is dangerous. In the case you mentioned in I would not object to changing that to 1, to reduce inadvertent change in behavior. Thanks for the close review! I always have some trepidation touching Tk. fvogel added on 2024-06-02 10:35:46: Your approach to fix this (change the Ttk_GetContentIndexFromObj() API) is totally fine for me. The entire fix is about making use of the already existing lastOK parameter of TkGetIntForIndex() called from Ttk_GetContentIndexFromObj(). Looking at the changes in detail I have been wondering what governed your choice of the lastOK value for each call to Ttk_GetContentIndexFromObj() throughout the code. To avoid changing the behavior in areas unrelated to the present bug I would have expected lastOK to be 1 in files other than ttkPanedWindow.c but one of your changes in ttkNotebook.c does not follow this rule. Does his mean that there were other, undiscovered (so far) bugs, that you corrected while fixing this one? In contrast, your choice for the value of lastOK in ttkPanedwindow.c look totally right to me, and constitute the fix for this ticket (insert: lastOK is 1; pane or forget: lastOK is 0). Ttk tests pass 100% for me (including the newly added tests). This is on Windows but since the code touched in generic it must be the case for all platforms. Many thanks Ashok! apnadkarni added on 2024-06-01 11:33:42: Fix and tests in bug-e6140f3404. Needs review from someone who knows Tk better than I do. In particular, an additional parameter has been added to Ttk_GetContentIndexFromObj. I'm assuming that is OK since the function does not seem to be exported outside of Tk. apnadkarni added on 2024-06-01 10:15:17: I found the cause. However, it is not related to TIP 660 and happens before the [6bc95282] commit as well, in particular with pre-660 Tk [ccee45f2] in conjunction with pre-660 Tcl [883464ea32] with exactly the same stack trace. The issue is a subtle change in the implementation of Ttk_GetContentIndexFromObj since 8.6 which had the fragment
An index == mgr->nContent then returned an error. In 9.0, the code has been changed as
Note that now index == mgr->nContent does not return an error. I don't know Tk well enough, but my presumption is that this change was done because for some commands like However, it does mean all callers that relied on that function but cannot treat index == mgr->nContent have to be fixed to do that check themselves. Fix in progress ... serhiy.storchaka added on 2024-06-01 07:27:40: I reproduced this on Linux with Tk 8.7b1. fvogel added on 2024-06-01 06:57:16: You meant: Tk8.6.14 does not show the problem. Correct. The reporter stated Version: 8.7b1 I'm seeing the crash with current trunk. Here is a stack trace from Windows: tcl9tk90.dll!Ttk_ContentData(TtkManager_ * mgr, __int64 index) Ligne 414 C tcl9tk90.dll!PanedPaneCommand(void * recordPtr, Tcl_Interp * interp, __int64 objc, Tcl_Obj * const * objv) Ligne 793 C tcl9tk90.dll!Ttk_InvokeEnsemble(const TtkEnsemble * ensemble, __int64 cmdIndex, void * clientData, Tcl_Interp * interp, __int64 objc, Tcl_Obj * const * objv) Ligne 1740 C tcl9tk90.dll!WidgetInstanceObjCmd(void * clientData, Tcl_Interp * interp, int objc, Tcl_Obj * const * objv) Ligne 173 C tcl90.dll!Dispatch(void * * data, Tcl_Interp * interp, int dummy4600) Ligne 4639 C tcl90.dll!TclNRRunCallbacks(Tcl_Interp * interp, int result, NRE_callback * rootPtr) Ligne 4654 C tcl90.dll!TclEvalObjEx(Tcl_Interp * interp, Tcl_Obj * objPtr, int flags, const CmdFrame * invoker, int word) Ligne 6114 C tcl90.dll!Tcl_EvalObjEx(Tcl_Interp * interp, Tcl_Obj * objPtr, int flags) Ligne 6095 C tcl90.dll!Tcl_RecordAndEvalObj(Tcl_Interp * interp, Tcl_Obj * cmdPtr, int flags) Ligne 182 C tcl90.dll!StdinProc(void * clientData, int dummy739) Ligne 793 C tcl90.dll!Tcl_NotifyChannel(Tcl_Channel_ * channel, int mask) Ligne 8603 C tcl90.dll!ConsoleEventProc(Tcl_Event * evPtr, int flags) Ligne 1443 C tcl90.dll!Tcl_ServiceEvent(int flags) Ligne 710 C tcl90.dll!Tcl_DoOneEvent(int flags) Ligne 1007 C tcl9tk90.dll!Tk_MainLoop() Ligne 2127 C tcl90.dll!Tcl_MainExW(__int64 argc, wchar_t * * argv, int(*)(Tcl_Interp *) appInitProc, Tcl_Interp * interp) Ligne 563 C tclsh90.exe!wmain(int argc, wchar_t * * argv) Ligne 144 C This seems to be due to the added code in PanedPaneCommand() and PanedForgetCommand() in [6bc95282], which in turn points to the TIP #660 reform (signed lengths and indices). @Ashok, could you please have a look? marc_culler (claiming to be Marc Culler) added on 2024-06-01 00:12:42: This ticket probably needs more information. Testing on macOS 14 with Tk9.6.14 I get: % ttk::panedwindow .p .p % .p pane 0 Slave index 0 out of bounds There is no crash. |
