Skip to content
Tcl Source Code Artifact [0dc48976a1]
Login

Artifact [0dc48976a1]

Artifact 0dc48976a14901e4fc759d31ef463ef18e2697d6fdc937365be2296e64c2f8c4:

Ticket change [0dc48976a1] - New ticket [a63f5a4fed23469b|a63f5a4fed] <i>Safe interp gets the parent&#39;s -errorinfo and -errorstack through a failing alias</i>. by serhiy.storchaka on 2026-10-17 10:51:11.
D 2026-10-17T10:51:11.762
J cmimetype text/x-fossil-wiki
J comment When\sa\scommand\sin\sa\ssafe\sinterpreter\sis\san\salias\sto\sa\sproc\sin\sa\strusted\sparent\sand\sthat\sproc\nfails,\sthe\sfull\s<tt>-errorinfo</tt>\sand\s<tt>-errorstack</tt>\sof\sthe\sparent\sare\scopied\sinto\sthe\nsafe\sinterpreter.\sThe\ssafe\sinterpreter\sthen\ssees\sthe\sparent's\sproc\snames,\sthe\stext\sof\stheir\nbodies,\sfile\snames\sof\ssourced\sscripts\sand,\sthrough\s<tt>-errorstack</tt>,\sthe\sactual\sargument\nvalues\sof\severy\sparent\sproc\son\sthe\scall\sstack.\n\n<verbatim>\nproc\sGetPassword\s{user}\s{return\shunter2}\nproc\sVerifyPassword\s{user\spw}\s{error\s"access\sdenied"}\nproc\sLoginAlias\s{user}\s{VerifyPassword\s$user\s[GetPassword\s$user]}\nset\ss\s[interp\screate\s-safe]\ninterp\salias\s$s\slogin\s{}\sLoginAlias\nputs\s[interp\seval\s$s\s{\n\s\s\s\scatch\s{login\salice}\smsg\sopts\n\s\s\s\slist\s$::errorInfo\s[dict\sget\s$opts\s-errorstack]\n}]\n</verbatim>\n\nActual\soutput\s(9.1,\s9.0,\s8.6):\n\n<verbatim>\n{access\sdenied\n\s\s\s\swhile\sexecuting\n"error\s"access\sdenied""\n\s\s\s\s(procedure\s"VerifyPassword"\sline\s1)\n\s\s\s\sinvoked\sfrom\swithin\n"VerifyPassword\s$user\s[GetPassword\s$user]"\n\s\s\s\s(procedure\s"LoginAlias"\sline\s1)\n\s\s\s\sinvoked\sfrom\swithin\n"login\salice"}\s{INNER\s{returnImm\s{access\sdenied}\s{}}\sCALL\s{VerifyPassword\salice\shunter2}\sCALL\s{LoginAlias\salice}}\n</verbatim>\n\nExpected:\sthe\ssafe\sinterpreter\ssees\sonly\sthe\serror\smessage\sand\sits\sown\spart\sof\sthe\straceback,\nas\sif\s<tt>login</tt>\swere\sa\sC\scommand\sfailing\swith\sthat\smessage:\n\n<verbatim>\n{access\sdenied\n\s\s\s\sinvoked\sfrom\swithin\n"login\salice"}\s{}\n</verbatim>\nIf\sthe\salias\starget\sdoes\s<nowiki>[source]</nowiki>\sa\sfile\sand\sthe\sscript\sfails,\sthe\straceback\nalso\scontains\s<tt>(file\s"/full/path/of/the/parent/script.tcl"\sline\sN)</tt>.\n\nCause:\s<tt>AliasObjCmd</tt>\sin\sgeneric/tclInterp.c\scalls\s<tt>Tcl_TransferResult</tt>,\swhich\ncopies\sthe\swhole\sreturn\soptions\sdictionary\s(<tt>Tcl_GetReturnOptions</tt>)\sof\sthe\sparent\sinto\nthe\schild,\swhether\sthe\schild\sis\ssafe\sor\snot.\sThe\sSafe\sBase\savoids\sthis\sonly\sbecause\sits\salias\nprocs\srethrow\swith\s<nowiki>[return\s-code\serror\s$msg]</nowiki>;\suser-defined\saliases\sget\sno\ssuch\nprotection.\sA\spossible\sfix\sis\sto\sdrop\s<tt>-errorinfo</tt>\sand\s<tt>-errorstack</tt>\s(keeping\sthe\nmessage,\s<tt>-errorcode</tt>\sand\sthe\sreturn\scode)\swhen\sthe\starget\sinterpreter\sis\ssafe\sand\sthe\nsource\sis\snot.\n\nThis\sis\sthe\sknownBug\stest\sinterp-26.8,\sone\sof\sthe\stests\scollected\sin\s[219164ffff]\s(bug\s1637,\n1999).\sThe\serrorInfo\spart\shas\sbeen\sthere\sat\sleast\ssince\s8.4;\s<tt>-errorstack</tt>\s(8.6)\smade\sit\nworse,\ssince\sit\scarries\sargument\svalues.\sRelated:\s[77f0dbc0f8]\s(a\sstale\s<tt>-errorstack</tt>\nfrom\san\searlier,\salready\scaught\serror\sin\sthe\sparent\sis\salso\spassed\sthrough\san\salias,\sbecause\n<tt>Tcl_GetReturnOptions</tt>\signores\s<tt>resetErrorStack</tt>),\s[1669424fff]\s(file\snames\sleak\ninto\ssafe\sinterps\svia\s<nowiki>[info\sframe]</nowiki>).
J foundin 8.6.18,\s9.0.5,\s9.1.0
J login serhiy.storchaka
J priority 5\sMedium
J resolution None
J severity Important
J status Open
J subsystem 20.\s[interp]
J title Safe\sinterp\sgets\sthe\sparent's\s-errorinfo\sand\s-errorstack\sthrough\sa\sfailing\salias
J type Bug
K a63f5a4fed23469bf1e1caaaf674b9dc765dd2ce
U serhiy.storchaka
Z 13a4667845052bbe40eeca842d226ee2