RFR(S): 8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"

Aleksey Shipilev shade at redhat.com
Thu Feb 28 18:26:51 UTC 2019


On 2/28/19 7:21 PM, Thomas Stüfe wrote:
> On Thu, Feb 28, 2019 at 4:59 PM Aleksey Shipilev <shade at redhat.com <mailto:shade at redhat.com>> wrote:
>     Do we really need to change stack alloc to malloc now, though? For any char*, either the char*
>     itself, or (char*) + 1 would be misaligned for any unit size greater than 1.
> 
> Yeah.. thats maybe me being a bit anal. I like having a confirmed aligned case first.
> 
> Unless it really irks you, lets keep it that way. We all spent way too much time on this thing, and
> while it is a really fascinating topic... :)

Yeah, no reason to sink more time into it. Let's move on!

>     > Note that the reason is_readable_pointer() did not catch the SIGBUS was that is_readable_pointer()
>     > does a SafeFetch32 on the address; so, it just requires 32bit alignment. In the crash case, we had
>     > 32bit aligned pointer and tried to load a 64bit valute (unitsize=8).
> 
>     Dang. That's a problem for is_readable_pointer, is it not? It should be doing native-width access?
> 
> I think is_readable_pointer makes no promises about the alignment, just that if you access that
> location it you wont access unmapped memory. 
> 
> Otherwise, what would be the right way? is_readable_pointer() cannot know what I plan to do with the
> pointer. I might plan to load a single byte from it.

Right. The responsibility of proper alignment is on caller anyway, and print_hex_dump now does it
properly.

-Aleksey



More information about the hotspot-dev mailing list