This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Fix build failure with _FORTIFY_SOURCE
AbandonedPublic

Authored by tstellar on Dec 2 2020, 4:01 PM.

Details

Summary

When _FORTIFY_SOURCE is defined, the glibc headers define realpath which
clashes with the definition in compiler-rt. In order to fix this for
realpath and also to protect us from future failues, when _FORTIFY_SOURCE
is defined, define our interceptor function with the __interceptor_ prefix.

Diff Detail

Event Timeline

tstellar created this revision.Dec 2 2020, 4:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2020, 4:01 PM
Herald added subscribers: Restricted Project, krytarowski. · View Herald Transcript
tstellar requested review of this revision.Dec 2 2020, 4:01 PM
dvyukov edited reviewers, added: vitalybuka; removed: dvyukov.Dec 3 2020, 1:35 AM
dvyukov added a subscriber: dvyukov.
compiler-rt/lib/interception/interception.h
140

maybe call them `__fortified_interceptor` to make their purpose more explicit?

compiler-rt/lib/interception/interception_linux.h
35

I don't find DECLARED_FUNC as explicit as REAL and WRAP. ALIAS ? EXTERNAL ?

Can you add a test probably in sanitizer_common which reproduces the issue?

Can you add a test probably in sanitizer_common which reproduces the issue?

The build failure is when building compiler-rt itself, and not in the application trying to use compiler-rt. Should I just create a test mini-sanitizer with one interceptor to demonstrate the problem?

Can you add a test probably in sanitizer_common which reproduces the issue?

The build failure is when building compiler-rt itself, and not in the application trying to use compiler-rt. Should I just create a test mini-sanitizer with one interceptor to demonstrate the problem?

How exactly do you call cmake to reproduce this?

I was able to reproduce.

We don't want interceptors depend on set of include files like with DECLARED_FUNC

I guess simple solution is to remove #include <stdlib.h> from dd_interceptors.cpp and
extern "C" void *malloc(size_t size);
extern "C" void free(void *ptr);
or move code which needs stdlib into a separate cpp file

vitalybuka requested changes to this revision.Dec 29 2020, 2:07 PM

I assume it's not needed after D93877

This revision now requires changes to proceed.Dec 29 2020, 2:07 PM
tstellar abandoned this revision.Nov 1 2021, 5:05 PM