Skip to content

Commit

Permalink
fix Linux flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
P403n1x87 committed Aug 31, 2023
1 parent a98f0d0 commit ab87302
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
15 changes: 13 additions & 2 deletions src/linux/py_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ _py_proc__parse_maps_file(py_proc_t * self) {
size_t page_size = getpagesize();
map->bss_base = (void *) lower - page_size;
map->bss_size = upper - lower + page_size;
maps_flag |= BSS_MAP;
log_d("Inferred BSS for %s: %lx-%lx", map->path, lower, upper);
}

Expand Down Expand Up @@ -539,10 +538,22 @@ _py_proc__parse_maps_file(py_proc_t * self) {
self->map.bss.base = pd->maps[map_index].bss_base;
self->map.bss.size = pd->maps[map_index].bss_size;

if (!isvalid(self->map.bss.base)) {
log_e("Cannot find valid BSS map");

Check warning on line 542 in src/linux/py_proc.h

View check run for this annotation

Codecov / codecov/patch

src/linux/py_proc.h#L542

Added line #L542 was not covered by tests
set_error(EPROCVM);
FAIL;

Check warning on line 544 in src/linux/py_proc.h

View check run for this annotation

Codecov / codecov/patch

src/linux/py_proc.h#L544

Added line #L544 was not covered by tests
}

if (!(maps_flag & (BIN_MAP))) {
log_e("No usable Python binary found");

Check warning on line 548 in src/linux/py_proc.h

View check run for this annotation

Codecov / codecov/patch

src/linux/py_proc.h#L548

Added line #L548 was not covered by tests
set_error(EPROC);
FAIL;

Check warning on line 550 in src/linux/py_proc.h

View check run for this annotation

Codecov / codecov/patch

src/linux/py_proc.h#L550

Added line #L550 was not covered by tests
}

log_d("BSS map %d from %s @ %p", map_index, pd->maps[map_index].path, self->map.bss.base);
log_d("VM maps parsing result: bin=%s lib=%s flags=%d", self->bin_path, self->lib_path, maps_flag);

return !(maps_flag & (BIN_MAP | BSS_MAP));
SUCCESS;
} /* _py_proc__parse_maps_file */


Expand Down
6 changes: 3 additions & 3 deletions test/test_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
@allpythons()
@variants
def test_attach_wall_time(austin, py, mode, mode_meta, heap):
with run_python(py, target("sleepy.py"), "1") as p:
sleep(0.4)
with run_python(py, target("sleepy.py"), "2") as p:
sleep(0.5)

result = austin(mode, "2ms", *heap, "-p", str(p.pid))
assert result.returncode == 0
Expand Down Expand Up @@ -189,4 +189,4 @@ def test_attach_container_like(py, tmp_path, prefix):
a = sum_metric(result.stdout)
d = int(meta["duration"])

assert abs(a - d) <= (a + d) * 0.1
assert abs(a - d) <= (a + d) * 0.25
2 changes: 1 addition & 1 deletion test/test_valgrind.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_valgrind_fork(py, mode):
@pytest.mark.parametrize("mode", ["", "s", "C", "Cs"])
@allpythons()
def test_valgrind_attach(py, mode):
with run_python(py, target("sleepy.py")) as p:
with run_python(py, target("sleepy.py"), "2") as p:
result = valgrind(["-p", str(p.pid)], mode)
assert result.returncode == 0, "\n".join((result.stdout, result.stderr))
p.kill()

0 comments on commit ab87302

Please sign in to comment.