Description
Description
I was learning about how to symbolise crash stacks on android (tombstone file). So, I induced a crash (nullptr-dereference) and it indeed produced a crash and generated a tombstone.txt file. When symbolising the crash stack via ndk-stack.py, I noticed that -
- On macOS (If apk is built on macOS and symbolised on macOS), I get a perfectly symbolised crash stack. (can see the source file and line number causing the crash)
- On windows (If apk is build on windows and symbolised on windows), the symbolise fails. (cannot see source file and line number)
I debugged further and found that the below snippet in ndk-stack.py
file -
def get_zip_info_from_offset(zip_file, offset):
"""Get the ZipInfo object from a zip file.
Returns: A ZipInfo object found at the 'offset' into the zip file.
Returns None if no file can be found at the given 'offset'.
"""
file_size = os.stat(zip_file.filename).st_size
if offset >= file_size:
return None
infos = zip_file.infolist()
if not infos or offset < infos[0].header_offset:
It looks like (correct me If I'm wrong) the above snippet expects infos
to be sorted based on header_offset
(this is true for apk built on macOS, but not on windows). To test out my hypothesis, I added a line to sort it -
def get_zip_info_from_offset(zip_file, offset):
"""Get the ZipInfo object from a zip file.
Returns: A ZipInfo object found at the 'offset' into the zip file.
Returns None if no file can be found at the given 'offset'.
"""
file_size = os.stat(zip_file.filename).st_size
if offset >= file_size:
return None
infos = zip_file.infolist()
infos = sorted(infos, key=lambda k: k.header_offset)
if not infos or offset < infos[0].header_offset:
and sure enough - the symbolise started working for me perfectly. Hence, thought I'd check with ndk team - do you see a need to introduce the above sort line? (I'm unsure why it's not sorted on windows. Is this due to apk not generated in proper format on windows for some reason?)
Environment Details
Not all of these will be relevant to every bug, but please provide as much
information as you can.
- NDK Version: 22.1.7171670
- Build system: CMake 3.10.2
- Host OS: Windows 10.
- ABI: x86_64 (any ABI for that matter)
- NDK API level:
- Device API level: 28
Let me know, if any more details are required!