This is an archive of the discontinued LLVM Phabricator instance.

[RFC][RISCV][sanitizer] Enable AP64 for RISCV64
AcceptedPublic

Authored by kito-cheng on Dec 12 2022, 2:36 AM.

Details

Summary

D92403 has use AP32 by default for RISCV64 and then D126825 has move
this logic into sanitizer_common/sanitizer_platform.h which will effect
both asan and lsan, however asan are using AP64 and lsan using AP32
before D126825, and AP64 should work well for all 64-bit platform (ASan use that
before, so that's kind of evidence), not sure why we choose AP32 for lsan
before.

We have 2 option here: 1) only limited lsan use AP32 for RISCV64, 2) or also
relax that for lsan to using AP64.

Diff Detail

Event Timeline

kito-cheng created this revision.Dec 12 2022, 2:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 12 2022, 2:36 AM
kito-cheng requested review of this revision.Dec 12 2022, 2:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 12 2022, 2:36 AM
Herald added subscribers: Restricted Project, pcwang-thead, eopXD. · View Herald Transcript

The lsan tests fail when SANITIZER_CAN_USE_ALLOCATOR64 is defined as 1, both on rv64 sv39 and sv48 hosts.

@kito-cheng when you uploaded this patch did you run check-lsan and get different results? If so, do you have information about your test system and base LLVM commit?

The lsan tests fail when SANITIZER_CAN_USE_ALLOCATOR64 is defined as 1, both on rv64 sv39 and sv48 hosts.

@kito-cheng when you uploaded this patch did you run check-lsan and get different results? If so, do you have information about your test system and base LLVM commit?

The lsan tests do pass for rv64 sv48 if we apply SANITIZER_CAN_USE_ALLOCATOR64=1 on top of your D139827. But they still don't work for sv39, so unless we want to drop sv39 support, setting SANITIZER_CAN_USE_ALLOCATOR64=1 doesn't seem to be viable just by itself.

MaskRay accepted this revision.Jan 30 2023, 3:24 PM
MaskRay added a subscriber: MaskRay.

The SANITIZER_CAN_USE_ALLOCATOR64 list is about legacy systems and Apple aarch64 which cannot migrate yet.
It seems a good idea to behave like modern 64-bit architectures. If that requires dropping 39-bit Virtual-Memory System, I think we should do that, to not pessimize modern systems which are likely the main users of lsan.

This revision is now accepted and ready to land.Jan 30 2023, 3:24 PM

I am kind of conservative guy to deprecating those support - I will spend more times on figure out how to resolve that.

Cross posting from D139827:

Sorry for not updating for a while, we/SiFive gonna to seeking a ultimate solution to work on each different Sv* system, my exception is we still need dynamic shadow sentinel which is what we did by D139827, but it not work well as @luismarques report, so I would like to defer this patch landing for now, and it become high priority work to SiFive, we've allocated dedicated engineer resources to improve the ASan including the ASan for scalable vector stuff and RVV intrinsic, the both work are targeting end of Q2.