Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Issue 1510683002: Add sk_careful_memcpy to catch undefined behavior in memcpy. (Closed)

Created:
5 years ago by mtklein_C
Modified:
5 years ago
Reviewers:
reed1, mtklein, tomhudson
CC:
borenet, reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Add sk_careful_memcpy to catch undefined behavior in memcpy. It's undefined behavior to pass null as src or dst to memcpy, even if len is 0. This currently triggers -fsanitize=attribute-nonnull warnings, but also can lead to very unexpected code generation with GCC. sk_careful_memcpy() checks len first before calling memcpy(), which prevents that weird undefined situation. This allows me to mark all sanitizers as no-recover, i.e. make-the-bots-red fatal. CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot BUG=skia:4641 NOTREECHECKS=true Committed: https://skia.googlesource.com/skia/+/cc881dafcbd00e8a811c47c14b472acdba5dd6c6

Patch Set 1 #

Patch Set 2 : memcpy(...,null,0) is not technically legal... #

Patch Set 3 : fix ub in MathBench #

Patch Set 4 : guard memcpys in SkPathRef::copy #

Patch Set 5 : another #

Patch Set 6 : disable for sfntly? #

Patch Set 7 : two more #

Total comments: 2

Patch Set 8 : sk_careful_memcpy #

Patch Set 9 : if(len) #

Patch Set 10 : comments #

Patch Set 11 : rebase #

Total comments: 2

Patch Set 12 : rebase #

Patch Set 13 : reed #

Unified diffs Side-by-side diffs Delta from patch set Stats (+30 lines, -6 lines) Patch
M gyp/common_conditions.gypi View 1 chunk +1 line, -0 lines 0 comments Download
M include/core/SkTArray.h View 1 2 3 4 5 6 7 1 chunk +2 lines, -2 lines 0 comments Download
M include/core/SkTDArray.h View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M include/core/SkTypes.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +22 lines, -0 lines 0 comments Download
M src/core/SkPathRef.cpp View 1 2 3 4 5 6 7 2 chunks +4 lines, -3 lines 0 comments Download

Messages

Total messages: 47 (28 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1510683002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1510683002/20001
5 years ago (2015-12-07 22:22:38 UTC) #3
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot on client.skia (JOB_FAILED, http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot/builds/55)
5 years ago (2015-12-07 22:34:54 UTC) #8
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1510683002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1510683002/60001
5 years ago (2015-12-07 23:07:28 UTC) #13
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot on client.skia (JOB_FAILED, http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot/builds/57)
5 years ago (2015-12-07 23:22:03 UTC) #16
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1510683002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1510683002/120001
5 years ago (2015-12-08 16:07:02 UTC) #18
tomhudson
https://codereview.chromium.org/1510683002/diff/120001/include/core/SkTArray.h File include/core/SkTArray.h (right): https://codereview.chromium.org/1510683002/diff/120001/include/core/SkTArray.h#newcode31 include/core/SkTArray.h:31: inline void copyAndDelete(SkTArray<T, true>* self, char* newMemArray) { Oddly, ...
5 years ago (2015-12-08 16:31:40 UTC) #20
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years ago (2015-12-08 16:36:12 UTC) #22
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1510683002/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1510683002/140001
5 years ago (2015-12-08 16:56:52 UTC) #24
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1510683002/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1510683002/160001
5 years ago (2015-12-08 17:02:57 UTC) #27
mtklein_C
Have a look now?
5 years ago (2015-12-08 17:22:31 UTC) #29
reed1
Might rename the CL as Add sk_careful_memcpy to catch ... https://codereview.chromium.org/1510683002/diff/200001/include/core/SkTypes.h File include/core/SkTypes.h (right): https://codereview.chromium.org/1510683002/diff/200001/include/core/SkTypes.h#newcode28 ...
5 years ago (2015-12-08 18:25:09 UTC) #30
mtklein_C
ready for another look
5 years ago (2015-12-08 19:01:36 UTC) #34
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1510683002/240001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1510683002/240001
5 years ago (2015-12-08 19:02:40 UTC) #35
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: Build-Ubuntu-GCC-Mips-Debug-Android-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Ubuntu-GCC-Mips-Debug-Android-Trybot/builds/3921)
5 years ago (2015-12-08 19:07:18 UTC) #37
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1510683002/240001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1510683002/240001
5 years ago (2015-12-08 19:24:42 UTC) #39
mtklein
+CC eric
5 years ago (2015-12-08 19:31:03 UTC) #40
reed1
lgtm
5 years ago (2015-12-08 19:47:27 UTC) #41
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1510683002/240001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1510683002/240001
5 years ago (2015-12-08 19:51:11 UTC) #45
commit-bot: I haz the power
5 years ago (2015-12-08 19:55:27 UTC) #47
Message was sent while issue was closed.
Committed patchset #13 (id:240001) as
https://skia.googlesource.com/skia/+/cc881dafcbd00e8a811c47c14b472acdba5dd6c6

Powered by Google App Engine
This is Rietveld 408576698