muttleyxd/clang-tools-static-binaries

clang-tidy 14 segfault

Opened this issue · 8 comments

Hello,

Running clang-tidy 14 on my available systems (ubuntu 22.02, Gentoo or arch linux) results in a segfault.

clang-format 14 doesn't segfault, nor does clang-tidy 13, 12...

Any idea?

This is an extract running the program with valgrind:

==1536299== Memcheck, a memory error detector
==1536299== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1536299== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==1536299== Command: ./clang-tidy-14_linux-amd64
==1536299== Parent PID: 1534110
==1536299== 
==1536299== Syscall param set_robust_list(head) points to uninitialised byte(s)
==1536299==    at 0x1B27B95: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1C2DD4E: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x42BD1D: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1FFF000417: ???
==1536299==  Address 0x4000bf0 is in the brk data segment 0x4000000-0x400123f
==1536299== 
==1536299== Conditional jump or move depends on uninitialised value(s)
==1536299==    at 0x1C62FF0: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1C62FBC: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1B27D86: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1C2DD4E: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x42BD1D: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1FFF000417: ???
==1536299== 
==1536299== Conditional jump or move depends on uninitialised value(s)
==1536299==    at 0x1C63074: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1C62FBC: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1B27D86: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1C2DD4E: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x42BD1D: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1FFF000417: ???
==1536299== 
==1536299== Conditional jump or move depends on uninitialised value(s)
==1536299==    at 0x1C68140: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1CCE1DA: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1CD2E44: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1CD60F5: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1C2DD88: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x42BD1D: ??? (in /home/user/Downloads/clang-tidy-14/clang-tidy-14_linux-amd64)
==1536299==    by 0x1FFF000417: ???

Hi! I forked muttleyxd's repository, bisected between v.13.0.0 and v14.0.0 and I was able to locate the first bad commit - 6a605b97a2006bd391f129a606483656b7c6fb28 as I'm not familiar with these regions of LLVM codebase. I've yet to try to understand this commit in terms of why it has such effects, but hopefully this investigation will push things further for us.

Ok, I checked out LLVM repository on the first "wrong" commit and I noticed the following:

  • it doesn't work when compiled on Ubuntu 20.04 and executed on Manjaro
  • it works when compiled on Ubuntu 22.04 and executed on Manjaro

and Github Actions is set to Ubuntu 20.04 for this project.

But because it worked on 22.04, I suppose this problem isn't really an issue of that particular commit from LLVM. I have no idea why it happens, but the only thing that comes to my mind is differences in glibc versions. I tested it by compiling this program:

#include <gnu/libc-version.h>
#include <stdio.h>

int main()
{
  printf("glibc_release: %s\n", gnu_get_libc_release());
  printf("glibc_version: %s\n", gnu_get_libc_version());
}

which produces:

  • on Ubuntu 20.04
glibc_release: stable
glibc_version: 2.31
  • on Ubuntu 22.04
glibc_release: stable
glibc_version: 2.35
  • on Manjaro
glibc_release: stable
glibc_version: 2.35

Thank you for investigating. I compiled version 14.0.5 under Ubuntu 22.04 without LTO (otherwise link time never ends) which runs quite well also under Ubuntu 22, Gentoo and Arch Linux.

Thank you again!

ubuntu-22.04 is now available for github runners: actions/runner-images#5998

I can confirm building clang-tidy-14 using ubuntu-22.04 in CI does fix this.

The latest release which includes Clang v15 still have Segmentation fault (tested on Ubuntu 20.04.5 LTS)

$ clang-tidy-15 --version
Segmentation fault

I confirm that higher version of clang-tidy linux amd64 are still segfaulting

./clang-tidy-16_linux-amd64
Segmentation fault

same segfault on centos 7.6