Bug 258392 - lang/tcl85 lang/tcl86: fix unsafe buffer lifetime
Summary: lang/tcl85 lang/tcl86: fix unsafe buffer lifetime
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-tcltk (Nobody)
Depends on:
Blocks: 258209
  Show dependency treegraph
Reported: 2021-09-09 18:09 UTC by Dimitry Andric
Modified: 2021-09-10 07:05 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (tcltk)

lang/tcl8[56]: apply upstream fix for unsafe buffer lifetime (2.06 KB, patch)
2021-09-09 18:09 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer 2021-09-09 18:09:18 UTC
Created attachment 227791 [details]
lang/tcl8[56]: apply upstream fix for unsafe buffer lifetime

During an exp-run for llvm 13 (see bug 258209), it turned out that lang/tcl8[56] compiled with clang 13 result in problems when databases/sqlite3 attempts to generate its main sqlite3.c source with tclsh [1] [2]:

sqlite3.c:17852:2: error: invalid preprocessing directive
#defi 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
sqlite3.c:18129:2: error: invalid preprocessing directive
#definly system table */
sqlite3.c:18223:2: error: invalid preprocessing directive
#defi     /* ON DELETE and ON UPDATE actions, respectively */

After some searching in tcl history I found that the cause is upstream ticket https://core.tcl-lang.org/tcl/info/24b9181478 ("Fix unsafe buffer lifetime"). They patched the 8.5 and 8.6 branches, but this didn't appear in a release yet. 8.7 already has the fix.

The unsafe buffer gets optimized differently with clang 13, causing the sqlite3 build to break due to its tcl scripts outputting garbled generated code.

Here is a patch for tcl 8.5 and tcl 8.6. I verified that all tcl versions in the ports tree can now be compiled with clang 13, and then succesfully generate the sqlite3.c main file.

[1] http://gohan04.nyi.freebsd.org/data/mainamd64PR258209-default/2021-09-05_20h27m09s/logs/errors/sqlite3-3.35.5_3,1.log
[2] http://gohan04.nyi.freebsd.org/data/mainamd64PR258209-default/2021-09-05_20h27m09s/logs/errors/sqlite3-tcl-3.35.5_3,1.log
Comment 1 commit-hook freebsd_committer 2021-09-10 07:04:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1bf09e93cdc274fdf6d2b8ed84d0d6b0efa5503b

commit 1bf09e93cdc274fdf6d2b8ed84d0d6b0efa5503b
Author:     Pietro Cerutti <gahr@FreeBSD.org>
AuthorDate: 2021-09-10 07:00:27 +0000
Commit:     Pietro Cerutti <gahr@FreeBSD.org>
CommitDate: 2021-09-10 07:03:41 +0000

    lang/tcl8[56]: fix unsafe buffer lifetime, bump PORTREVISION

    PR:             258392
    Reported by:    dim
    Obtained from:  https://core.tcl-lang.org/tcl/info/24b9181478

 lang/tcl85/Makefile                          |  2 +-
 lang/tcl85/files/patch-generic_tclIO.c (new) | 21 +++++++++++++++++++++
 lang/tcl86/Makefile                          |  2 +-
 lang/tcl86/files/patch-generic_tclIO.c (new) | 21 +++++++++++++++++++++
 4 files changed, 44 insertions(+), 2 deletions(-)
Comment 2 Pietro Cerutti freebsd_committer 2021-09-10 07:05:17 UTC
Thanks a lot!