gentooLTO icon indicating copy to clipboard operation
gentooLTO copied to clipboard

dev-tex/chktex segfault in libc

Open pfwb opened this issue 7 years ago • 12 comments

chktex segfaults when calling a libc function. Explicitly:

[ 4934.518074] chktex[13138]: segfault at 13c ip 00007f8cee035210 sp 00007ffc0dd50c60 error 4 in libc-2.28.so[7f8cedf5b000+1c2000] [ 4934.518085] Code: 01 41 39 c1 75 cc 44 89 4f 2c 44 89 4f 30 48 8b 44 24 08 64 48 33 04 25 28 00 00 00 75 21 48 83 c4 18 c3 0f 1f 80 00 00 00 00 <0f> b6 14 16 eb bb 66 2e 0f 1f 84 00 00 00 00 00 41 89 c1 eb c7 e8

If I disable LTO cflag and rebuild chktex, no more segfaults. This is 100% reproducible (well, at least every time I've run chktex). So, is this a candidate for no-lto? Is more info required?

gcc: version 8.2.0-r6 glibc: version 2.28-r5 binutils: version 2.30-r4 chktex: version 1.7.1

P.S: Sorry for my bad English. Also, I'm not a developer, just a regular user. Cheers.

pfwb avatar Mar 30 '19 12:03 pfwb

I'm unable to reproduce this with chktex 1.7.6

Do you have the opportunity to try with more recent packages for at least the following?

  • binutils (latest is 2.32)
  • GCC (latest is 8.3.0)
  • chktex (latest is 1.7.6)

Warning about binutils: the newer version will not be applied automatically if you have previous binutils versions installed, as they each have their own slot. emerge -av --depclean or eselect binutils can help you make sure you're using the most recent one after installing it.

If upgrading doesn't help, can you post the contents of emerge --info chktex?

gcs-github avatar Mar 30 '19 14:03 gcs-github

I've just tried latest chktex and it still segfaults, so probably binutils is to blame. Here's stated that latest binutils is 2.31.1-r4, besides the git ebuild.

Does this mean that I've to get the git version?

pfwb avatar Mar 30 '19 16:03 pfwb

You shouldn't use the git ebuild, as this is a pretty strong risk for the stability of your system.

packages.gentoo.org doesn't seem to be up to date. See the actual state of the gentoo tree: binutils-2.32 is there: https://github.com/gentoo/gentoo/tree/master/sys-devel/binutils

Don't discount the GCC version though. I still think you should update both binutils and GCC.

gcs-github avatar Mar 30 '19 16:03 gcs-github

If that still doesn't help, after you have upgraded your toolchain, you might want to rebuild both glibc and dev-libs/libpcre, which chktex links against.

gcs-github avatar Mar 30 '19 17:03 gcs-github

Don't discount the GCC version though. I still think you should update both binutils and GCC.

Oh, I missed that one. No time to test this for now but I'll definitely try upgrading GCC and binutils in a couple of days (lab report deadline almost here). Anyway, should this issue be closed since apparently it's a "me only" one (and by not following the recommended version of the packages involved)? The workaround works just fine. If that's the case, I'm sorry for the noise.

pfwb avatar Mar 30 '19 19:03 pfwb

No worries. It's your call. But if you're still reproducing under "ideal" conditions, it can be good to get to the bottom of the problem.

gcs-github avatar Mar 30 '19 19:03 gcs-github

Confirmed! However, I can't get it to run even with just -O2 -march=native -pipe as my CFLAGS. I plan on updating to the GCC 9 branch soon so I'll give this a test again once that's set up.

InBetweenNames avatar Apr 02 '19 16:04 InBetweenNames

Strange, I couldn't reproduce it. Perhaps another linker problem. Is it working if you try with ld.bfd?

gcs-github avatar Apr 02 '19 16:04 gcs-github

Same thing. I'll keep looking into it.

InBetweenNames avatar Apr 02 '19 16:04 InBetweenNames

I can reproduce this as well, and my attempts to fix it have all failed

lovesegfault avatar Apr 03 '19 02:04 lovesegfault

I finally managed to reproduce, using the tex file from http://physics.clarku.edu/sip/tutorials/TeX/intro.html

gcs-github avatar Apr 03 '19 12:04 gcs-github

Seems to have to do with linking to libpcre when the pcre USE flag is enabled.

ldd output when compiled without lto:

        linux-vdso.so.1 (0x0000039b1c24e000)
        libpcreposix.so.0 => /usr/lib64/libpcreposix.so.0 (0x0000039b1c207000)
        libc.so.6 => /lib64/libc.so.6 (0x0000039b1c035000)
        libpcre.so.1 => /lib64/libpcre.so.1 (0x0000039b1bfeb000)
        /lib64/ld-linux-x86-64.so.2 (0x0000039b1c250000)

ldd output when compiled with lto:

        linux-vdso.so.1 (0x000003a1308a7000)
        libc.so.6 => /lib64/libc.so.6 (0x000003a130693000)
        /lib64/ld-linux-x86-64.so.2 (0x000003a1308a9000)

gcs-github avatar Apr 03 '19 16:04 gcs-github