This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizer] Fix MIPS64 kernel_stat_to_stat()
ClosedPublic

Authored by mstojanovic on Jul 20 2017, 3:02 AM.

Details

Summary

This patch takles with two issues:

  1. Output stat st_[a|m|c]time fields were holding wrong values. st_[a|m|c]time fields should have contained value of seconds and instead we were filling them with st_[a|m|c]time_nsec fields which hold nanoseconds.
  1. Build fails for MIPS64 if SANITIZER_ANDROID. Recently <sys/stat.h> from bionic introduced st_[a|m|c]time_nsec macros for compatibility with old NDKs and those clashed with the field names of the <asm/stat.h> kernel_stat structure.

To fix both issues and make sure sanitizer builds on all platforms
we must un-define all compatibility macros and access the fields
directly when copying the 'time' fields.

Patch submitted by: Miodrag Dinic <miodrag.dinic@imgtec.com>

Diff Detail

Event Timeline

mstojanovic created this revision.Jul 20 2017, 3:02 AM
sdardis added inline comments.Aug 11 2017, 3:00 AM
lib/sanitizer_common/sanitizer_linux.cc
251–252

What environments define these macros for 'struct stat'?

miodrag.dinic added inline comments.
lib/sanitizer_common/sanitizer_linux.cc
251–252

Hi Simon,

sorry for a late response.

These should be coming from glibc:
__USE_XOPEN2K8 : https://github.com/lattera/glibc/blob/master/include/features.h#L261

__USE_MISC : https://github.com/lattera/glibc/blob/master/include/features.h#L305

These guards were introduced a while ago in mips/bits/stat.h :
https://sourceware.org/ml/glibc-cvs/2009-q4/msg00168.html

This is the current state in glibc:
https://github.com/lattera/glibc/blob/master/sysdeps/unix/sysv/linux/bits/stat.h

sdardis edited edge metadata.Aug 24 2017, 4:19 AM
sdardis added a subscriber: llvm-commits.

llvm-commits should have been added to the subscribers list.

sdardis accepted this revision.Sep 15 2017, 3:04 AM

LGTM.

This revision is now accepted and ready to land.Sep 15 2017, 3:04 AM
This revision was automatically updated to reflect the committed changes.