Skip to content

Python2 Build fails with make: *** [Makefile:426: sharedmods] Error 139 #1297

Closed

Description

@suroh

Python version: 3.6

OS: Arch Linux

python-for-android version: 0.6.0

The command I use to build is:

p4a apk --private ~/Projects/Python/Mobile_Apps/BeerApp/ --package=org.drink.recommendations --name "Drink Recommendations" --version 0.2 --bootstrap=sdl2 --requirements=python2,kivy --ndk_version r9c

The error is:

make: *** [Makefile:426: sharedmods] Error 139

The build logs are in the following file.
p4a_errors.txt

Initally I thought that this was a buildozer issue, as I attempted it that way first. So, I opened an issue on their github page and multiple users pointed out that they too were experiencing this issue. I've tried with both python3 and python2, the out come is the same. There is absolutely no unicode in any of my source files, I've also attempted the build with pygame instead of sdl2 (for python 2). There are also multiple simillar SO threads open about this.

Does anyone have any sugesstions or ideas as to why this is happening and how to go about fixing it?

It's also worth noting that if I use the kivy buildozer vm, I can use buildozer to carry out a successful build. Just not on any other machine using either buildozer or p4a, using the same source and build commands.

The buildozer issue is here: kivy/buildozer#673

The output from the dump file is:

