-
Enhancement
-
Resolution: Fixed
-
P4
-
11, 17, 20, 21
-
b23
(Found this during Lilliput review)
Current CollectedHeap::is_oop is weird:
```
bool CollectedHeap::is_oop(oop object) const {
...
if (is_in(object->klass_raw())) { // <--- if klass is in the Java heap, it is not an oop?!
return false;
}
...
}
```
The history shows it goes all the way back toJDK-6964458, which rewrote the previous checking code to:
```
@@ -589,21 +609,7 @@ inline bool oopDesc::is_oop(bool ignore_mark_word) const {
if (!check_obj_alignment(obj)) return false;
if (!Universe::heap()->is_in_reserved(obj)) return false;
// obj is aligned and accessible in heap
- // try to find metaclass cycle safely without seg faulting on bad input
- // we should reach klassKlassObj by following klass link at most 3 times
- for (int i = 0; i < 3; i++) {
- obj = obj->klass_or_null();
- // klass should be aligned and in permspace
- if (!check_obj_alignment(obj)) return false;
- if (!Universe::heap()->is_in_permanent(obj)) return false;
- }
- if (obj != Universe::klassKlassObj()) {
- // During a dump, the _klassKlassObj moved to a shared space.
- if (DumpSharedSpaces && Universe::klassKlassObj()->is_shared()) {
- return true;
- }
- return false;
- }
+ if (Universe::heap()->is_in_reserved(obj->klass_or_null())) return false;
```
I think the check should be a more direct: assert the klass ptr is in the Metaspace, at very least.
Current CollectedHeap::is_oop is weird:
```
bool CollectedHeap::is_oop(oop object) const {
...
if (is_in(object->klass_raw())) { // <--- if klass is in the Java heap, it is not an oop?!
return false;
}
...
}
```
The history shows it goes all the way back to
```
@@ -589,21 +609,7 @@ inline bool oopDesc::is_oop(bool ignore_mark_word) const {
if (!check_obj_alignment(obj)) return false;
if (!Universe::heap()->is_in_reserved(obj)) return false;
// obj is aligned and accessible in heap
- // try to find metaclass cycle safely without seg faulting on bad input
- // we should reach klassKlassObj by following klass link at most 3 times
- for (int i = 0; i < 3; i++) {
- obj = obj->klass_or_null();
- // klass should be aligned and in permspace
- if (!check_obj_alignment(obj)) return false;
- if (!Universe::heap()->is_in_permanent(obj)) return false;
- }
- if (obj != Universe::klassKlassObj()) {
- // During a dump, the _klassKlassObj moved to a shared space.
- if (DumpSharedSpaces && Universe::klassKlassObj()->is_shared()) {
- return true;
- }
- return false;
- }
+ if (Universe::heap()->is_in_reserved(obj->klass_or_null())) return false;
```
I think the check should be a more direct: assert the klass ptr is in the Metaspace, at very least.