Skip to content

Commit bbd3282

Browse files
committed
allow easier debugging for gil issues when assertions are enabled
1 parent 12a6afb commit bbd3282

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ boolean tryAcquireGil() {
11431143
*/
11441144
@TruffleBoundary
11451145
void acquireGil() throws InterruptedException {
1146-
assert !ownsGil() : "trying to acquire the GIL more than once";
1146+
assert !ownsGil() : dumpStackOnAssertionHelper("trying to acquire the GIL more than once");
11471147
try {
11481148
globalInterpreterLock.lockInterruptibly();
11491149
} catch (InterruptedException e) {
@@ -1166,14 +1166,19 @@ void acquireGil() throws InterruptedException {
11661166
}
11671167
}
11681168

1169+
private static final String dumpStackOnAssertionHelper(String msg) {
1170+
Thread.dumpStack();
1171+
return msg;
1172+
}
1173+
11691174
/**
11701175
* Should not be called directly.
11711176
*
11721177
* @see GilNode
11731178
*/
11741179
@TruffleBoundary
11751180
void releaseGil() {
1176-
assert globalInterpreterLock.getHoldCount() == 1 : "trying to release the GIL with invalid hold count " + globalInterpreterLock.getHoldCount();
1181+
assert globalInterpreterLock.getHoldCount() == 1 : dumpStackOnAssertionHelper("trying to release the GIL with invalid hold count " + globalInterpreterLock.getHoldCount());
11771182
globalInterpreterLock.unlock();
11781183
}
11791184

0 commit comments

Comments
 (0)