This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer_common][test] Disable CompactRingBuffer.int64 on Solaris/sparcv9
AbandonedPublic

Authored by ro on Nov 17 2020, 4:42 AM.

Details

Summary

Even after D91615, CompactRingBuffer.int64 continues to FAIL on Solaris/sparcv9: it SEGVs here:

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x00000001001b4598 in __sanitizer::CompactRingBuffer<long>::push (this=0x101420250, t=0) at /vol/llvm/src/llvm-project/local/compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h:136
136	    *next = t;
(gdb) p next
$1 = (long *) 0xffffff7f59a000

The problem is that this address is unmapped:CompactRingBuffer uses the top 8 bits of the address for its own purposes (cf. kNextMask). However, Solaris/sparcv9 uses the full 64-bit address space, so this masking breaks the test, which needs to be disabled.

Diff Detail

Event Timeline

ro created this revision.Nov 17 2020, 4:42 AM
Herald added subscribers: Restricted Project, fedor.sergeev, jyknight. · View Herald TranscriptNov 17 2020, 4:42 AM
ro requested review of this revision.Nov 17 2020, 4:42 AM

Does it mean CompactRingBuffer is broken, or just the test?
Is this ADI? I don't understand why bits 52-56 (and below) are 0xff in your example.
Could you tell me more about the 64-bit address space in solaris/sparcv9?

Would it work to

  • mask off the top bits of "storage" in Init
  • somehow disable tag checking when storing through the truncated pointer?
ro added a comment.Nov 18 2020, 6:58 AM

Does it mean CompactRingBuffer is broken, or just the test?

Hard for me to tell given that this is the only test using it. Besides, hwasan is the only user which isn't supported on SPARC, so I didn't look at the test very hard.

Is this ADI? I don't understand why bits 52-56 (and below) are 0xff in your example.

No, while the machine I use for my tests (a Netra SPARC S7-2) is ADI-capable, it needs to be enabled explicitly.

When I look at the processes' address space with pmap -x, I find (among many others)

[...]
FFFFFFFF7F59A000     16     -     -    - rw-----  [ anon ]

while the faulting address is

mapping	        FFFFFFFF7F59A000
next		  ffffff7f59a000

i.e. 8 bits masked.

Could you tell me more about the 64-bit address space in solaris/sparcv9?

The layout can be seen here. There's a large virtual address hole in the middle, the exact location of which cannot be determined programmatically (yet) and depends on the exact hardware used. This obviously creates problems for a future Solaris/sparcv9 ASan port, too. Solaris/amd64 used to be the same, but they changed the layout during the large-scale rewrite of the VM system in Solaris 11.2.

Would it work to

  • mask off the top bits of "storage" in Init
  • somehow disable tag checking when storing through the truncated pointer?

I can't tell for certain, but at first blush it doesn't look like it would.

Very interesting, thank you for the explanation.
It looks like this can be fixed by applying sign extension to the masked address?

ro added a comment.Nov 19 2020, 2:07 AM

Very interesting, thank you for the explanation.
It looks like this can be fixed by applying sign extension to the masked address?

I guess so, yes. Any guidance on where to apply this much appreciated ;-)

D91827 should do it, but I can't test it on high addresses
It does not update the compiler side, but that one would need to be sparc-specific anyway to avoid adding an extra instruction on aarch64

vitalybuka resigned from this revision.Feb 17 2021, 1:46 PM
ro abandoned this revision.Feb 4 2022, 4:03 AM

Superceded by the combination of D91615 and D91827.