panda icon indicating copy to clipboard operation
panda copied to clipboard

pyPANDA rr_get_guest_instr_count() can overflow with large instruction counts

Open wpence opened this issue 2 years ago • 1 comments

In panda.py the rr_get_guest_instr_count() can return negative integer numbers when the system has a large instruction count. It turns out the C API used with cffi to build pyPANDA only returns an int which appears to be causing this problem, but the actual instruction count is stored as a uint64_t.

If the header file: https://github.com/panda-re/panda/blob/dev/panda/include/panda/panda_api.h#L34

and corresponding source file: https://github.com/panda-re/panda/blob/dev/panda/src/panda_api.c#L132

are updated to return a uint64_t (how the instruction count is stored in C) and the pyPANDA python package is rebuilt, this appears to solve the problem on the Python side.

wpence avatar Sep 19 '22 13:09 wpence

That looks like a problem. Thanks for the bug report.

lacraig2 avatar Oct 04 '22 15:10 lacraig2

Created PR #1242 to fix this issue. Verified with a very large ARM replay file that the instruction count no longer overflows when using the Python API.

wpence avatar Nov 01 '22 12:11 wpence

PR #1242 fixes issue. Merged.

lacraig2 avatar Nov 11 '22 09:11 lacraig2