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

2.x,3.x iOS static build: Fatal Python error: exceptions bootstrapping error. #59071

Closed
ghost opened this issue May 21, 2012 · 10 comments
Closed
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-mac type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@ghost
Copy link

ghost commented May 21, 2012

BPO 14866
Nosy @ronaldoussoren, @amauryfa
Files
  • pyconfig.h
  • config.c
  • Python-3.2.3.tar.bz2: test project
  • iOS-build272.sh: Xcode 4.3.2, u'll need patch from http://randomsplat.com/wp-content/uploads/2011/10/Python-2.7.2-xcompile.patch
  • iOS-build272.sh
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ronaldoussoren'
    closed_at = <Date 2012-05-22.05:43:04.597>
    created_at = <Date 2012-05-21.05:20:29.961>
    labels = ['OS-mac', 'interpreter-core', 'type-crash']
    title = '2.x,3.x iOS static build: Fatal Python error: exceptions bootstrapping error.'
    updated_at = <Date 2012-05-22.15:03:00.112>
    user = None

    bugs.python.org fields:

    activity = <Date 2012-05-22.15:03:00.112>
    actor = 'ronaldoussoren'
    assignee = 'ronaldoussoren'
    closed = True
    closed_date = <Date 2012-05-22.05:43:04.597>
    closer = 'amaury.forgeotdarc'
    components = ['Interpreter Core', 'macOS']
    creation = <Date 2012-05-21.05:20:29.961>
    creator = '\xe3\x83\x89\xe3\x83\x9f\xe3\x83\x88\xe3\x83\xaa.\xe3\x82\xb9\xe3\x83\x86\xe3\x83\x91\xe3\x83\x8c\xe3\x82\xb7\xe3\x82\xad\xe3\x83\xb3'
    dependencies = []
    files = ['25656', '25657', '25658', '25670', '25672']
    hgrepos = []
    issue_num = 14866
    keywords = []
    message_count = 10.0
    messages = ['161244', '161245', '161259', '161270', '161323', '161327', '161328', '161330', '161334', '161361']
    nosy_count = 3.0
    nosy_names = ['ronaldoussoren', 'amaury.forgeotdarc', '\xe3\x83\x89\xe3\x83\x9f\xe3\x83\x88\xe3\x83\xaa.\xe3\x82\xb9\xe3\x83\x86\xe3\x83\x91\xe3\x83\x8c\xe3\x82\xb7\xe3\x82\xad\xe3\x83\xb3']
    pr_nums = []
    priority = 'normal'
    resolution = 'works for me'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue14866'
    versions = ['Python 2.7', 'Python 3.2']

    @ghost
    Copy link
    Author

    ghost commented May 21, 2012

    I trying to make minimal part of Python to work as part (static library) of my iOS application for internal scripting. I used configure under Mac OS X(10.7) and it was successful. Then I got compilable and linkable XCode project very fast.
    The problem is, when I trying to use Python by 
    Py_NoSiteFlag=1;
    Py_Initialize();
    it fails with error "Fatal Python error: exceptions bootstrapping error." inside _PyExc_Init().
    I tried to debug it, but unfortunately I cant understand why it fails. May be bacause I noob in Python source, but anyway, I need to port it. Tried 2.7.3, or latest 3.x, it was the same result as above. Any solution or hint will be very helpful.

    Best Regards

    @ghost ghost assigned ronaldoussoren May 21, 2012
    Repository owner added interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-mac type-crash A hard crash of the interpreter, possibly with a core dump labels May 21, 2012
    @ghost
    Copy link
    Author

    ghost commented May 21, 2012

    Call stack:
    #0 0x300cba1c in __pthread_kill ()
    #1 0x362e43ba in pthread_kill ()
    #2 0x362dcbfe in abort ()
    #3 0x00127d96 in Py_FatalError at /Users/mac_user/Downloads/Python-3.2.3/IOS/pythoncore/../../Python/pythonrun.c:2169
    #4 0x00155328 in _PyExc_Init at /Users/mac_user/Downloads/Python-3.2.3/IOS/pythoncore/../../Objects/exceptions.c:2042
    #5 0x00127ad4 in Py_InitializeEx at /Users/mac_user/Downloads/Python-3.2.3/IOS/pythoncore/../../Python/pythonrun.c:272
    #6 0x0012846a in Py_Initialize at /Users/mac_user/Downloads/Python-3.2.3/IOS/pythoncore/../../Python/pythonrun.c:332
    #7 0x000d6242 in testpython at /Users/mac_user/Downloads/Python-3.2.3/IOS/test/test/testmac.c:15
    #8 0x000d618e in -[ViewController viewDidLoad] at /Users/mac_user/Downloads/Python-3.2.3/IOS/test/test/ViewController.m:23
    #9 0x3283ff0e in -[UIViewController view] ()
    #10 0x3283e2b4 in -[UIWindow addRootViewControllerViewIfPossible] ()
    #11 0x3283a332 in -[UIWindow _setHidden:forced:] ()
    #12 0x3283e28e in -[UIWindow _orderFrontWithoutMakingKey] ()
    #13 0x3284cc60 in -[UIWindow makeKeyAndVisible] ()
    #14 0x000d5ffe in -[AppDelegate application:didFinishLaunchingWithOptions:] at /Users/mac_user/Downloads/Python-3.2.3/IOS/test/test/AppDelegate.m:35
    #15 0x3283e820 in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] ()
    #16 0x32838b64 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
    #17 0x3280d7d6 in -[UIApplication handleEvent:withNewEvent:] ()
    #18 0x3280d214 in -[UIApplication sendEvent:] ()
    #19 0x3280cc52 in _UIApplicationHandleEvent ()
    #20 0x322b7e76 in PurpleEventCallback ()
    #21 0x3113ba96 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
    #22 0x3113d83e in __CFRunLoopDoSource1 ()

    @ghost
    Copy link
    Author

    ghost commented May 21, 2012

    I tried look as deep as I can. The result from 3.2.3 port: it fails in Python/getargs.c:convertsimple():line 709, error "signed integer is less than minimum". It parses some parameters, and we have an error on last, 5th parameter. I really have no idea what happens here and why, knowing that same code works just fine under Windows.

    @amauryfa
    Copy link
    Member

    Most of the time, embedding python in this way requires precise control over PYTHONPATH and PYTHONHOME.  Did you try to modify them?
    Something like this worked for me:
      putenv("PYTHONPATH=/path/to/python-3.2.3/Lib");
      Py_SetPythonHome(L"/path/to/python-3.2.3");
    I don't know whether both are needed.

    @ghost
    Copy link
    Author

    ghost commented May 22, 2012

    thank You for answer. my problem was finally solved by using build script from https://github.com/cobbal/python-for-iphone and patch from http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html

    @ronaldoussoren
    Copy link
    Contributor

    The build script you mentioned seems to be for python 2.6, did you have to change anything beyond the version numbers to get it to build python 3.2 as well?

    @ghost
    Copy link
    Author

    ghost commented May 22, 2012

    actually I changed all, that was needed to build Python static library for iOS device(BTW it doesn't work for simulator, I got configure errors, I can't(or have no time if u want) to resolve), but not much changes.
    Want to see working script? OK, attached.
    Tested on 2.6.5, and 2.7.2(2.7.x is must have for my application, so sont tested with 3.x)

    @ghost
    Copy link
    Author

    ghost commented May 22, 2012

    I embedded 2.7.2 static in iOS test app, and, at least "print "something"" is worked.
    Now I *sigh* need to make it compile and work on iPhone Simulator.
    I'll try hard, and upload working script, if I'll can fix this mess.

    @ghost
    Copy link
    Author

    ghost commented May 22, 2012

    fixed it for build BIG FAT binary. attached.

    @ronaldoussoren
    Copy link
    Contributor

    Thanks for posting a working script. I was mostly interested in this because I'll likely need this functionality myself in the near future ;-)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-mac type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants