8144246: adding lots of directives via jcmd may produce OOM crash

Add a limit to the number of directives

Reviewed-by: kvn
This commit is contained in:
Nils Eliasson 2015-12-16 15:38:28 +01:00
parent e699dcb655
commit 8c0ad215bc
9 changed files with 46 additions and 10 deletions

View file

@ -487,6 +487,14 @@ void DirectivesStack::pop_inner() {
DirectivesStack::release(tmp);
}
bool DirectivesStack::check_capacity(int request_size, outputStream* st) {
if ((request_size + _depth) > CompilerDirectivesLimit) {
st->print_cr("Could not add %i more directives. Currently %i/%i directives.", request_size, _depth, CompilerDirectivesLimit);
return false;
}
return true;
}
void DirectivesStack::clear() {
// holding the lock during the whole operation ensuring consistent result
MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);