Skip to content

Commit f87099f

Browse files
committed
WUIO
1 parent b402a48 commit f87099f

7 files changed

Lines changed: 599 additions & 12 deletions

File tree

Lib/test/test_external_inspection.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ def new_eager_loop():
162162
["c5", "c4", "c3", "c2"],
163163
"c2_root",
164164
[
165-
[["main"], root_task, []],
166-
[["c1"], "sub_main_1", [[["main"], root_task, []]]],
167-
[["c1"], "sub_main_2", [[["main"], root_task, []]]],
165+
[['_aexit', '__aexit__', "main"], root_task, []],
166+
[["c1"], "sub_main_1", [[['_aexit', '__aexit__', "main"], root_task, []]]],
167+
[["c1"], "sub_main_2", [[['_aexit', '__aexit__', "main"], root_task, []]]],
168168
],
169169
]
170170
self.assertEqual(stack_trace, expected_stack_trace)
@@ -346,7 +346,7 @@ async def main():
346346
stack_trace[2].sort(key=lambda x: x[1])
347347

348348
expected_stack_trace = [
349-
['deep', 'c1', 'run_one_coro'], 'Task-2', [[['main'], 'Task-1', []]]
349+
['deep', 'c1', 'run_one_coro'], 'Task-2', [[['staggered_race', 'main'], 'Task-1', []]]
350350
]
351351
self.assertEqual(stack_trace, expected_stack_trace)
352352

@@ -456,11 +456,13 @@ async def main():
456456
self.assertGreaterEqual(len(entries), 1000)
457457
# the first three tasks stem from the code structure
458458
self.assertIn(('Task-1', []), entries)
459-
self.assertIn(('server task', [[['main'], 'Task-1', []]]), entries)
460-
self.assertIn(('echo client spam', [[['main'], 'Task-1', []]]), entries)
459+
self.assertIn(('server task', [[['_aexit', '__aexit__', 'main'], 'Task-1', []]]), entries)
460+
self.assertIn(('echo client spam', [[['_aexit', '__aexit__', 'main'], 'Task-1', []]]), entries)
461461
# the final task will have some random number, but it should for
462462
# sure be one of the echo client spam horde
463-
self.assertEqual([[['echo_client_spam'], 'echo client spam', [[['main'], 'Task-1', []]]]], entries[-1][1])
463+
self.assertEqual(
464+
[[['_aexit', '__aexit__', 'echo_client_spam'], 'echo client spam', [[['_aexit', '__aexit__', 'main'], 'Task-1', []]]]],
465+
entries[-1][1])
464466
except PermissionError:
465467
self.skipTest(
466468
"Insufficient permissions to read the stack trace")

Modules/_testexternalinspection.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,17 @@ read_char(pid_t pid, uintptr_t address, char *result)
586586
}
587587

588588
static int
589-
read_int(pid_t pid, uintptr_t address, int *result)
589+
read_sized_int(pid_t pid, uintptr_t address, void *result, size_t size)
590590
{
591-
int bytes_read = read_memory(pid, address, sizeof(int), result);
591+
int bytes_read = read_memory(pid, address, size, result);
592592
if (bytes_read < 0) {
593593
return -1;
594594
}
595595
return 0;
596596
}
597597

598+
599+
598600
static int
599601
read_unsigned_long(pid_t pid, uintptr_t address, unsigned long *result)
600602
{
@@ -810,11 +812,13 @@ parse_coro_chain(
810812
}
811813
Py_DECREF(name);
812814

813-
int gi_frame_state;
814-
err = read_int(
815+
int8_t gi_frame_state;
816+
err = read_sized_int(
815817
pid,
816818
coro_address + offsets->gen_object.gi_frame_state,
817-
&gi_frame_state);
819+
&gi_frame_state,
820+
sizeof(int8_t)
821+
);
818822
if (err) {
819823
return -1;
820824
}

basura.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
[
2+
(
3+
843914,
4+
[
5+
("Task-1", []),
6+
(
7+
"timer",
8+
[
9+
[
10+
["blech3", "blech2", "blech"],
11+
"child1_1",
12+
[
13+
[
14+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
15+
"root1",
16+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
17+
]
18+
],
19+
],
20+
[
21+
["plech3", "plech2", "plech"],
22+
"child2_2",
23+
[
24+
[
25+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
26+
"root2",
27+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
28+
]
29+
],
30+
],
31+
[
32+
["plech3", "plech2", "plech"],
33+
"child2_1",
34+
[
35+
[
36+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
37+
"root1",
38+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
39+
]
40+
],
41+
],
42+
[
43+
["blech3", "blech2", "blech"],
44+
"child1_2",
45+
[
46+
[
47+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
48+
"root2",
49+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
50+
]
51+
],
52+
],
53+
],
54+
),
55+
("root1", [[["_aexit", "__aexit__", "main"], "Task-1", []]]),
56+
("root2", [[["_aexit", "__aexit__", "main"], "Task-1", []]]),
57+
(
58+
"child1_1",
59+
[
60+
[
61+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
62+
"root1",
63+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
64+
]
65+
],
66+
),
67+
(
68+
"child2_1",
69+
[
70+
[
71+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
72+
"root1",
73+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
74+
]
75+
],
76+
),
77+
(
78+
"child1_2",
79+
[
80+
[
81+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
82+
"root2",
83+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
84+
]
85+
],
86+
),
87+
(
88+
"child2_2",
89+
[
90+
[
91+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
92+
"root2",
93+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
94+
]
95+
],
96+
),
97+
],
98+
),
99+
(0, []),
100+
]

bloch.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import asyncio
2+
3+
async def foo():
4+
await asyncio.sleep(10)
5+
6+
async def blech(x):
7+
await blech2(x)
8+
9+
async def blech2(x):
10+
await blech3(x)
11+
12+
async def blech3(x):
13+
await x
14+
15+
async def plech(x):
16+
await plech2(x)
17+
18+
async def plech2(x):
19+
await plech3(x)
20+
21+
async def plech3(x):
22+
await x
23+
24+
async def bloch(x, name):
25+
await blocho_caller(x, name)
26+
27+
async def blocho_caller(x, name):
28+
async with asyncio.TaskGroup() as tg:
29+
tg.create_task(blech(x), name=f'child1_{name}')
30+
tg.create_task(plech(x), name=f'child2_{name}')
31+
32+
async def main():
33+
t = asyncio.Task(foo(), name='timer')
34+
async with asyncio.TaskGroup() as tg:
35+
tg.create_task(bloch(t, "1"), name="root1")
36+
tg.create_task(bloch(t, "2"), name="root2")
37+
38+
asyncio.run(main())

deps.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
dependency_data = [
2+
(
3+
843914,
4+
[
5+
("Task-1", []),
6+
(
7+
"timer",
8+
[
9+
[
10+
["blech3", "blech2", "blech"],
11+
"child1_1",
12+
[
13+
[
14+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
15+
"root1",
16+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
17+
]
18+
],
19+
],
20+
[
21+
["plech3", "plech2", "plech"],
22+
"child2_2",
23+
[
24+
[
25+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
26+
"root2",
27+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
28+
]
29+
],
30+
],
31+
[
32+
["plech3", "plech2", "plech"],
33+
"child2_1",
34+
[
35+
[
36+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
37+
"root1",
38+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
39+
]
40+
],
41+
],
42+
[
43+
["blech3", "blech2", "blech"],
44+
"child1_2",
45+
[
46+
[
47+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
48+
"root2",
49+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
50+
]
51+
],
52+
],
53+
],
54+
),
55+
("root1", [[["_aexit", "__aexit__", "main"], "Task-1", []]]),
56+
("root2", [[["_aexit", "__aexit__", "main"], "Task-1", []]]),
57+
(
58+
"child1_1",
59+
[
60+
[
61+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
62+
"root1",
63+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
64+
]
65+
],
66+
),
67+
(
68+
"child2_1",
69+
[
70+
[
71+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
72+
"root1",
73+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
74+
]
75+
],
76+
),
77+
(
78+
"child1_2",
79+
[
80+
[
81+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
82+
"root2",
83+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
84+
]
85+
],
86+
),
87+
(
88+
"child2_2",
89+
[
90+
[
91+
["_aexit", "__aexit__", "blocho_caller", "bloch"],
92+
"root2",
93+
[[["_aexit", "__aexit__", "main"], "Task-1", []]],
94+
]
95+
],
96+
),
97+
],
98+
),
99+
(0, []),
100+
]
101+

0 commit comments

Comments
 (0)