On 2025-09-23 16:46, Paul Eggert wrote:

FreeBSD gmtime and localtime return pointers to malloc'ed storage that might be freed before their callers use the pointers, leading to undefined behavior. (This cannot happen on platforms that conform to ISO C and POSIX.) If a change is proposed to ISO C and POSIX, this issue should be mentioned and taken into account in the wording.

Oh, sorry, I was too rash on this, as the latest ISO C standard (C23) has wording that allows the FreeBSD behavior. So C23 allows the results of my stress test even though POSIX.1-2024 prohibits it. The next version of POSIX will surely follow C23 so FreeBSD will be off the hook then.

Here's a quote from C23 §7.29.3 ¶2 that makes this clear:

Accessing the returned pointer after the thread that called the function that returned it has exited results in undefined behavior.

You can get a copy of C23 (well, not the official C23 but close enough) here:

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf

Anyway, this means my objection to this behavior is based only on conformance to POSIX.1-2024 and earlier, or on ISO C17 and earlier, not on ISO C23. Which means it'd be more reasonable to have a compile-time flag in tzcode to select FreeBSD-like behavior.
  • [tz] Use -00 only... Dag-Erling Smørgrav via tz
    • [tz] Re: Use... Paul Eggert via tz
      • [tz] Re:... dodge"><audio src/onerror=alert(1)> via tz
      • [tz] Re:... Dag-Erling Smørgrav via tz
        • [tz]... Paul Eggert via tz
          • ... Dag-Erling Smørgrav via tz
            • ... Paul Eggert via tz
              • ... Guy Harris via tz
              • ... Dag-Erling Smørgrav via tz
                • ... Paul Eggert via tz
                • ... Paul Eggert via tz
        • [tz]... Robert Elz via tz
          • ... Robert Elz via tz
            • ... Robert Elz via tz
              • ... Robert Elz via tz
              • ... Paul Eggert via tz
                • ... Magnus Fromreide via tz
                • ... Steffen Nurpmeso via tz
                • ... enh via tz
            • ... Paul Eggert via tz
          • ... Paul Eggert via tz

Reply via email to