Skip to content

PR for llvm/llvm-project#64388 #656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 30, 2023
Merged

PR for llvm/llvm-project#64388 #656

merged 4 commits into from
Aug 30, 2023

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Aug 28, 2023

@MaskRay
Copy link
Member

MaskRay commented Aug 29, 2023

LGTM

MaskRay and others added 4 commits August 29, 2023 04:29
`_MSC_VER>=1800` (Visual Studio 2013) supports atoll/strtoll.
Remove the obsoleted workaround ASAN_INTERCEPT_ATOLL_AND_STRTOLL.

test/asan/TestCases/atoll_strict.c passes but
test/asan/TestCases/strtoll_strict.c doesn't.

(cherry picked from commit 8033231240f223dc7c718d1d27ece2dbcc8057c6)
`strtol("0b1", 0, 0)` can be (pre-C23) 0 or (C23) 1.
`sscanf("0b10", "%i", &x)` is similar. glibc 2.38 introduced
`__isoc23_strtol` and `__isoc23_scanf` family functions for binary
compatibility.

When `_ISOC2X_SOURCE` is defined (implied by `_GNU_SOURCE`) or
`__STDC_VERSION__ > 201710L`, `__GLIBC_USE_ISOC2X` is defined to 1 and
these `__isoc23_*` symbols are used.

Add `__isoc23_` versions for the following interceptors:

* sanitizer_common_interceptors.inc implements strtoimax/strtoumax.
  Remove incorrect FIXME about google/sanitizers#321
* asan_interceptors.cpp implements just strtol and strtoll. The default
  `replace_str` mode checks `nptr` is readable and `endptr` is writable.
  atoi reuses the existing strtol interceptor.
* msan_interceptors.cpp implements strtol family functions and their
  `_l` versions. Tested by lib/msan/tests/msan_test.cpp
* sanitizer_common_interceptors.inc implements scanf family functions.

The strtol family functions are spreaded, which is not great, but the
patch (intended for release/17.x) does not attempt to address the issue.

Add symbols to lib/sanitizer_common/symbolizer/scripts/global_symbols.txt to
support both glibc pre-2.38 and 2.38.

When build bots migrate to glibc 2.38+, we will lose test coverage for
non-isoc23 versions since the existing C++ unittests imply `_GNU_SOURCE`.
Add test/sanitizer_common/TestCases/{strtol.c,scanf.c}.
They catch msan false positive in the absence of the interceptors.

Fix llvm/llvm-project#64388
Fix llvm/llvm-project#64946

Link: https://lists.gnu.org/archive/html/info-gnu/2023-07/msg00010.html
("The GNU C Library version 2.38 is now available")

Reviewed By: #sanitizers, vitalybuka, mgorny

Differential Revision: https://reviews.llvm.org/D158943

(cherry picked from commit ad7e2501000da2494860f06a306dfe8c08cc07c3)
…argets

8033231240f223dc7c718d1d27ece2dbcc8057c6 made this test pass
in MinGW environments, even if it still is failing in MSVC
environments.

(cherry picked from commit 277fc9475fb89c0b80d4237dbc8d698a55203c0d)
SANITIZER_GLIBC is always defined so should be tested with an if not an
ifdef.

Fixes: ad7e2501000d

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D159041

(cherry picked from commit 692344d87357ded619d216b265a9375f4326d8fb)
@tru tru merged commit b6cf21f into release/17.x Aug 30, 2023
@tru tru deleted the llvm-issue64388 branch August 30, 2023 15:00
@nickdesaulniers
Copy link
Member

nickdesaulniers commented Aug 31, 2023

Hi @MaskRay

It looks like this is causing a regression in ninja check-compiler-rt on release/17.x. Can you PTAL? I suspect that -std=c23 wasn't accepted yet by clang in this branch.

Initial report: #566 (comment)

@MaskRay
Copy link
Member

MaskRay commented Aug 31, 2023

requested a cherry-pick on llvm/llvm-project#64388 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compiler-rt: sanitizers do not intercept __isoc23_* functions added in Glibc-2.38
6 participants