public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/31655] New: clang can't build glibc with stack protector
Date: Thu, 18 Apr 2024 15:00:36 +0000	[thread overview]
Message-ID: <bug-31655-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=31655

            Bug ID: 31655
           Summary: clang can't build glibc with stack protector
           Product: glibc
           Version: 2.40
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: hjl.tools at gmail dot com
                CC: adhemerval.zanella at linaro dot org, drepper.fsp at gmail dot com,
                    skpgkp2 at gmail dot com
  Target Milestone: ---
            Target: x86

On x86, glibc built with stack protector using clang crashed very early:

(gdb) bt
#0 0x00000000005b3327 in bsearch (__key=__key@entry=0x7fffffffe540,
__base=0x6bde70 <intel_02_known>, __nmemb=__nmemb@entry=68,
__size=__size@entry=8,
__compar=__compar@entry=0x5b2400 <intel_02_known_compare>) at
../bits/stdlib-bsearch.h:22
#1 0x00000000005b220a in intel_check_word (name=name@entry=188, value=16711424,
has_level_2=has_level_2@entry=0x7fffffffe587,
no_level_2_or_3=no_level_2_or_3@entry=0x7fffffffe586, cpu_features=)
at ../sysdeps/x86/dl-cacheinfo.h:217
#2 0x00000000005b1904 in handle_intel (name=name@entry=188, cpu_features=)
at ../sysdeps/x86/dl-cacheinfo.h:279
#3 0x00000000005b0606 in dl_init_cacheinfo (cpu_features=)
at ../sysdeps/x86/dl-cacheinfo.h:811
#4 init_cpu_features (cpu_features=) at ../sysdeps/x86/cpu-features.c:1030
#5 __libc_start_main_impl (main=0x4599c0

, argc=13, argv=0x7fffffffe718,
init=, fini=, rtld_fini=0x0, stack_end=0x7fffffffe708)
at ../csu/libc-start.c:269
#6 0x0000000000401201 in _start () at ../sysdeps/x86_64/start.S:115
(gdb)

since the stack-protector canary in TCB hasn't been set up yet.
bits/stdlib-bsearch.h has an __extern_inline bsearch which is protected by

#ifdef __USE_EXTERN_INLINES
# include <bits/stdlib-bsearch.h>
#endif

But __USE_EXTERN_INLINES isn't defined for clang when building glibc on
azanella/clang branch:

/* Decide whether we can define 'extern inline' functions in headers.  */
#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
    && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
    && defined __extern_inline && !(defined __clang__ && defined _LIBC)
# define __USE_EXTERN_INLINES   1
#endif

As the result, clang can't build glibc with stack protector on x86.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2024-04-18 15:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18 15:00 hjl.tools at gmail dot com [this message]
2024-04-18 15:08 ` [Bug libc/31655] " adhemerval.zanella at linaro dot org
2024-04-18 17:43 ` skpgkp1 at gmail dot com
2024-04-18 17:45 ` hjl.tools at gmail dot com
2024-04-18 18:10 ` adhemerval.zanella at linaro dot org
2024-04-18 18:13 ` skpgkp1 at gmail dot com
2024-04-18 19:31 ` adhemerval.zanella at linaro dot org
2024-04-18 19:37 ` hjl.tools at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31655-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).