Mercurial > hg > truffle
comparison src/share/vm/oops/klass.cpp @ 17883:9428a0b94204
8028497: SIGSEGV at ClassLoaderData::oops_do(OopClosure*, KlassClosure*, bool)
Summary: Keep class in CLD::_klasses list and mirror created for CDS classes if OOM during restore_shareable_info(). This keeps pointers consistent for CMS.
Reviewed-by: ehelin, stefank, jmasa, iklam
author | coleenp |
---|---|
date | Tue, 15 Apr 2014 17:02:20 -0400 |
parents | 85318d1fe8fe |
children | 386dd1c71858 |
comparison
equal
deleted
inserted
replaced
17876:9c3dc501b5eb | 17883:9428a0b94204 |
---|---|
481 void Klass::oops_do(OopClosure* cl) { | 481 void Klass::oops_do(OopClosure* cl) { |
482 cl->do_oop(&_java_mirror); | 482 cl->do_oop(&_java_mirror); |
483 } | 483 } |
484 | 484 |
485 void Klass::remove_unshareable_info() { | 485 void Klass::remove_unshareable_info() { |
486 if (!DumpSharedSpaces) { | 486 assert (DumpSharedSpaces, "only called for DumpSharedSpaces"); |
487 // Clean up after OOM during class loading | 487 |
488 if (class_loader_data() != NULL) { | |
489 class_loader_data()->remove_class(this); | |
490 } | |
491 } | |
492 set_subklass(NULL); | 488 set_subklass(NULL); |
493 set_next_sibling(NULL); | 489 set_next_sibling(NULL); |
494 // Clear the java mirror | 490 // Clear the java mirror |
495 set_java_mirror(NULL); | 491 set_java_mirror(NULL); |
496 set_next_link(NULL); | 492 set_next_link(NULL); |
498 // Null out class_loader_data because we don't share that yet. | 494 // Null out class_loader_data because we don't share that yet. |
499 set_class_loader_data(NULL); | 495 set_class_loader_data(NULL); |
500 } | 496 } |
501 | 497 |
502 void Klass::restore_unshareable_info(TRAPS) { | 498 void Klass::restore_unshareable_info(TRAPS) { |
503 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); | 499 // If an exception happened during CDS restore, some of these fields may already be |
504 // Restore class_loader_data to the null class loader data | 500 // set. We leave the class on the CLD list, even if incomplete so that we don't |
505 set_class_loader_data(loader_data); | 501 // modify the CLD list outside a safepoint. |
506 | 502 if (class_loader_data() == NULL) { |
507 // Add to null class loader list first before creating the mirror | 503 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); |
508 // (same order as class file parsing) | 504 // Restore class_loader_data to the null class loader data |
509 loader_data->add_class(this); | 505 set_class_loader_data(loader_data); |
506 | |
507 // Add to null class loader list first before creating the mirror | |
508 // (same order as class file parsing) | |
509 loader_data->add_class(this); | |
510 } | |
510 | 511 |
511 // Recreate the class mirror. The protection_domain is always null for | 512 // Recreate the class mirror. The protection_domain is always null for |
512 // boot loader, for now. | 513 // boot loader, for now. |
513 java_lang_Class::create_mirror(this, Handle(NULL), CHECK); | 514 // Only recreate it if not present. A previous attempt to restore may have |
515 // gotten an OOM later but keep the mirror if it was created. | |
516 if (java_mirror() == NULL) { | |
517 java_lang_Class::create_mirror(this, Handle(NULL), CHECK); | |
518 } | |
514 } | 519 } |
515 | 520 |
516 Klass* Klass::array_klass_or_null(int rank) { | 521 Klass* Klass::array_klass_or_null(int rank) { |
517 EXCEPTION_MARK; | 522 EXCEPTION_MARK; |
518 // No exception can be thrown by array_klass_impl when called with or_null == true. | 523 // No exception can be thrown by array_klass_impl when called with or_null == true. |