This is an archive of the discontinued LLVM Phabricator instance.

scudo: Don't define mallinfo2 on Android.
ClosedPublic

Authored by pcc on Mar 17 2023, 12:19 PM.

Details

Summary

On Android, mallinfo2 is an alias of mallinfo, which results
in errors if we try to define both.

Diff Detail

Event Timeline

pcc created this revision.Mar 17 2023, 12:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 12:19 PM
pcc requested review of this revision.Mar 17 2023, 12:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 12:19 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

Just curious, why we didn't have issue before? I thought it may be fine because it's defined as WEAK ?!

pcc added a comment.Mar 17 2023, 12:59 PM

How do you usually build Scudo? When I run the unit tests I cross compile it for Android using llvm's gn build system. If you're building it as part of the Android platform, SCUDO_PREFIX will be defined to add a prefix of scudo_, so the alias in malloc.h wouldn't affect the definitions.

Is it worth examining how we do this on Android? For example, should we remove the mallinfo2 alias for mallinfo, so that we don't have to make this change?

pcc added a comment.Mar 17 2023, 2:29 PM

Is it worth examining how we do this on Android? For example, should we remove the mallinfo2 alias for mallinfo, so that we don't have to make this change?

If you removed the mallinfo2 alias and added a definition of mallinfo2 to Bionic, then it would mean that newer NDK versions will increase the API level requirement for mallinfo2 from baseline to whichever version of Android you added it in. So from an NDK user perspective, that doesn't seem like a good idea.

cferris accepted this revision.Mar 17 2023, 2:41 PM

Good point.

LGTM then.

This revision is now accepted and ready to land.Mar 17 2023, 2:41 PM
This revision was automatically updated to reflect the committed changes.

How do you usually build Scudo? When I run the unit tests I cross compile it for Android using llvm's gn build system. If you're building it as part of the Android platform, SCUDO_PREFIX will be defined to add a prefix of scudo_, so the alias in malloc.h wouldn't affect the definitions.

I see, thanks!

That prefix is only added when #if SCUDO_ANDROID && _BIONIC (code), do you think we need to do #if !SCUDO_ANDROID || !_BIONIC?

pcc added a comment.Mar 17 2023, 2:59 PM

How do you usually build Scudo? When I run the unit tests I cross compile it for Android using llvm's gn build system. If you're building it as part of the Android platform, SCUDO_PREFIX will be defined to add a prefix of scudo_, so the alias in malloc.h wouldn't affect the definitions.

I see, thanks!

That prefix is only added when #if SCUDO_ANDROID && _BIONIC (code), do you think we need to do #if !SCUDO_ANDROID || !_BIONIC?

That shouldn't be necessary, we aren't using scudo_mallinfo2 on the platform side.