Skip to content

Conversation

@gpshead
Copy link
Member

@gpsheadgpshead commented Nov 12, 2018

Adds a convenient configure flags for --with-memory-sanitizer and --with-undefined-behavior-sanitizer.

Fixes up the CPython code base to be mostly memory sanitizer clean. These changes come from patches we've been using at Google.

https://bugs.python.org/issue35214

This makes it easier to enable clang's memory and undefined behavior sanitizers on a build without manually setting CFLAGS and LDFLAGS. This also encodes the detail that address sanitizer and memory sanitizer should disable pymalloc.
This allows code to easily take conditional action when in an msan build. Usually used for telling msan things it can't otherwise figure out such as syscall, asm behavior, or about libc functions it isn't yet aware of.
These teach MSan about syscalls, asm behavior, or otherwise address clang memory sanitizer flagged issues.
@gpshead
Copy link
MemberAuthor

A news entry will come. I put the PR up to see what the CI thinks of this on various platforms.

I run the current undefined behavior sanitizer buildbot and am setting up a memory sanitizer buildbot. This is a prerequisite for that to be useful.

@gpsheadgpshead merged commit 1584a00 into python:masterNov 12, 2018
@miss-islington
Copy link
Contributor

Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @gpshead, I could not cleanly backport this to 3.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 1584a0081500d35dc93ff88e5836df35faf3e3e2 3.7

@miss-islington
Copy link
Contributor

Sorry, @gpshead, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 1584a0081500d35dc93ff88e5836df35faf3e3e2 3.6

gpshead added a commit to gpshead/cpython that referenced this pull request Nov 12, 2018
Adds configure flags for msan and ubsan builds to make it easier to enable. These also encode the detail that address sanitizer and memory sanitizer should disable pymalloc. Define MEMORY_SANITIZER when appropriate at build time and adds workarounds to existing code to mark things as initialized where the sanitizer is otherwise unable to determine that. This lets our build succeed under the memory sanitizer. not all tests pass without sanitizer failures yet but we're in pretty good shape after this. (cherry picked from commit 1584a00)
gpshead added a commit to gpshead/cpython that referenced this pull request Nov 12, 2018
Adds configure flags for msan and ubsan builds to make it easier to enable. These also encode the detail that address sanitizer and memory sanitizer should disable pymalloc. Define MEMORY_SANITIZER when appropriate at build time and adds workarounds to existing code to mark things as initialized where the sanitizer is otherwise unable to determine that. This lets our build succeed under the memory sanitizer. not all tests pass without sanitizer failures yet but we're in pretty good shape after this.. (cherry picked from commit 1584a00) Co-authored-by: Gregory P. Smith <greg@krypto.org>
@bedevere-bot
Copy link

GH-10492 is a backport of this pull request to the 3.7 branch.

gpshead added a commit that referenced this pull request Nov 12, 2018
…-10492) Adds configure flags for msan and ubsan builds to make it easier to enable. These also encode the detail that address sanitizer and memory sanitizer should disable pymalloc. Define MEMORY_SANITIZER when appropriate at build time and adds workarounds to existing code to mark things as initialized where the sanitizer is otherwise unable to determine that. This lets our build succeed under the memory sanitizer. not all tests pass without sanitizer failures yet but we're in pretty good shape after this. (cherry picked from commit 1584a00) Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
gpshead added a commit to gpshead/cpython that referenced this pull request Nov 12, 2018
Adds configure flags for msan and ubsan builds to make it easier to enable. These also encode the detail that address sanitizer and memory sanitizer should disable pymalloc. Define MEMORY_SANITIZER when appropriate at build time and adds workarounds to existing code to mark things as initialized where the sanitizer is otherwise unable to determine that. This lets our build succeed under the memory sanitizer. not all tests pass without sanitizer failures yet but we're in pretty good shape after this. (cherry picked from commit 1584a00) Contributed by Gregory P. Smith [Google LLC]
gpshead added a commit to gpshead/cpython that referenced this pull request Nov 12, 2018
Adds configure flags for msan and ubsan builds to make it easier to enable. These also encode the detail that address sanitizer and memory sanitizer should disable pymalloc. Define MEMORY_SANITIZER when appropriate at build time and adds workarounds to existing code to mark things as initialized where the sanitizer is otherwise unable to determine that. This lets our build succeed under the memory sanitizer. not all tests pass without sanitizer failures yet but we're in pretty good shape after this.. (cherry picked from commit 1584a00) Co-authored-by: Gregory P. Smith <greg@krypto.org>
@bedevere-bot
Copy link

GH-10493 is a backport of this pull request to the 3.6 branch.

@gpsheadgpshead deleted the initial-msan-fixes branch November 12, 2018 22:11
gpshead added a commit that referenced this pull request Nov 13, 2018
…-10493) Adds configure flags for msan and ubsan builds to make it easier to enable. These also encode the detail that address sanitizer and memory sanitizer should disable pymalloc. Define MEMORY_SANITIZER when appropriate at build time and adds workarounds to existing code to mark things as initialized where the sanitizer is otherwise unable to determine that. This lets our build succeed under the memory sanitizer. not all tests pass without sanitizer failures yet but we're in pretty good shape after this. (cherry picked from commit 1584a00) Contributed by Gregory P. Smith [Google LLC] Also includes a whitespace fix from make patchcheck to _posixsubprocess.c - unrelated to the main change that makes the CI happy so I'm just doing it now rather than creating a separate PR.
Sign up for freeto 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.

4 participants

@gpshead@miss-islington@bedevere-bot@the-knights-who-say-ni