This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Use consistent checks for XDR
ClosedPublic

Authored by iana on Jul 18 2022, 11:13 PM.

Details

Summary

sanitizer_platform_limits_posix.h defines __sanitizer_XDR if SANITIZER_LINUX && !SANITIZER_ANDROID, but sanitizer_platform_limits_posix.cpp tries to check it if HAVE_RPC_XDR_H. This coincidentally works because macOS has a broken <rpc/xdr.h> which causes HAVE_RPC_XDR_H to be 0, but if <rpc/xdr.h> is fixed then clang fails to compile on macOS. Restore the platform checks so that <rpc/xdr.h> can be fixed on macOS.

Diff Detail

Event Timeline

iana created this revision.Jul 18 2022, 11:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2022, 11:13 PM
iana requested review of this revision.Jul 18 2022, 11:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2022, 11:13 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
iana added a comment.Jul 18 2022, 11:15 PM

The checks were (I think erroneously) removed in D8698

If OSX fixes HAVE_RPC_XDR_H=1 why not to fix mac handling of XDR here instead?

kstoimenov accepted this revision.Jul 20 2022, 3:03 PM
This revision is now accepted and ready to land.Jul 20 2022, 3:03 PM
kstoimenov resigned from this revision.Jul 20 2022, 3:07 PM

Please get approval from vitalybuka.

This revision now requires review to proceed.Jul 20 2022, 3:07 PM
iana added a comment.Jul 20 2022, 3:09 PM

If OSX fixes HAVE_RPC_XDR_H=1 why not to fix mac handling of XDR here instead?

I didn't want to change the behavior on macOS, this part has never been on on that platform.

iana added a comment.Jul 20 2022, 3:12 PM

That would be changing the struct __sanitizer_XDR declaration in sanitizer_platform_limits_posix.h to be HAVE_RPC_XDR_H instead of SANITIZER_LINUX && !SANITIZER_ANDROID. I think right now it doesn't check HAVE_RPC_XDR_H because it's not actually using anything from xdr.h.

Mostly I wasn't totally sure what the intended behavior was, and I'm just trying to fix the build, not add new functionality to non-Linux platforms.

vitalybuka added subscribers: wrotki, yln.

If OSX fixes HAVE_RPC_XDR_H=1 why not to fix mac handling of XDR here instead?

I didn't want to change the behavior on macOS, this part has never been on on that platform.

#if HAVE_RPC_XDR_H && !SANITIZER_APPLE
with TODO to fix for Apple?

@yln @wrotki added few recent Apple committers for opinion

iana added a comment.Jul 20 2022, 8:03 PM

If OSX fixes HAVE_RPC_XDR_H=1 why not to fix mac handling of XDR here instead?

I didn't want to change the behavior on macOS, this part has never been on on that platform.

#if HAVE_RPC_XDR_H && !SANITIZER_APPLE
with TODO to fix for Apple?

@yln @wrotki added few recent Apple committers for opinion

Wouldn't it be best to match the sanitizer_platform_limits_posix.h guard? That's the crux of the bug anyway, the declaration and checks are guarded with totally different macros.

If OSX fixes HAVE_RPC_XDR_H=1 why not to fix mac handling of XDR here instead?

I didn't want to change the behavior on macOS, this part has never been on on that platform.

#if HAVE_RPC_XDR_H && !SANITIZER_APPLE
with TODO to fix for Apple?

@yln @wrotki added few recent Apple committers for opinion

Wouldn't it be best to match the sanitizer_platform_limits_posix.h guard? That's the crux of the bug anyway, the declaration and checks are guarded with totally different macros.

No. This file applies to FREEBSD as well
so it should be HAVE_RPC_XDR_H && ((SANITIZER_LINUX && !SANITIZER_ANDROID) || SANITIZER_FREEBSD)
but on all these platform HAVE_RPC_XDR_H will be set anyway
so (HAVE_RPC_XDR_H && !SANITIZER_APPLE) is just shorter

TODO is not needed as Apple does not intercept XDR

iana updated this revision to Diff 446353.Jul 20 2022, 10:14 PM

Update the platform checks.

iana added a comment.Jul 20 2022, 10:14 PM

If OSX fixes HAVE_RPC_XDR_H=1 why not to fix mac handling of XDR here instead?

I didn't want to change the behavior on macOS, this part has never been on on that platform.

#if HAVE_RPC_XDR_H && !SANITIZER_APPLE
with TODO to fix for Apple?

@yln @wrotki added few recent Apple committers for opinion

Wouldn't it be best to match the sanitizer_platform_limits_posix.h guard? That's the crux of the bug anyway, the declaration and checks are guarded with totally different macros.

No. This file applies to FREEBSD as well
so it should be HAVE_RPC_XDR_H && ((SANITIZER_LINUX && !SANITIZER_ANDROID) || SANITIZER_FREEBSD)
but on all these platform HAVE_RPC_XDR_H will be set anyway
so (HAVE_RPC_XDR_H && !SANITIZER_APPLE) is just shorter

TODO is not needed as Apple does not intercept XDR

Ok, updated, thanks for the help!

so (HAVE_RPC_XDR_H && !SANITIZER_APPLE) is just shorter

So why not a shorter version? Do I miss some benefits of this long expression?

iana added a comment.Jul 20 2022, 10:19 PM

so (HAVE_RPC_XDR_H && !SANITIZER_APPLE) is just shorter

So why not a shorter version? Do I miss some benefits of this long expression?

Because I misread your comment the first time >.>

iana updated this revision to Diff 446354.Jul 20 2022, 10:21 PM

Update the platform checks to be the nicer shorter version.

iana added a comment.Jul 20 2022, 10:21 PM

so (HAVE_RPC_XDR_H && !SANITIZER_APPLE) is just shorter

So why not a shorter version? Do I miss some benefits of this long expression?

Because I misread your comment the first time >.>

Sorry, updated!

vitalybuka accepted this revision.Jul 20 2022, 10:22 PM

() is not requirement
do you have committer access?

This revision is now accepted and ready to land.Jul 20 2022, 10:22 PM
iana added a comment.Jul 20 2022, 10:25 PM

() is not requirement
do you have committer access?

Good point, let me get rid of the parens. I think I have committer access.

iana updated this revision to Diff 446356.Jul 20 2022, 10:25 PM

Get rid of the extra parens

Feel free to land it then. I don't see a point to wait for other feedback. At first I thought it's a different kind of issue.

This revision was landed with ongoing or failed builds.Jul 20 2022, 10:28 PM
This revision was automatically updated to reflect the committed changes.