Skip to content

Commit 789e759

Browse files
committed
handle exceptions when reading JAZZER_MAXIMIZE_MAX_COUNTERS
1 parent 13eb44d commit 789e759

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/main/java/com/code_intelligence/jazzer/runtime/CountersTracker.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ public final class CountersTracker {
4848

4949
private static final String ENV_MAX_COUNTERS = "JAZZER_MAXIMIZE_MAX_COUNTERS";
5050

51+
private static final int DEFAULT_MAX_COUNTERS = 1 << 20;
52+
5153
/** Maximum number of counters available (default 1M, configurable via environment variable). */
52-
private static final int MAX_COUNTERS =
53-
System.getenv(ENV_MAX_COUNTERS) != null
54-
? Integer.parseInt(System.getenv(ENV_MAX_COUNTERS))
55-
: 1 << 20;
54+
private static final int MAX_COUNTERS = initMaxCounters();
5655

5756
private static final Unsafe UNSAFE = UnsafeProvider.getUnsafe();
5857

@@ -256,6 +255,18 @@ private static final class CounterRange {
256255
}
257256
}
258257

258+
private static int initMaxCounters() {
259+
String value = System.getenv(ENV_MAX_COUNTERS);
260+
if (value == null || value.isEmpty()) {
261+
return DEFAULT_MAX_COUNTERS;
262+
}
263+
try {
264+
return Integer.parseInt(value.trim());
265+
} catch (NumberFormatException e) {
266+
return DEFAULT_MAX_COUNTERS;
267+
}
268+
}
269+
259270
// Native methods
260271

261272
/**

0 commit comments

Comments
 (0)