Skip to content

clang changed __builtin___stpncpy_chk, breaking glibc fortify users #81603

@fefe17

Description

@fefe17

Here's a small test program:

$ cat > t.c
int main() {
  char buf[100];
  __builtin___stpncpy_chk (buf, "foo", 3,
      __builtin_object_size (buf, 2 > 1));
}
$ gcc -c t.c
$ /usr/bin/clang -c t.c
$ /opt/llvm/bin/clang -c t.c
t.c:5:41: error: too few arguments to function call, expected 5, have 4
    4 |   __builtin___stpncpy_chk (buf, "foo", 3,
      |   ~~~~~~~~~~~~~~~~~~~~~~~
    5 |       __builtin_object_size (buf, 2 > 1));
      |                                         ^

gcc is 13.2.0, /usr/bin/clang is 17.0.6, /opt/llvm/bin/clang is git from Jan 24.

This bug manifests when trying to compile Firefox. Some Rust module includes string.h from glibc with Fortify support enabled, which manifests with this error message:

In file included from /src/firefox/third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb.c:101:
In file included from /src/firefox/obj-x86_64-pc-linux-gnu/dist/system_wrappers/string.h:3:
In file included from /usr/include/string.h:548:
/usr/include/bits/string_fortified.h:105:31: error: too few arguments to function call, expected 5, have 4
  104 |   return __builtin___stpncpy_chk (__dest, __src, __n,
      |          ~~~~~~~~~~~~~~~~~~~~~~~
  105 |                                   __glibc_objsize (__dest));
      |                                                           ^
1 error generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:headersHeaders provided by Clang, e.g. for intrinsicsinvalidResolved as invalid, i.e. not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions