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

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

Closed
suroh opened this issue Jun 11, 2018 · 20 comments · Fixed by #1351
Closed

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

suroh opened this issue Jun 11, 2018 · 20 comments · Fixed by #1351
Assignees

Comments

@suroh
Copy link

suroh commented Jun 11, 2018

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

@AndreMiras
Copy link
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 🤞

@tshirtman
Copy link
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.

@inclement
Copy link
Member

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

@suroh
Copy link
Author

suroh commented Jun 11, 2018

@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.

@AndreMiras
Copy link
Member

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

@Huyston
Copy link

Huyston commented Jul 24, 2018

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

@Huyston
Copy link

Huyston commented Jul 24, 2018

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.

@HeliosDK
Copy link

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.

@ghost
Copy link

ghost commented Aug 5, 2018

Same issue on Fedora 28... where can I add those options? I don't know what to do, it simply crashes (always at the same point when building hostpython2)

@jwbowen
Copy link

jwbowen commented Aug 13, 2018

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

@tito
Copy link
Member

tito commented Sep 4, 2018

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.)

@tito tito self-assigned this Sep 4, 2018
@tito
Copy link
Member

tito commented Sep 4, 2018

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).

@AndreMiras
Copy link
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.

@tito
Copy link
Member

tito commented Sep 4, 2018

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.

@ghost
Copy link

ghost commented Sep 4, 2018

Well if you want people to use Python 3, then this really should be solved: #1337 because otherwise, nobody that isn't a ctypes wizard and can easily fix this will have any use of it

@tito
Copy link
Member

tito commented Sep 4, 2018

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 :/

@ghost
Copy link

ghost commented Sep 4, 2018

Yea CrystaX seems dead, they didn't respond about me filing a ticket about missing lzma from the standard library either.

However, integrating the patch in #1337 would be a huge improvement with minimal effort for at least the current temporary situation. So I think it's worth adding this into the initialization bootstrap python script for now, until a non-Crystax Python 3 port can be made to work.

Edit: also, p4a's Python 2 already ships with a similar hack on which this was actually based, so it would probably be necessary for a non-Crystax Python 3 build anyway

@AndreMiras
Copy link
Member

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

@suroh
Copy link
Author

suroh commented Oct 2, 2018

Thanks all for the research and the help.

@CyberDrudge
Copy link

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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants