From 9e60af6d4a6545975c758cf3979105a2b7d59467 Mon Sep 17 00:00:00 2001 From: Ellian Carlos Date: Mon, 5 Oct 2026 20:13:23 +0000 Subject: [PATCH] fix(devenv): apply the srcML fix for an attribute in parentheses srcML corrupts its heap and dies with signal 11 or 6 on a GCC __attribute__ that follows an expression inside parentheses, for example "F(a __attribute__((unused)));" (srcML/srcML#2425). The pinned revision 8a3a629d has the bug, with or without --position. The pipeline then excludes the blob, and blame credits the next version of the file with all its lines. Upstream fixed it in 0910c0eb (srcML/srcML#2426), merged on 2026-10-04, but no release carries it yet. Apply that commit as a patch on top of the pin, and add a regression test. On mariadb, the patched build tokenizes all 8,061 blobs that crashed. On 65 blobs that did not crash, its token output is byte-identical to the unpatched pin. --- nix/srcml.nix | 12 +++++++++++- tests/t/tokenizeSrcMl.t | 14 +++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/nix/srcml.nix b/nix/srcml.nix index 93f91a24..f8ac9cb0 100644 --- a/nix/srcml.nix +++ b/nix/srcml.nix @@ -1,9 +1,12 @@ # srcML at a pinned source revision. The 1.1.0 release binary segfaults under # `--position` (srcML/srcML#2395, fixed upstream by cebd3ab, still unreleased), -# and the pipeline always passes `--position`. +# and the pipeline always passes `--position`. The pin also segfaults on a GCC +# `__attribute__` after an expression inside parentheses (srcML/srcML#2425), so +# the upstream fix 0910c0eb is applied on top of it until a release carries it. { lib , stdenv , fetchFromGitHub +, fetchpatch , fetchurl , cmake , ninja @@ -59,6 +62,13 @@ stdenv.mkDerivation { hash = "sha256-stn1VP+D9Awd9B+r3UWIjHJUkoNU52SOJndX9hLEnrY="; }; + patches = [ + (fetchpatch { + url = "https://github.com/srcML/srcML/commit/0910c0ebac7d595a3ad47e3bbe681dfa130bf3b0.patch"; + hash = "sha256-GqVYV8Z8OmK1TGsusNiGUjfXDAJlkB03ZPyuYLVABFA="; + }) + ]; + nativeBuildInputs = [ cmake ninja jdk_headless ]; buildInputs = [ libxml2 libxslt libarchive curl ] diff --git a/tests/t/tokenizeSrcMl.t b/tests/t/tokenizeSrcMl.t index b2978141..14aed94c 100644 --- a/tests/t/tokenizeSrcMl.t +++ b/tests/t/tokenizeSrcMl.t @@ -20,7 +20,7 @@ plan skip_all => "ctags not on PATH" plan skip_all => "srcml2token not built (cd tokenize/srcMLtoken && make)" unless -x $srcml2token; -plan tests => 24; +plan tests => 27; my $workdir = tempdir(CLEANUP => 1); @@ -110,6 +110,18 @@ sub run_tokenizer { } } +{ + my $attr = "$workdir/attribute-in-parens.c"; + open(my $fh, '>', $attr) or die $!; + print $fh "void f(int a) { F(a __attribute__((unused))); }\n"; + close $fh; + + my ($status, $out, $err) = run_tokenizer("--position", "'$attr'"); + is($status, 0, "a GCC attribute after an expression inside parentheses tokenizes (srcML/srcML#2425)"); + like($out, qr/^\d+:\d+\|attribute\|__attribute__\(\($/m, "and the attribute is in the tokenization"); + like($out, qr/^\d+:\d+\|name\|unused$/m, "with its argument"); +} + { my $dies = "$workdir/srcml-that-dies"; open(my $fh, '>', $dies) or die $!;