Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-02-01 Thread Ryan Gonzalez
That looks better! Looks like now the real encoding issues are coming up. Try going to line 269 of pythonrun.c and changing: PyErr_SetNone(PyExc_NotImplementedError); return NULL; to: char* m = malloc(6); strcpy(m, "ascii"); return m; This just sets a default encoding. On Sat, Jan 31, 2015 at

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-02-01 Thread Ryan
3.4.x >for me...I may go back to working on 2.7.x > >Sent from my android device. > >-Original Message- >From: Ryan Gonzalez >To: Cyd Haselton >Cc: Python-Dev >Sent: Fri, 30 Jan 2015 7:53 PM >Subject: Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-02-01 Thread Cyd Haselton
to figure out a way to get the instuctions you sent >>implemented, but this may be a deal-breaker for porting Python 3.4.x >>for me...I may go back to working on 2.7.x >> >>Sent from my android device. >> >>-Original Message- >>From: Ryan Gonzalez

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-02-01 Thread Cyd Haselton
Very interesting. I got this error Fatal Python error: Py_Initialize: Unable to get the locale encoding NotImplementedError Aborted generate-posix-vars failed make: *** [pybuilddir.txt] Error 1 ...but it didn't (of course) segfault. I'll pull gdb, get the results and send them. On January 31,

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-31 Thread Cyd Haselton
There were references to oldloc in Modules/python.c...a duplicate of the line in frozenmain.c and some others. On a hunch I commented them out, ran make clean && make. If it fails, I'll revert and use the method you sent in the email after this (thanks...by the way!) On January 31, 2015 1:10:1

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-31 Thread Ryan
No; I was looking for all uses of _PyRaw_Strdup. Surprisingly, it's used only a few times. Cyd Haselton wrote: >Question: >When you said earlier that you found the problem by using grep...were >you looking for places where strdup called locale? > >On January 30, 2015 7:52:47 PM CST, Ryan Gonzale

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-31 Thread Cyd Haselton
Question: When you said earlier that you found the problem by using grep...were you looking for places where strdup called locale? On January 30, 2015 7:52:47 PM CST, Ryan Gonzalez wrote: >Regardless, if you're looking to toy more with stuff like this, I'd >highly >recommend dual-booting with Ub

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-31 Thread chaselton
ng on 2.7.x Sent from my android device. -Original Message- From: Ryan Gonzalez To: Cyd Haselton Cc: Python-Dev Sent: Fri, 30 Jan 2015 7:53 PM Subject: Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault Regardless, if you're looking to toy more with stuff like t

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-31 Thread Ryan Gonzalez
Regardless, if you're looking to toy more with stuff like this, I'd highly recommend dual-booting with Ubuntu, which is what I'm doing now. (Now I rarely ever boot into Windows!) On Fri, Jan 30, 2015 at 7:51 PM, Ryan Gonzalez wrote: > Do you have just the SDK (which doesn't require Cygwin) or a

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Ryan Gonzalez
Do you have just the SDK (which doesn't require Cygwin) or a rooted phone? If so, I can upload instructions that don't use the NDK. On Fri, Jan 30, 2015 at 6:19 PM, Cyd Haselton wrote: > This is going to take some time...here's why: > > Downloading and installing the NDK/SDK won't be too hard...

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
This is going to take some time...here's why: Downloading and installing the NDK/SDK won't be too hard...I have to clear some space...but my primary machine is running Windows 7 and I'd rather swallow hot coals than install Cygwin. I've got next to no experience with it, other than knowing that t

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Ryan Gonzalez
Do you have the Android SDK and NDK installed? If so... Using Google, I've created this series of steps, which may (or may not) work: 1. Make sure you have a copy of Python on your computer and make sure that it's built with debug symbols. 2. Run the following commands from a shell with your pho

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Ryan Gonzalez
Are you sure the patch was applied correctly? I was SO sure it would work! FYI, you tried the patch I attached to the email message, right? On Fri, Jan 30, 2015 at 12:58 PM, Cyd Haselton wrote: > Update: I did try the patch after getting it installed correctly, but > I'm still getting a segfau

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
I've got a page of all of the modifications to source files I've used in my attempts to get 3.4.2 working...I can post it somewhere if the port ever succeeds. On Fri, Jan 30, 2015 at 2:07 PM, Victor Stinner wrote: > Oh, I found my old patch to force UTF-8 on Android. I didn't test it: > see attac

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
Update: I did try the patch after getting it installed correctly, but I'm still getting a segfault on the newly built binary. Will post info this afternoon. On Fri, Jan 30, 2015 at 12:10 PM, Ryan Gonzalez wrote: > No, it returns NULL if malloc gives it a raw pointer. It unconditionally > checks

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
Unfortunately it is still reporting the same function :-/. On Fri, Jan 30, 2015 at 1:44 PM, Ryan Gonzalez wrote: > Yes... > > Can you check if it's crashing in a different function now? > > On Fri, Jan 30, 2015 at 1:39 PM, Cyd Haselton wrote: >> >> Yes I did. I did have to enter all the informa

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
Ok...that makes sense.. apologies I do not do a lot of debugging. My goal was to get Python (then spidermonkey) on my device then start learning languages where i'd need to learn debugging. Tried patch, see my reply, agree about Android's locale...at least where native codeis concerned On Fri, Ja

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Victor Stinner
Oh, I found my old patch to force UTF-8 on Android. I didn't test it: see attached file. It would be nice to start a wiki page to collect all informations on the Python port to Android. Victor 2015-01-30 21:04 GMT+01:00 Victor Stinner : > Android provides a minimal support of locales. Most funct

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Victor Stinner
Android provides a minimal support of locales. Most functions return a fake result, do nothing. I'm not sure that it supports any codec. To support Android, we may force UTF-8 for the filesystem encoding, as done on Mac OS X. Victor 2015-01-30 19:04 GMT+01:00 Ryan Gonzalez : > No... > > ...but I

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Ryan Gonzalez
No, it returns NULL if malloc gives it a raw pointer. It unconditionally checks the length of the (possibly null) string argument first. Please try the patch I attached in the last email. It *might* fix the issue. Android has crappy locale handling. On Fri, Jan 30, 2015 at 12:09 PM, Cyd Haselton

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
Unless i'm reading something incorrectly, _PyMem_RawStrdup is currently returning NULL when given a null pointer. >From obmalloc.c _PyMem_RawStrdup(const char *str) { size_t size; char *copy; size = strlen(str) + 1; copy = PyMem_RawMalloc(size); if (copy == NULL) return

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Ryan Gonzalez
No... ...but I think I found the issue with grep. Try applying the attached patch to the Python/frozenmain.c. It comments out the locale handling. It seems that Python always calls its strdup function on the locale string. On Android, this can apparently be null (as seen in the bug report you lin

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
I don't have gdb on device; does the following tell you where Python's strdup is called? >> _PyMem_RawStrdup >> /bld/python/Python-3.4.2/Objects/obmalloc.c:323 On Fri, Jan 30, 2015 at 11:52 AM, Ryan Gonzalez wrote: > Is it possible at all to get a stack trace of the crash using gdb? Try the > st

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Ryan Gonzalez
I seriously doubt the issue is in that file; _PyMem_RawStrdup crashes when calling strlen. It's that whatever is calling it is likely asking it to duplicate a null pointer. Basically, it's probably the caller's fault. You could always try modifying _PyMem_RawStrdup to return NULL when given a null

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
Alternatively, is there a hassle-free way to find out what changed in obmalloc.c between 2.7.x and 3.4.x? On Fri, Jan 30, 2015 at 9:29 AM, Cyd Haselton wrote: > There's a related strdup patch for readline.c, mentioned > here:http://bugs.python.org/issue21390 and here > https://github.com/rave-en

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Ryan Gonzalez
Is it possible at all to get a stack trace of the crash using gdb? Try the steps here . That way we can see where Python's own strdup function is getting called. On Fri, Jan 30, 2015 at 9:05 AM, Cyd Haselton wrote: > Absolutely. Good thing I have ad

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
There's a related strdup patch for readline.c, mentioned here:http://bugs.python.org/issue21390 and here https://github.com/rave-engine/python3-android/issues/2. There's a patch, but I'm not sure how to modify it for obmalloc.c, as (I think) the functions all belong to Python...they're all prefixed

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-30 Thread Cyd Haselton
Absolutely. Good thing I have addr2line on device /bld/python/Python-3.4.2 $ addr2line -C -f -e /lib/libpython3.4m.so.1.0 0008bbc8 _PyMem_RawStrdup /bld/python/Python-3.4.2/Objects/obmalloc.c:323 /bld/python/Python-3.4.2 $ On Thu, Jan 29, 2015 at 8:26 PM, Ryan wrote: > Could you try the steps

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-29 Thread Ryan
Could you try the steps at http://stackoverflow.com/a/11369475/2097780? They allow you to get a better idea of where libc is crashing. Cyd Haselton wrote: >Managed to get this out of logcat: >F(11914) Fatal signal 11 (SIGSEGV) at 0x (code=1), thread >11914 (python) (libc) > >[ 01-29 19:

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-29 Thread Cyd Haselton
Managed to get this out of logcat: F(11914) Fatal signal 11 (SIGSEGV) at 0x (code=1), thread 11914 (python) (libc) [ 01-29 19:30:55.855 23373:23373 F/libc ] Fatal signal 11 (SIGSEGV) at 0x (code=1), thread 23373 (python) Less detail than strace but it seems to be that python

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-29 Thread Cyd Haselton
Found a patch for at bugs.python.org addressing a segfault issue for android but even afternapplying it i'm still getting a segfault. I ran a strace with the verbose option and am attaching it to this update. If not helpful, I'll see if I can hook up the debugging bridge to the tablet but as ment

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-28 Thread Cyd Haselton
That is interesting.../dev/__properties__ is in memory...not the filesystem, apparently proccesses read global properties from it. It's read-only...not sure why the build or the python binary would access it...or if that's the cause of the segfault. I have root access on the tablet so I was able t

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-28 Thread Ryan Gonzalez
On Wed, Jan 28, 2015 at 10:43 AM, Guido van Rossum wrote: > What I see in the strace: > > ... load libpython3.4m.so.1.0 > ... load libm > ... open /dev/__properties__ and do something to it (what?) > ... get current time > ... allocate memory > ... getuid > ... segfault > > That's not a lot to go

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-28 Thread Cyd Haselton
Apologies...I'm not sure what a stack track is, but I do have the strace. Nearest I can tell, it happens due to an open call, though I am probably wrong. Attaching the strace output to this email. I'm going to head back to the documentation and to back out of some Android-related changes in _loca

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-28 Thread Guido van Rossum
What I see in the strace: ... load libpython3.4m.so.1.0 ... load libm ... open /dev/__properties__ and do something to it (what?) ... get current time ... allocate memory ... getuid ... segfault That's not a lot to go on, but it doesn't look as if it has started to load modules yet. Does /dev/__

Re: [Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-28 Thread Guido van Rossum
There could be a million differences relevant (unicode, ints, ...). Perhaps the importlib bootstrap is failing. Perhaps the dynamic loading code changed. Did you get a stack track? (IIRC strace shows a syscall trace -- also useful, but doesn't tell you precisely how it segfaulted.) On Wed, Jan 28,

[Python-Dev] Newly Built Python3 Binary Throws Segfault

2015-01-28 Thread Cyd Haselton
All, I recently ditched my attempts to port Python 2.7.8 to Android in favor of Python 3.4.2. Unfortunately, after using the same configure options in the same environment, and modifying the setup.py as needed, the newly built binary throws a segfault when the generate-posix-vars portion of the bu