[PATCH] D67865: [clang-tidy] Finds uses of OSRead* calls on macOS that may mask unexpected behavior due to unaligned reads

Dave MacLachlan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 14:41:21 PDT 2019


dmaclach created this revision.
dmaclach added a reviewer: alexfh.
Herald added subscribers: cfe-commits, kristof.beyls, xazax.hun, mgorny.
Herald added a project: clang.

We ran into a problem in protocol buffers recently when compiling with Xcode 11 that caused crashes on 32 bit ARM architectures due to undefined behavior caused by OSRead* calls in OSByteOrder.h when reading unaligned addresses.

These potential errors can easily be fixed by replacing the OSRead* call with a memcpy and then a OSSwap{Big|Little}ToHostInt{16|32|64}.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D67865

Files:
  clang-tidy/objc/AvoidOSReadCheck.cpp
  clang-tidy/objc/AvoidOSReadCheck.h
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/ObjCTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-avoid-osread.rst
  test/clang-tidy/objc-avoid-osread.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67865.221120.patch
Type: text/x-patch
Size: 10162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190920/1a2cda75/attachment.bin>


More information about the cfe-commits mailing list