.
by
oehhar
2024-07-08 16:47:43.
D 2024-07-08T16:47:43.631
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment For\sme,\sthe\sfollowing\sscript\scrashes\swith\ssegmentation\sfault,\swhen\sthe\smenubutton\sis\sopened\sand\sthe\scheckbutton\sis\sselected.\r\n\r\n<verbatim>\r\npack\s[ttk::menubutton\s.b\s-text\s"Button"]\r\nmenu\s.b.s\s-tearoff\s0\r\n.b.s\sadd\scheckbutton\s-label\sSelected\s-command\sselected\r\n.b\sconfigure\s-menu\s.b.s\r\n\r\nproc\sselected\s{}\s{\r\n\s\s\s\sdestroy\s.b\r\n\s\s\s\sputs\s.\r\n}\r\n</verbatim>\r\n\r\nThe\scrash\sdoes\snot\shappen,\sif\sone\sof\sthe\scommands\sof\sthe\sselected\sroutine\sare\sremoved.\r\n\r\nEnvironment:\r\n\r\n\s\s\s*\s\s\scurrent\stcl/tk\sbranch\score-8-6-branch\sor\s8.6.14\srelease\r\n\s\s\s*\s\s\sCompiled\sby\sVisualStudio\s2015\sin\sx86\s(32bit)\smode\r\n\s\s\s*\s\s\splatform:\sMS_Windows\s10\s64\sbit\r\n\r\nThe\slast\scall\sin\sTk\sis\sin\sgeneric\\tkMenu.c\sproc\sDestroyMenuEntry\sline\s1450:\r\n<verbatim>\r\n\tTcl_UntraceVar2(menuPtr->interp,\svarName,\sNULL,\r\n\t\tTCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,\r\n\t\tMenuVarProc,\smePtr);\r\n</verbatim>\r\n\r\nThe\svariable\scontents\sare:\r\n<verbatim>\r\nmenuPtr->interp\s:\slooks\slike\sarbitrary\smemory.\r\nvarName:\sString\s"fStop"\r\nMenuVarProc\s->\spointer\sto\sa\sfunction\r\nmePtr:\scurrent\sMenu\sentry\r\n</verbatim>\r\n\r\nThe\smenuPtr\sdoes\snot\slook\sgood.\sIt\sis\sthe\smenu\sentry\sstructure\sTkMenuEntry\s"menuPtr"\selement.\r\n\r\nI\ssuppose,\sthat\sthe\sdestroy\sof\sthe\swidget\shas\salready\sdestroyed\sthe\smenu.\r\nThe\smenu\sitem\sis\spreserved\sand\sits\sdestruction\sfails,\sas\sthe\smenu\sis\salready\sfreed.\r\n\r\n---\r\n\r\nWith\s"Tcl_UntraceVar2",\sTCL\sis\scalled.\sThe\ssegmentation\sfault\shappens\sin\sthe\sfunction\r\n"TclLookupSimpleVar()"\sin\sfile\s"generic\\tclVar.c"\sline\s866:\r\n\r\n<verbatim>\r\n\s\s\s\sif\s((cxtNsPtr->varResProc\s!=\sNULL\s||\siPtr->resolverPtr\s!=\sNULL)\r\n\t\s\s\s\s&&\s!(flags\s&\sTCL_AVOID_RESOLVERS))\s{\r\n</verbatim>\r\n\r\nThe\sinvalid\sread\saccess\sis\sin\s"cxtNsPtr->varResProc",\swhich\scomes\sfrom\s"cxtNsPtr\s=\siPtr->globalNsPtr;".\r\n"iPtr"\sis\sprobably\sthe\scurrent\sinterpreter\spointer\sand\slooks\slike\sinvalid\sdata.\r\n\r\nThis\sinvalid\sdata\smakes\sall\sthe\schain\sand\sis\salready\spresent\sin\sthe\supper\stk\scall.\r\n\r\nThe\scall\sstack\sis\sas\sfollows:\r\n<verbatim>\r\n>\ttcl86tg.dll!TclLookupSimpleVar(Tcl_Interp\s*\sinterp,\sTcl_Obj\s*\svarNamePtr,\sint\sflags,\sint\screate,\sconst\schar\s*\s*\serrMsgPtr,\sint\s*\sindexPtr)\sZeile\s866\tC\r\n\s\ttcl86tg.dll!TclObjLookupVarEx(Tcl_Interp\s*\sinterp,\sTcl_Obj\s*\spart1Ptr,\sTcl_Obj\s*\spart2Ptr,\sint\sflags,\sconst\schar\s*\smsg,\sint\screatePart1,\sint\screatePart2,\sVar\s*\s*\sarrayPtrPtr)\sZeile\s710\tC\r\n\s\ttcl86tg.dll!TclObjLookupVar(Tcl_Interp\s*\sinterp,\sTcl_Obj\s*\spart1Ptr,\sconst\schar\s*\spart2,\sint\sflags,\sconst\schar\s*\smsg,\sint\screatePart1,\sint\screatePart2,\sVar\s*\s*\sarrayPtrPtr)\sZeile\s520\tC\r\n\s\ttcl86tg.dll!TclLookupVar(Tcl_Interp\s*\sinterp,\sconst\schar\s*\spart1,\sconst\schar\s*\spart2,\sint\sflags,\sconst\schar\s*\smsg,\sint\screatePart1,\sint\screatePart2,\sVar\s*\s*\sarrayPtrPtr)\sZeile\s437\tC\r\n\s\ttcl86tg.dll!Tcl_UntraceVar2(Tcl_Interp\s*\sinterp,\sconst\schar\s*\spart1,\sconst\schar\s*\spart2,\sint\sflags,\schar\s*(*)(void\s*,\sTcl_Interp\s*,\sconst\schar\s*,\sconst\schar\s*,\sint)\sproc,\svoid\s*\sclientData)\sZeile\s2919\tC\r\n\s\ttk86tg.dll!DestroyMenuEntry(char\s*\smemPtr)\sZeile\s1450\tC\r\n\s\ttcl86tg.dll!Tcl_Release(void\s*\sclientData)\sZeile\s229\tC\r\n\s\ttk86tg.dll!TkInvokeMenu(Tcl_Interp\s*\sinterp,\sTkMenu\s*\smenuPtr,\sint\sindex)\sZeile\s1064\tC\r\n\s\ttk86tg.dll!TkWinHandleMenuEvent(HWND__\s*\s*\sdummy1141,\sunsigned\sint\s*\spMessage,\sunsigned\sint\s*\spwParam,\slong\s*\splParam,\slong\s*\splResult)\sZeile\s1243\tC\r\n\s\ttk86tg.dll!TkWinMenuProc(HWND__\s*\shwnd,\sunsigned\sint\smessage,\sunsigned\sint\swParam,\slong\slParam)\sZeile\s1013\tC\r\n\s\tuser32.dll!__InternalCallWinProc@20()\tUnbekannt\r\n\s\tuser32.dll!UserCallWinProcCheckWow()\tUnbekannt\r\n\s\tuser32.dll!_DispatchMessageWorker@8()\tUnbekannt\r\n\s\tuser32.dll!_DispatchMessageW@4()\tUnbekannt\r\n\s\ttcl86tg.dll!Tcl_WaitForEvent(const\sTcl_Time\s*\stimePtr)\sZeile\s518\tC\r\n\s\ttcl86tg.dll!Tcl_DoOneEvent(int\sflags)\sZeile\s946\tC\r\n\s\ttk86tg.dll!Tk_MainLoop()\sZeile\s2109\tC\r\n\s\ttk86tg.dll!Tk_MainExW(int\sargc,\swchar_t\s*\s*\sargv,\sint(*)(Tcl_Interp\s*)\sappInitProc,\sTcl_Interp\s*\sinterp)\sZeile\s385\tC\r\n\s\twish86tg.exe!wWinMain(HINSTANCE__\s*\shInstance,\sHINSTANCE__\s*\shPrevInstance,\swchar_t\s*\slpszCmdLine,\sint\snCmdShow)\sZeile\s176\tC\r\n\s\twish86tg.exe!invoke_main()\sZeile\s118\tC++\r\n\s\twish86tg.exe!__scrt_common_main_seh()\sZeile\s253\tC++\r\n\s\twish86tg.exe!__scrt_common_main()\sZeile\s296\tC++\r\n\s\twish86tg.exe!wWinMainCRTStartup()\sZeile\s17\tC++\r\n\s\tkernel32.dll!@BaseThreadInitThunk@12()\tUnbekannt\r\n\s\tntdll.dll!__RtlUserThreadStart()\tUnbekannt\r\n\s\tntdll.dll!__RtlUserThreadStart@8()\tUnbekannt\r\n</verbatim>\r\n\r\nPlease\scome\sback\sto\sme\sin\scase\sof\sany\squestions.\r\n\r\nThank\syou\sfor\sany\shelp,\r\nHarald
J foundin core-8-6-branch
J is_private 0
J login oehhar
J priority 5\sMedium
J private_contact 0f366eb3e9e2fcab52b8ebacd197db9047186a5f
J resolution None
J severity Minor
J status Open
J submitter oehhar
J subsystem 13.\sWin\sMenus
J title Read\ssegmentation\sfault\son\sMenu\swhen\sdestroyed\sin\scommand\sand\sconsole\soutput
J type Bug
K 2d3a81c0ecd1ccbc8c5d3063dfa6630e70b88266
U oehhar
Z 1b08bfe9051ff1d96842894303eedbda