comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 1389:5dbd9300cf9c

6943926: G1: Integer overflow during heap region verification Summary: The expression that calculates the live bytes for a heap region can overflow for a suitably large humongous region/object. Cache the object size in a suitably sized local variable so that the expression is converted to a wider type. Reviewed-by: tonyp, jmasa, iveresov, apetrusenko
author johnc
date Thu, 15 Apr 2010 15:52:55 -0700
parents 7666957bc44d
children f9ec1e4bbb44
comparison
equal deleted inserted replaced
1388:7666957bc44d 1389:5dbd9300cf9c
2192 void do_object(oop o) { 2192 void do_object(oop o) {
2193 VerifyLivenessOopClosure isLive(_g1h); 2193 VerifyLivenessOopClosure isLive(_g1h);
2194 assert(o != NULL, "Huh?"); 2194 assert(o != NULL, "Huh?");
2195 if (!_g1h->is_obj_dead_cond(o, _use_prev_marking)) { 2195 if (!_g1h->is_obj_dead_cond(o, _use_prev_marking)) {
2196 o->oop_iterate(&isLive); 2196 o->oop_iterate(&isLive);
2197 if (!_hr->obj_allocated_since_prev_marking(o)) 2197 if (!_hr->obj_allocated_since_prev_marking(o)) {
2198 _live_bytes += (o->size() * HeapWordSize); 2198 size_t obj_size = o->size(); // Make sure we don't overflow
2199 _live_bytes += (obj_size * HeapWordSize);
2200 }
2199 } 2201 }
2200 } 2202 }
2201 size_t live_bytes() { return _live_bytes; } 2203 size_t live_bytes() { return _live_bytes; }
2202 }; 2204 };
2203 2205