Skip to content

Commit bf43f88

Browse files
committed
[GR-73006][GR-73732][GR-72044][GR-73540] Address some transient CI failures.
PullRequest: graalpython/4307
2 parents 45e72a6 + d657e8c commit bf43f88

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FaulthandlerModuleBuiltins.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2026, 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
@@ -121,7 +121,7 @@ public void postInitialize(Python3Core core) {
121121
}
122122

123123
@TruffleBoundary
124-
private static void dumpTraceback(PythonLanguage language, PrintWriter writer) {
124+
private static synchronized void dumpTraceback(PythonLanguage language, PrintWriter writer) {
125125
writer.println();
126126
writer.println(Thread.currentThread());
127127
if (PythonOptions.isPExceptionWithJavaStacktrace(language)) {
@@ -262,7 +262,9 @@ private static void doDumpLater(Node inliningTarget, PythonModule module, long t
262262
do {
263263
sleepInterruptibly(inliningTarget, timeoutNs);
264264
long timeoutS = timeoutNs / 1_000_000_000;
265-
newRawFdPrintWriter(fd).printf("Timeout (%d:%02d:%02d)!%n", timeoutS / 3600, timeoutS / 60, timeoutS);
265+
PrintWriter timeoutWriter = newRawFdPrintWriter(fd);
266+
timeoutWriter.printf("Timeout (%d:%02d:%02d)!%n", timeoutS / 3600, timeoutS / 60, timeoutS);
267+
timeoutWriter.flush();
266268
try {
267269
DumpTracebackNode.dump(context.getLanguage(), context, fd, fileObj, true);
268270
if (exit) {

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ public void setContextVarsContext(PContextVarsContext contextVarsContext) {
469469
this.contextVarsContext = contextVarsContext;
470470
}
471471

472-
public void dispose(PythonContext context, boolean canRunGuestCode) {
472+
public void dispose(PythonContext context, boolean canRunGuestCode, boolean clearNativeThreadLocalVarPointer) {
473473
// This method may be called twice on the same object.
474474

475475
/*
@@ -497,10 +497,10 @@ public void dispose(PythonContext context, boolean canRunGuestCode) {
497497
* precaution, we just skip this if we cannot run guest code, because it may invoke
498498
* LLVM.
499499
*/
500-
if (nativeThreadLocalVarPointer != null && canRunGuestCode) {
500+
if (nativeThreadLocalVarPointer != null && canRunGuestCode && clearNativeThreadLocalVarPointer) {
501501
CStructAccess.WritePointerNode.writeUncached(nativeThreadLocalVarPointer, 0, context.getNativeNull());
502-
nativeThreadLocalVarPointer = null;
503502
}
503+
nativeThreadLocalVarPointer = null;
504504
}
505505

506506
public Object getTraceFun() {
@@ -2070,8 +2070,9 @@ public void runShutdownHooks() {
20702070
*/
20712071
@TruffleBoundary
20722072
private void disposeThreadStates() {
2073-
for (PythonThreadState ts : threadStateMapping.values()) {
2074-
ts.dispose(this, true);
2073+
Thread currentThread = Thread.currentThread();
2074+
for (Map.Entry<Thread, PythonThreadState> entry : threadStateMapping.entrySet()) {
2075+
entry.getValue().dispose(this, true, entry.getKey() == currentThread);
20752076
}
20762077
threadStateMapping.clear();
20772078
}
@@ -2554,7 +2555,7 @@ public synchronized void disposeThread(Thread thread, boolean canRunGuestCode) {
25542555
}
25552556
ts.shutdown();
25562557
threadStateMapping.remove(thread);
2557-
ts.dispose(this, canRunGuestCode);
2558+
ts.dispose(this, canRunGuestCode, thread == Thread.currentThread());
25582559
releaseSentinelLock(ts.sentinelLock);
25592560
getSharedMultiprocessingData().removeChildContextThread(PThread.getThreadId(thread));
25602561
}

graalpython/lib-python/3/test/conftest.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ partial_splits_individual_tests = true
3333
selector = [
3434
'test_multiprocessing_spawn',
3535
'test_multiprocessing_main_handling',
36+
'test_tarfile',
3637
]
3738

3839

graalpython/lib-python/3/test/test_weakref.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@ def cb(self, ignore):
786786

787787
del alist[:]
788788
gc.collect()
789+
gc_collect() # <- GraalPy change
789790
self.assertEqual(alist, [])
790791

791792
def test_gc_during_ref_creation(self):
@@ -798,6 +799,7 @@ def check_gc_during_creation(self, makeref):
798799
thresholds = gc.get_threshold()
799800
gc.set_threshold(1, 1, 1)
800801
gc.collect()
802+
gc_collect() # <- GraalPy change
801803
class A:
802804
pass
803805

@@ -902,6 +904,7 @@ def test_ordering(self):
902904
# Same when dead.
903905
del x, y
904906
gc.collect()
907+
gc_collect() # <- GraalPy change
905908
for op in ops:
906909
self.assertRaises(TypeError, op, a, b)
907910

@@ -914,6 +917,7 @@ def test_hashing(self):
914917
self.assertEqual(hash(a), hash(42))
915918
del x, y
916919
gc.collect()
920+
gc_collect() # <- GraalPy change
917921
# Dead weakrefs:
918922
# - retain their hash is they were hashed when alive;
919923
# - otherwise, cannot be hashed.
@@ -1192,6 +1196,7 @@ def _ne(a, b):
11921196
_eq(a, ALWAYS_EQ)
11931197
del x, y, z
11941198
gc.collect()
1199+
gc_collect() # <- GraalPy change
11951200
# Dead WeakMethods compare by identity
11961201
refs = a, b, c, d, e, f
11971202
for q in refs:
@@ -1236,9 +1241,11 @@ def check_len_cycles(self, dict_type, cons):
12361241
pass
12371242
del items
12381243
gc.collect()
1244+
gc_collect() # <- GraalPy change
12391245
n1 = len(dct)
12401246
del it
12411247
gc.collect()
1248+
gc_collect() # <- GraalPy change
12421249
n2 = len(dct)
12431250
# one item may be kept alive inside the iterator
12441251
self.assertIn(n1, (0, 1))
@@ -1257,6 +1264,7 @@ def check_len_race(self, dict_type, cons):
12571264
for th in range(1, 100):
12581265
N = 20
12591266
gc.collect(0)
1267+
gc_collect() # <- GraalPy change
12601268
gc.set_threshold(th, th, th)
12611269
items = [RefCycle() for i in range(N)]
12621270
dct = dict_type(cons(o) for o in items)
@@ -1428,6 +1436,7 @@ def check_weak_destroy_while_iterating(self, dict, objects, iter_name):
14281436
# Destroy an object
14291437
del objects[-1]
14301438
gc.collect() # just in case
1439+
gc_collect() # <- GraalPy change
14311440
# We have removed either the first consumed object, or another one
14321441
self.assertIn(len(list(it)), [len(objects), len(objects) - 1])
14331442
del it
@@ -1508,10 +1517,12 @@ def testcontext():
15081517
# Schedule a key/value for removal and recreate it
15091518
v = objects.pop().arg
15101519
gc.collect() # just in case
1520+
gc_collect() # <- GraalPy change
15111521
yield Object(v), v
15121522
finally:
15131523
it = None # should commit all removals
15141524
gc.collect()
1525+
gc_collect() # <- GraalPy change
15151526
self.check_weak_destroy_and_mutate_while_iterating(dict, testcontext)
15161527
# Issue #21173: len() fragile when keys are both implicitly and
15171528
# explicitly removed.
@@ -1535,10 +1546,12 @@ def testcontext():
15351546
# Schedule a key/value for removal and recreate it
15361547
k = objects.pop().arg
15371548
gc.collect() # just in case
1549+
gc_collect() # <- GraalPy change
15381550
yield k, Object(k)
15391551
finally:
15401552
it = None # should commit all removals
15411553
gc.collect()
1554+
gc_collect() # <- GraalPy change
15421555
self.check_weak_destroy_and_mutate_while_iterating(dict, testcontext)
15431556
dict, objects = self.make_weak_valued_dict()
15441557
self.check_weak_del_and_len_while_iterating(dict, testcontext)
@@ -1907,6 +1920,7 @@ def pop_and_collect(lst):
19071920
lst.pop(i)
19081921
if gc_ctr % 10000 == 0:
19091922
gc.collect() # just in case
1923+
gc_collect() # <- GraalPy change
19101924

19111925
self.assertIn(type_, (weakref.WeakKeyDictionary, weakref.WeakValueDictionary))
19121926

0 commit comments

Comments
 (0)