diff --git a/src/linux/py_proc.h b/src/linux/py_proc.h index 2ceaf67..3dd460f 100644 --- a/src/linux/py_proc.h +++ b/src/linux/py_proc.h @@ -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); } @@ -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"); + set_error(EPROCVM); + FAIL; + } + + if (!(maps_flag & (BIN_MAP))) { + log_e("No usable Python binary found"); + set_error(EPROC); + FAIL; + } + 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 */ diff --git a/test/test_attach.py b/test/test_attach.py index 03e1eb2..9a17cbc 100644 --- a/test/test_attach.py +++ b/test/test_attach.py @@ -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 @@ -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 diff --git a/test/test_valgrind.py b/test/test_valgrind.py index 9582086..2e46547 100644 --- a/test/test_valgrind.py +++ b/test/test_valgrind.py @@ -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()