Reading symbols from /home/suroh/.local/share/python-for-android/build/other_builds/hostpython2/desktop/hostpython2/python...done. [New LWP 28854] [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1". Core was generated by ./python -E ./setup.py -q build. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x000055731803eb2a in PyInstance_NewRaw (klass=klass@entry=0x7f7cbf1d1c18, dict=0x557319325210, dict@entry=0x0) at Objects/classobject.c:534 534 inst->in_dict = dict; File "/home/suroh/.local/share/python-for-android/build/other_builds/hostpython2/desktop/hostpython2/python-gdb.py", line 55 Py_TPFLAGS_HEAPTYPE = (1L << 9) ^ SyntaxError: invalid syntax

Activity

  1. AndreMiras commented on Jun 11, 2018

    @AndreMiras
    Member

    It's a bit annoying because it's a segfault 😞
    Can you edit your issue and link to the buildozer ticket you created?

    I don't have the solution, but I can suggest few things to take a look at.

    1. Try p4a master branch p4a.branch = master in your buildozer.spec
    2. Also I think it could be great to give a try in an isolated Docker environment. Rather it crashes or not would give some hint. You need to clone the p4a repository build the Docker image and play with it.
      You can take a look at .travis.yml to see how we play with it.

    So I think Docker could help, because it may not crash on that image. but then you can try to modify it a bit and makes it look like your own setup, e.g. Arch Linux... But also maybe it already crashes straight away with the Dockerfile provided. All of that could help to "corner" where the issue comes from and eventually fix it.

    Good luck 🤞

  2. tshirtman commented on Jun 11, 2018

    @tshirtman
    Member

    do you have a core.dump file? if so, you can open it with gdb, maybe it would provide some hinsight about what was happening while it crashed, though, without debug symbols, it's a bit like hitting in the dark.

  3. inclement commented on Jun 11, 2018

    @inclement
    Member

    I have the same issue, on Arch, but haven't had time to really look at it yet.

  4. suroh commented on Jun 11, 2018

    @suroh
    Author

    @AndreMiras I'll absolutely give that a try ( Not at home at the moment)! @tshirtman I've looked for a dump file but haven't been able to locate one, when I get home I'll re-run and search more as I cleared everything out.

  5. AndreMiras commented on Jun 12, 2018

    @AndreMiras
    Member

    Good point for the core dump. On Gentoo it's disable by default, but running ulimit -c unlimited enables it.

  6. Huyston commented on Jul 24, 2018

    @Huyston
    Contributor

    I have the same issue. I'm also on Arch. Maybe it has to do with some 32bit libs.

  7. Huyston commented on Jul 24, 2018

    @Huyston
    Contributor

    Well, someone fixed it by using:
    BASECFLAGS=-m32 LDFLAGS=-m32 CFLAGS=-m32 ./configure --prefix=/opt/python32
    Don't know how to test this with buildozer though.

  8. HeliosDK commented on Jul 25, 2018

    @HeliosDK

    The build cpython with BASECFLAGS=-m32 LDFLAGS=-m32 CFLAGS=-m32 ./configure --prefix=/opt/python32 is not a fix.
    I have just used alot of time building python2 / python3 and no luck same error. (make: *** [Makefile:426: sharedmods] Error 139)

    /bin/sh: linje 1: 9857 Segmentfejl (smed kerne) CC='gcc -pthread' LDSHARED='gcc -pthread -shared ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build

    This was with python-for-android and buildozer build from master.

  9. jwbowen commented on Aug 13, 2018

    @jwbowen

    I'm also running into the issue on Fedora 28, even with -m32 in CFLAGS.

  10. tito commented on Sep 4, 2018

    @tito
    Member

    Got it too :[

    Hostpython build is straightforward, and a simple ./configure && make should works. It appears no:
    On my system, no ccache, PATH reduced to /usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:

    $ wget https://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
    $ tar xf Python-2.7.2.tar.bz2
    $ cd Python-2.7.2
    $ ./configure
    $ make
    

    => ends up with a segfault:

    /home/tito/code/connectage/app/.buildozer/android/platform/build/build/other_builds/p/Python-2.7.2/./Modules/posixmodule.c:7317: warning: the use of `tempnam' is dangerous, better use `mkstemp'
    /bin/sh: line 1: 18943 Segmentation fault      (core dumped) CC='gcc -pthread' LDSHARED='gcc -pthread -shared ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes' ./python -E ./setup.py build
    

    So it's system wide, not related to cross compilation (as we are not yet there), and the env (as far as i understand.)

  11. self-assigned this
    on Sep 4, 2018
  12. tito commented on Sep 4, 2018

    @tito
    Member

    Works with Python 2.7.15.

    Related issues:

    Long story short, issue was a longstanding in Python < 2.7.15, and recently triggered with recent compiler. They fixed it in 3.x, and backported into 2.7.15. So instead of just gathering the patch back, maybe it's best to update our 2.x version to 2.7.15 with the cross compilation patches. I'm a little bit afraid of the implication (ssl certificates issues on 2.7.x at some point).

  13. AndreMiras commented on Sep 4, 2018

    @AndreMiras
    Member

    Thanks for the research @tito I like the idea of upgrading. But I also like the idea of not investing too much time of it. I think we should drop Python 2 support soon anyway and focus more on Python 3.
    https://pythonclock.org
    The problem is currently I think we have better support for Python 2 than for Python 3. That leads people to use that implementation by default rather than contributing on the Python 3 ecosystem.

  14. tito commented on Sep 4, 2018

    @tito
    Member

    I'll fix it anyway, last time i checked python 3, i wasn't able to have sqlite3 + ssl working. And i have few customer old app that i need to maintain, and no budget to switch to Python 3 yet.
    So drop it is not a complete solution for now.

  15. tito commented on Sep 4, 2018

    @tito
    Member

    I understand, and in my point of view, Crystax SDK is not maintained, our best shot is native compilation of Python 3 same as what we do in Python 2. I already spent time without tangible success yet. And now i need to deliver, no free time to dig and continue for now :/

  16. added a commit that references this issue on Sep 4, 2018
    ee427a3
  17. AndreMiras commented on Sep 4, 2018

    @AndreMiras
    Member

    Guys #1351 was merged to master, please give it a try @jwbowen @Jonast @suroh

  18. suroh commented on Oct 2, 2018

    @suroh
    Author

    Thanks all for the research and the help.

  19. CyberDrudge commented on Oct 29, 2018

    @CyberDrudge

    I got the same error using python3. Any fixes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions