Skip to content
Tcl Source Code History Of Ticket 7371b6270b
Login

History Of Ticket 7371b6270b

Artifacts Associated With Ticket 7371b6270b

  1. Ticket change [79be50c9e9] (rid 217025) by chrstphrchvz on 2023-08-04 04:36:43:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      AddressSanitizer (ASan) can detect use-after-return errors. Depending on the platform, this is enabled either by default, or by using the appropriate compiler flags or runtime environment variables (e.g. <tt>ASAN_OPTIONS=detect_use_after_return=1</tt>).
      
      But enabling this can completely break Tcl coroutines: there will be unexpected “cannot yield: C stack busy” errors, and numerous tests will fail or even hang (e.g. http-3.10.0, io-28.6). This is because the real stack gets replaced with a heap-allocated fake stack, and there is [https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterReturn#compatibility|no guarantee] that the address of a stack variable will be consistent for a given C stack depth, as assumed by the coroutines implementation.
      
      Rather than requiring AddressSanitizer use-after-return detection to be disabled, I suggest that Tcl use AddressSanitizer-friendly approaches instead. For GCC and Clang, there is <a href="https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html#index-_005f_005fbuiltin_005fframe_005faddress"><tt>__builtin_frame_address(0)</tt></a>; and for MSVC, there is <a href="https://learn.microsoft.com/en-us/cpp/intrinsics/addressofreturnaddress"><tt>_AddressOfReturnAddress()</tt></a>. And I suggest always using these when available, for consistency between builds with and without AddressSanitizer, and in case of other use-after-return detection tools with similar limitations. See attached patch. [https://github.com/llvm/llvm-project/blob/llvmorg-10.0.0-rc1/clang/lib/Basic/Stack.cpp#L24] shows a very similar example.
      
    5. foundin initialized to: "8.6.13"
    6. is_private initialized to: "0"
    7. login: "chrstphrchvz"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "6133eb3026f9b10aa9b7b48da92ae2834fc225b0"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "chrstphrchvz"
    14. subsystem initialized to: "60. NRE and coroutines"
    15. title initialized to:
      AddressSanitizer use-after-return detection breaks coroutines
      
    16. type initialized to: "Patch"
  2. Add attachment "7371b6270b.diff" [7e5c5c83e8] (rid 217027) by chrstphrchvz on 2023-08-04 04:44:01.

  3. Ticket change [b2fa6943f6] (rid 217037) by chrstphrchvz on 2023-08-04 15:30:24:

    1. icomment:
      I now notice the same issue affecting NRE test functions. I will look into patching those as well.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
    4. title changed to:
      AddressSanitizer use-after-return detection breaks NRE tests, coroutines
      
  4. Add attachment "7371b6270b.diff" [a1b7bf7d0e] (rid 218944) by chrstphrchvz on 2023-09-30 08:36:43.

  5. Ticket change [fe0f180691] (rid 218945) by chrstphrchvz on 2023-09-30 08:37:43:

    1. icomment:
      See revised attached patch. It seems that factoring out code for use in both tclBasic.c and tclTest.c requires reserving a stub in tclInt.decls.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [c220c84bdb] (rid 219115) by chrstphrchvz on 2023-10-05 08:14:33:

    1. icomment:
      I notice the CI failure for GCC on Windows. It attempted to use <tt>_AddressOfReturnAddress()</tt> which is MSVC-specific, but the condition is <tt>HAVE_INTRIN_H</tt> even though intrin.h is not MSVC-specific. I am thinking that the condition for <tt>_AddressOfReturnAddress()</tt> should depend on <tt>defined(_MSC_VER)</tt> (whether or not in addition to <tt>HAVE_INTRIN_H</tt>); and/or the GCC/Clang <tt>__builtin_frame_address(0)</tt> case should go first (as done by LLVM).
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [e3ec4f07fe] (rid 219309) by chrstphrchvz on 2023-10-11 10:47:52:

    1. icomment:
      Note to self regarding <tt>#if __GNUC__</tt> being changed to <tt>#if defined(__GNUC__)</tt> in [df7a3fd9e118]: although the former is what the LLVM example used, and would seem more robust in case of someone/something else defining <tt>__GNUC__</tt> to 0, the latter is more consistent with the rest of core Tcl.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  8. Ticket change [690a5b076e] (rid 219310) by chrstphrchvz on 2023-10-11 10:59:44:

    1. icomment:
      …in other words, I consider the change to be justified.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  9. Ticket change [8f9e067ff1] (rid 219685) by chrstphrchvz on 2023-10-22 16:24:40:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2460240.1838048"
    3. closer changed to: "chrstphrchvz"
    4. icomment:
      I am not aware of anything else to do for this ticket; closing. Thanks for committing and revising this, Jan!
      
    5. login: "chrstphrchvz"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Accepted"
    8. status changed to: "Closed"
  10. Ticket change [a16d601953] (rid 240144) by dgp on 2025-05-16 18:10:30:

    1. closedate changed to: "2460812.2572956"
    2. closer changed to: "dgp"
    3. icomment:
      This patch was merged to the 8.6 branch in checkin [910b623484].
      
      When I attempt a build of that checkin on a Macbook Pro, M1 model from 2021,
      running Sonoma 14.7.5, and the "gcc" compiler is clang-1600.0.26.6, I see
      crashes in the test suite in test files
      
      coroutine.test
      nre.test
      
      This is with a build under the tcl/unix build system.
      
      I have to guess that the compiler intrinsics added by this patch need
      some platform variation to fix the problem.  The crashes seem to 
      persist in all checkins of the 86 branch since then.
      
    4. login: "dgp"
    5. mimetype: "text/plain"
  11. Ticket change [5782fc3d90] (rid 240146) by chrstphrchvz on 2025-05-16 21:20:21:

    1. closedate changed to: "2460812.38913705"
    2. closer changed to: "chrstphrchvz"
    3. icomment:
      I do not know if I will return to help with this anytime soon.
      
      clang-1600.0.26.6 is Xcode/command line tools 16.2, released late 2024--much more recent than what I had access to when testing this patch. Maybe try adding <tt>#error</tt> to see which approach is getting compiled instead.
      
    4. login: "chrstphrchvz"
    5. mimetype: "text/x-fossil-wiki"
  12. Ticket change [3c4e04d5c6] (rid 240249) by dgp on 2025-05-20 18:39:37:

    1. closedate changed to: "2460816.27751844"
    2. closer changed to: "dgp"
    3. icomment:
      It looks like the tcl/unix builds make it far too easy
      for a `make test` to test the installed library that is
      still buggy instead of testing the built library in the
      workspace which includes the fix.
      
      I think this was a false alarm.
      
    4. login: "dgp"
    5. mimetype: "text/plain"