Skip to content
Tcl Source Code Artifact [79be50c9e9]
Login

Artifact [79be50c9e9]

Artifact 79be50c9e9dc43431f488a28a416a9d81548e36184fd1341b7c20e15b5d90bd3:

Ticket change [79be50c9e9] - New ticket [7371b6270b727521|7371b6270b] <i>AddressSanitizer use-after-return detection breaks coroutines</i>. by chrstphrchvz on 2023-08-04 04:36:43.
D 2023-08-04T04:36:43.859
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment AddressSanitizer\s(ASan)\scan\sdetect\suse-after-return\serrors.\sDepending\son\sthe\splatform,\sthis\sis\senabled\seither\sby\sdefault,\sor\sby\susing\sthe\sappropriate\scompiler\sflags\sor\sruntime\senvironment\svariables\s(e.g.\s<tt>ASAN_OPTIONS=detect_use_after_return=1</tt>).\r\n\r\nBut\senabling\sthis\scan\scompletely\sbreak\sTcl\scoroutines:\sthere\swill\sbe\sunexpected\s“cannot\syield:\sC\sstack\sbusy”\serrors,\sand\snumerous\stests\swill\sfail\sor\seven\shang\s(e.g.\shttp-3.10.0,\sio-28.6).\sThis\sis\sbecause\sthe\sreal\sstack\sgets\sreplaced\swith\sa\sheap-allocated\sfake\sstack,\sand\sthere\sis\s[https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterReturn#compatibility|no\sguarantee]\sthat\sthe\saddress\sof\sa\sstack\svariable\swill\sbe\sconsistent\sfor\sa\sgiven\sC\sstack\sdepth,\sas\sassumed\sby\sthe\scoroutines\simplementation.\r\n\r\nRather\sthan\srequiring\sAddressSanitizer\suse-after-return\sdetection\sto\sbe\sdisabled,\sI\ssuggest\sthat\sTcl\suse\sAddressSanitizer-friendly\sapproaches\sinstead.\sFor\sGCC\sand\sClang,\sthere\sis\s<a\shref="https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html#index-_005f_005fbuiltin_005fframe_005faddress"><tt>__builtin_frame_address(0)</tt></a>;\sand\sfor\sMSVC,\sthere\sis\s<a\shref="https://learn.microsoft.com/en-us/cpp/intrinsics/addressofreturnaddress"><tt>_AddressOfReturnAddress()</tt></a>.\sAnd\sI\ssuggest\salways\susing\sthese\swhen\savailable,\sfor\sconsistency\sbetween\sbuilds\swith\sand\swithout\sAddressSanitizer,\sand\sin\scase\sof\sother\suse-after-return\sdetection\stools\swith\ssimilar\slimitations.\sSee\sattached\spatch.\s[https://github.com/llvm/llvm-project/blob/llvmorg-10.0.0-rc1/clang/lib/Basic/Stack.cpp#L24]\sshows\sa\svery\ssimilar\sexample.
J foundin 8.6.13
J is_private 0
J login chrstphrchvz
J priority 5\sMedium
J private_contact 6133eb3026f9b10aa9b7b48da92ae2834fc225b0
J resolution None
J severity Important
J status Open
J submitter chrstphrchvz
J subsystem 60.\sNRE\sand\scoroutines
J title AddressSanitizer\suse-after-return\sdetection\sbreaks\scoroutines
J type Patch
K 7371b6270b727521cf0c7044a882d16ef5c4e96b
U chrstphrchvz
Z eb096b9e9ef3650f2b4cb7561c2b1cae