<i>Tcl parser UB (braces vs. quotes/brackets)</i>.
by
.
D 2020-01-20T20:19:19.855
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment Today\sI\stried\sto\sfind\ssome\ssporadic\sissue,\sso\strying\sto\sstart\slast\scode\spiece\sof\s[5adbede0722cb22f]\smultiple\stimes\s(using\stimerate\scall)\sends\swith\s"extra\scharacters\safter\sclose-brace"\s(because\sof\s"}"\sin\scatch\sin\s<code>[catch\s...]</code>).\r\nwhere\swhole\scode\srunning\s"good"\sif\scopy&pasted\sinto\sthe\sshell\s(then\sit\stakes\s"}"\sas\sa\soptions\svariable,\stry\s<code>set\s\\}</code>\sto\ssee\sthat).\r\n\r\nThe\sresult\sis\squasi\ssimilar\s"undefined\sbehavior",\sjust\scompare\sfollowing:\r\n<code><pre\sstyle=padding:10pt><b\sstyle="color:green">%\seval\s"puts\s}"\r\n}</b>\r\n<b\sstyle="color:red">%\sif\s1\s{\seval\s"puts\s}"\s}\r\nextra\scharacters\safter\sclose-brace</b>\r\n</pre></code>\r\nand\r\n<code><pre\sstyle=padding:10pt><b\sstyle="color:green">%\seval\s"puts\s\\}"\r\n}\r\n%\sif\s1\s{\seval\s"puts\s\\}"\s}\r\n}</b>\r\n</pre></code>\r\nI\scould\sfix\sthat,\sbut\sdo\snot\sreally\sknow\show:\r\n<ol>\r\n<li>either\s<code>eval\s"puts\s}"</code>\sshould\scause\ssome\s(parse)\serror</li>\r\n<li>or\s<code>if\s1\s{\seval\s"puts\s}"\s}</code>\sshould\savoid\san\serror\stoo\s(must\sconsider\sopen\squotes\sand\ssquare\sbrackets)</li>\r\n</ol>\r\nThe\sdecision\sis\ssomething\sfor\sa\ssyntax\sevangelists\s(@TCT).\r\n\r\nAnyway\sif\sparser\sworks\sdifferently\son\scertain\scircumstances\s(e.\sg.\ssome\scode\sbecomes\senclosed\sor\scopied\sin\sother\scode\swithin\sbraces)\s-\sit\sis\spretty\sgood\sdefinition\sof\sUB.\r\n\r\nIn\smy\sopinion\sthe\sparser\sshall\sto\swork\salways\sin\sthe\ssame\sway...\sbecause\sit\smay\sbe\sobvious\son\ssome\ssmall\scode\spieces,\sbut\scan\scause\sreal\sburning\sbrain\son\ssome\sunpaired\sbrace\sin\slarge\scodes\swith\smany\snested\squotes/brackets/braces.<br/>\r\nEspecially\sif\scode\sis\screated\s"dynamically"\s(some\stemplate\sengine\smixing\sTcl\swith\ssome\sother\slang,\slike\shtml),\sso\syou've\sto\slook\son\ssome\sinterim\sresult\sof\spre-processor\sto\sfind\sthe\sissue.
J foundin any
J is_private 0
J login sebres
J priority 5\sMedium
J resolution None
J severity Severe
J status Open
J submitter sebres
J subsystem 45.\sParsing\sand\sEval
J title Tcl\sparser\sUB\s(braces\svs.\squotes/brackets)
J type Bug
K eabb2f5613b6996eb80bc73f903a8da139c78dbd
U sebres
Z be75f83765f980921569eba36baf3b5c