Skip to content

Commit

Permalink
[GR-35186] Verify that early-parsed isolate arguments don't change la…
Browse files Browse the repository at this point in the history
…ter on.

PullRequest: graal/15737
  • Loading branch information
christianhaeubl committed Oct 25, 2023
2 parents 12aaa48 + 8ed7de1 commit 9cfc178
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,21 @@ public void persistOptions(CLongPointer parsedArgs) {

public void verifyOptionValues() {
for (int i = 0; i < OPTION_COUNT; i++) {
validate(OPTIONS[i], getOptionValue(i));
RuntimeOptionKey<?> option = OPTIONS[i];
if (shouldValidate(option)) {
validate(option, getOptionValue(i));
}
}
}

private static boolean shouldValidate(RuntimeOptionKey<?> option) {
if (SubstrateOptions.UseSerialGC.getValue()) {
/* The serial GC supports changing the heap size at run-time to some degree. */
return option != SubstrateGCOptions.MinHeapSize && option != SubstrateGCOptions.MaxHeapSize && option != SubstrateGCOptions.MaxNewSize;
}
return true;
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static boolean getBooleanOptionValue(int index) {
return PARSED_OPTION_VALUES[index] == 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.graalvm.nativeimage.VMRuntime;
import org.graalvm.nativeimage.impl.VMRuntimeSupport;

import com.oracle.svm.core.IsolateArgumentParser;
import com.oracle.svm.core.Isolates;
import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
import com.oracle.svm.core.heap.HeapSizeVerifier;
Expand Down Expand Up @@ -92,7 +93,7 @@ public boolean isUninitialized() {
public void initialize() {
boolean shouldInitialize = initializationState.compareAndSet(InitializationState.Uninitialized, InitializationState.InProgress);
if (shouldInitialize) {
// GR-35186: we should verify that none of the early parsed isolate arguments changed.
IsolateArgumentParser.singleton().verifyOptionValues();
HeapSizeVerifier.verifyHeapOptions();

executeHooks(startupHooks);
Expand Down

0 comments on commit 9cfc178

Please sign in to comment.