Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import itertools ImportError: dlopen(/Users/k3vin/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/lib/python2.7/lib-dynload/itertools.so #1173

Closed
k3vinlusec opened this issue Jan 23, 2020 · 10 comments
Assignees
Milestone

Comments

@k3vinlusec
Copy link

Hi, I was trying to debug .so in an app with gdb, I encountered the following error.
k3vin@Kais-MacBook-Pro bin % ./gdb
Traceback (most recent call last):
File "/Users/k3vin/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/share/gdb/python/gdb/init.py", line 143, in auto_load_packages
import(modname)
File "/Users/k3vin/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/share/gdb/python/gdb/command/frame_filters.py", line 22, in
from gdb.FrameIterator import FrameIterator
File "/Users/k3vin/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/share/gdb/python/gdb/FrameIterator.py", line 17, in
import itertools
ImportError: dlopen(/Users/k3vin/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/lib/python2.7/lib-dynload/itertools.so, 2): Symbol not found: _PyBool_Type
Referenced from: /Users/k3vin/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/lib/python2.7/lib-dynload/itertools.so
Expected in: flat namespace
in /Users/k3vin/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/lib/python2.7/lib-dynload/itertools.so

GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin14.5.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb)

GDB is located at /Users/k3vin/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/bin

How to fix the error? Thanks!

@k3vinlusec k3vinlusec changed the title import itertools ImportError: dlopen(/Users/kailu/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/lib/python2.7/lib-dynload/itertools.so import itertools ImportError: dlopen(/Users/k3vin/Library/Android/sdk/ndk/21.0.6113669/prebuilt/darwin-x86_64/lib/python2.7/lib-dynload/itertools.so Jan 23, 2020
@DanAlbert DanAlbert added this to the r21b milestone Jan 24, 2020
@k3vinlusec
Copy link
Author

The testing system: MacBook Pro, macOS 10.15.2. Could you reproduce it?

@enh-google
Copy link
Collaborator

(i see the same on 10.14 if i run ./prebuilt/darwin-x86_64/bin/gdb, so i don't think this is 10.15-specific.)

@k3vinlusec
Copy link
Author

I want to use GEF in GDB to debug the app, if this issue won't be fixed, I cannot use GEF in GDB.

@DanAlbert
Copy link
Member

DanAlbert commented Feb 20, 2020

@hhb have you had a chance to look at this? Any idea what it will take to fix it?

@k3vinlusec
Copy link
Author

I compile the gdb 8.3 source code from google android by myself, and set target aarch64-linux-android, built with python3, it works well with GEF-gdb

@hhb
Copy link
Collaborator

hhb commented Mar 10, 2020

I'm still trying to figure out what's happening. _PyBool_Type is defined in libpython2.7.a. libpython is statically linked into gdb binary. But gdb doesn't export any symbol. Linking flag issue?

It is also interesting that this didn't cause any problem on other platforms.

@hhb
Copy link
Collaborator

hhb commented Mar 10, 2020

The unstripped binary does have PyBool_Type. Maybe we should not strip it.

@DanAlbert
Copy link
Member

IIRC there's a flag to choose specific symbols to avoid stripping. I would assume that if it needs to continue exporting "unused" symbols there's probably a version script that goes with it?

@enh-google
Copy link
Collaborator

strip --keep-symbol

disigma pushed a commit to wimal-build/ndk that referenced this issue Mar 11, 2020
Bug: android/ndk#1173
Change-Id: I1748371baf4aea5952436864b9d217e668d856d4
disigma pushed a commit to wimal-build/ndk that referenced this issue Mar 17, 2020
Oops forgot this part in aosp/1254254

Bug: android/ndk#1173
Change-Id: Ibe13a536d6dc5a2c827f48e78ffb3839d6b7edba
@DanAlbert
Copy link
Member

Fix is in build 6352462 on https://ci.android.com/builds/branches/aosp-ndk-release-r21/grid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants