File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
Android/testbed/app/src/main/python Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 5
5
import sys
6
6
7
7
# Some tests use SIGUSR1, but that's blocked by default in an Android app in
8
- # order to make it available to `sigwait` in the "Signal Catcher" thread. That
9
- # thread's functionality is only relevant to the JVM ("forcing GC (no HPROF) and
10
- # profile save"), so disabling it should not weaken the tests.
8
+ # order to make it available to `sigwait` in the Signal Catcher thread. That
9
+ # thread's functionality is only useful for debugging the JVM, so disabling it
10
+ # should not weaken the tests.
11
+ #
12
+ # Simply unblocking SIGUSR1 is enough to fix most tests that use it. But in
13
+ # tests that generate multiple different signals in quick succession, it's
14
+ # possible for SIGUSR1 to arrive while the main thread is busy running the
15
+ # C-level handler for a different signal, in which case the SIGUSR1 may be sent
16
+ # to the Signal Catcher thread instead. When this happens, there will be a log
17
+ # message containing the text "reacting to signal".
18
+ #
19
+ # In such cases, the tests may need to be changed. Possible workarounds include:
20
+ # * Use a signal other than SIGUSR1 (e.g. test_stress_delivery_simultaneous in
21
+ # test_signal.py).
22
+ # * Send the signal to a specific thread rather than the whole process (e.g.
23
+ # test_signals in test_threadsignals.py.
11
24
signal .pthread_sigmask (signal .SIG_UNBLOCK , [signal .SIGUSR1 ])
12
25
13
26
sys .argv [1 :] = shlex .split (os .environ ["PYTHON_ARGS" ])
Original file line number Diff line number Diff line change @@ -1325,15 +1325,18 @@ def test_stress_delivery_simultaneous(self):
1325
1325
def handler (signum , frame ):
1326
1326
sigs .append (signum )
1327
1327
1328
- self .setsig (signal .SIGUSR1 , handler )
1328
+ # On Android, SIGUSR1 is unreliable when used in close proximity to
1329
+ # another signal – see Android/testbed/app/src/main/python/main.py.
1330
+ # So we use a different signal.
1331
+ self .setsig (signal .SIGUSR2 , handler )
1329
1332
self .setsig (signal .SIGALRM , handler ) # for ITIMER_REAL
1330
1333
1331
1334
expected_sigs = 0
1332
1335
while expected_sigs < N :
1333
1336
# Hopefully the SIGALRM will be received somewhere during
1334
- # initial processing of SIGUSR1 .
1337
+ # initial processing of SIGUSR2 .
1335
1338
signal .setitimer (signal .ITIMER_REAL , 1e-6 + random .random () * 1e-5 )
1336
- os .kill (os .getpid (), signal .SIGUSR1 )
1339
+ os .kill (os .getpid (), signal .SIGUSR2 )
1337
1340
1338
1341
expected_sigs += 2
1339
1342
# Wait for handlers to run to avoid signal coalescing
You can’t perform that action at this time.
0 commit comments