RFR: Check for NULL in is-alive-closures
Roman Kennke
rkennke at redhat.com
Fri Feb 2 12:55:12 UTC 2018
Am 02.02.2018 um 01:06 schrieb Roman Kennke:
> I've run into a SEGV in referenceProcessor, because a referent was
> NULL. This sequence:
>
> verify_referent(obj);
> if (is_alive_non_header()->do_object_b(java_lang_ref_Reference::referent(obj)))
> {
>
> means that if the referent is NULL, it is passed to do_object_b(),
> which assumes it to be not NULL. I have no idea how this hasn't blown
> up before?
>
> I was a bit unsure if we should return true (is-alive) or false
> (is-not-alive) when observing NULL referent. I think it is better to
> say it's alive, because then the Reference object is not put into
> discovered list, but treated as regular oop.
>
> http://cr.openjdk.java.net/~rkennke/fixisalivecl/webrev.00/
>
The situation might arise only with traversal GC, because it can mark
through the Reference object right after it is created, but fields not
yet initialized. In this case, referent is still NULL, but it can
already be visible to the GC. A subsequent putfield to store the
referent will do the right thing (i.e. put the referent in the traversal
work queue, and mark it live). Returning 'is-alive' for the NULL is
still the best we can do I think.
Roman
More information about the shenandoah-dev
mailing list