Skip to content

Commit b8c5d2c

Browse files
committed
[GR-44443] Do not crash when logging and no source is available to print
1 parent 57811f6 commit b8c5d2c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SequenceFromStackNode.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -266,12 +266,20 @@ public void reportUpdatedCapacity(BasicSequenceStorage newStore) {
266266
if (PythonContext.get(this).getOption(PythonOptions.OverallocateLiteralLists)) {
267267
if (newStore.getCapacity() > initialCapacity.estimate()) {
268268
initialCapacity.updateFrom(newStore.getCapacity());
269-
LOGGER.finest(() -> String.format("Updating list size estimate at %s. Observed capacity: %d, new estimate: %d", getSourceSection(), newStore.getCapacity(),
270-
initialCapacity.estimate()));
269+
LOGGER.finest(() -> {
270+
SourceSection encapsulatingSourceSection = getEncapsulatingSourceSection();
271+
String sourceSection = encapsulatingSourceSection == null ? "<unavailable source>" : encapsulatingSourceSection.toString();
272+
return String.format("Updating list size estimate at %s. Observed capacity: %d, new estimate: %d", sourceSection, newStore.getCapacity(),
273+
initialCapacity.estimate());
274+
});
271275
}
272276
if (newStore.getElementType().generalizesFrom(type)) {
273277
type = newStore.getElementType();
274-
LOGGER.finest(() -> String.format("Updating list type estimate at %s. New type: %s", getSourceSection(), type.name()));
278+
LOGGER.finest(() -> {
279+
SourceSection encapsulatingSourceSection = getEncapsulatingSourceSection();
280+
String sourceSection = encapsulatingSourceSection == null ? "<unavailable source>" : encapsulatingSourceSection.toString();
281+
return String.format("Updating list type estimate at %s. New type: %s", sourceSection, type.name());
282+
});
275283
}
276284
}
277285
}

0 commit comments

Comments
 (0)