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

Thread not working for python 2.7.1 built with HP Compiler on HP-UX 11.31 ia64 #57266

Closed
wahmeng mannequin opened this issue Sep 29, 2011 · 24 comments
Closed

Thread not working for python 2.7.1 built with HP Compiler on HP-UX 11.31 ia64 #57266

wahmeng mannequin opened this issue Sep 29, 2011 · 24 comments
Labels
build The build process and cross-build

Comments

@wahmeng
Copy link
Mannequin

wahmeng mannequin commented Sep 29, 2011

BPO 13057
Nosy @birkenfeld, @tpn, @ezio-melotti, @skrah, @py-user
Files
  • issue-13057.diff
  • 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 = None
    closed_at = <Date 2012-11-22.22:25:01.964>
    created_at = <Date 2011-09-29.02:38:37.063>
    labels = ['build']
    title = 'Thread not working for python 2.7.1 built with HP Compiler on HP-UX 11.31 ia64'
    updated_at = <Date 2013-01-18.05:22:35.164>
    user = 'https://bugs.python.org/wahmeng'

    bugs.python.org fields:

    activity = <Date 2013-01-18.05:22:35.164>
    actor = 'py.user'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-11-22.22:25:01.964>
    closer = 'skrah'
    components = ['Build']
    creation = <Date 2011-09-29.02:38:37.063>
    creator = 'wah meng'
    dependencies = []
    files = ['23262']
    hgrepos = []
    issue_num = 13057
    keywords = ['patch']
    message_count = 24.0
    messages = ['144584', '144586', '144587', '144622', '144660', '144662', '144664', '144665', '144666', '144667', '144668', '144669', '144670', '144671', '144672', '144675', '144678', '144685', '144686', '176127', '176128', '176134', '180174', '180175']
    nosy_count = 7.0
    nosy_names = ['georg.brandl', 'trent', 'ezio.melotti', 'skrah', 'py.user', 'python-dev', 'wah meng']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue13057'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2', 'Python 3.3']

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 29, 2011

    Resending as my old alternative email ID wasn't registered under my account.
    ===========================================================================
    Hello there,

    I included --with-threads option into the configure script calling, which it failed to add the -D_REENTRANT into Makefile. So I manually added this into OPT of the Makefile. I ran make again and generated a new python binary. However, the new binary is still not able to start a new thread from the thread module.

    I reviewed the config.log file, I think this failure has caused the build with threads failed. Cthreads.h header file is missing. Should this be included in my HP UX Compiler or it comes from python source? In python source I only found pythread.h. Anyway, I am only guessing what is wrong.

    Hope to hear some feedback here, whether this is something missing or a bug.

    configure:8407: checking for --with-threads
    configure:8427: result: yes
    configure:8484: checking for _POSIX_THREADS in unistd.h
    configure:8503: result: yes
    configure:8508: checking cthreads.h usability
    configure:8508: cc +DD64 -I/home/r32813/local/include -c -g  conftest.c >&5
    "conftest.c", line 128: error python/cpython#47946-D: cannot open source file "cthreads.h"
      #include <cthreads.h>
                           ^
    1 error detected in the compilation of "conftest.c".
    
    configure:8508: result: no
    configure:8508: checking for cthreads.h
    configure:8508: result: no
    configure:8521: checking mach/cthreads.h usability
    configure:8521: cc +DD64 -I/home/r32813/local/include -c -g  conftest.c >&5
    "conftest.c", line 128: error python/cpython#47946-D: cannot open source file "mach/cthreads.h"
      #include <mach/cthreads.h>
                                ^

    1 error detected in the compilation of "conftest.c".
    configure:8521: $? = 2
    configure: failed program was:
    | /* confdefs.h */
    | #define _GNU_SOURCE 1

    configure:8521: result: no
    configure:8521: checking for mach/cthreads.h
    configure:8521: result: no
    configure:8533: checking for --with-pth
    configure:8548: result: no
    configure:8556: checking for pthread_create in -lpthread
    configure:8572: cc +DD64 -I/home/r32813/local/include -o conftest -g -L/home/r32813/local/lib -L/home/r32813/Build/2.7.1/Python-2.7.1 conftest.c -l
    nsl -lrt -ldld -ldl -lpthread >&5

    Regards,
    Wah Meng
    Genesis Wafermap Support Ticket:
    To report a problem: http://dyno.freescale.net/Question/QuestionMain3.asp?location=zmy02&category=&tickettype=6820
    To request a service: http://dyno.freescale.net/Question/Questionmain3.asp?location=74&category=2&tickettype=6819
    Or if it is related to EWM or DSA: http://dyno.freescale.net/Question/Questionmain3.asp?location=ZMY02&tickettype=6539

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Sep 29, 2011

    However, the new binary is still not able to start a new thread from the thread module.

    Traceback?

    mach/cthreads.h is only relevant for Hurd, as far as I can see.

    configure:8572: cc +DD64 -I/home/r32813/local/include -o conftest -g
    -L/home/r32813/local/lib -L/home/r32813/Build/2.7.1/Python-2.7.1
    conftest.c -l nsl -lrt -ldld -ldl -lpthread >&5

    Result of this test?

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 29, 2011

    Traceback?

    $ python
    Python 2.7.1 (r271:86832, Sep 28 2011, 17:31:02) [C] on hp-ux11
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import thread
    >>> def testing():
    ...    print "Hello World"
    ... 
    >>> thread.start_new_thread(testing, ())  
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    thread.error: can't start new thread
    >>>

    mach/cthreads.h is only relevant for Hurd, as far as I can see.

    I am not sure what Hurd is. So I should not be looking at this one I guess.

    configure:8572: cc +DD64 -I/home/r32813/local/include -o conftest -g
    -L/home/r32813/local/lib -L/home/r32813/Build/2.7.1/Python-2.7.1
    conftest.c -l nsl -lrt -ldld -ldl -lpthread >&5

    Result of this test?

    configure:8556: checking for pthread_create in -lpthread
    configure:8572: cc +DD64 -I/home/r32813/local/include -o conftest -g -L/home/r32813/local/lib -L/home/r32813/Build/2.7.1/Python-2.7.1 conftest.
    c -lnsl -lrt -ldld -ldl -lpthread >&5
    "conftest.c", line 97: warning bpo-2223-D: function "exit" declared implicitly
    void * start_routine (void *arg) { exit (0); }
    ^

    "conftest.c", line 102: error bpo-2020: identifier "NULL" is undefined
    pthread_create (NULL, NULL, start_routine, NULL)
    ^

    1 error detected in the compilation of "conftest.c".
    configure:8572: $? = 2
    configure: failed program was:
    | /* confdefs.h */
    | #define _GNU_SOURCE 1
    | #define _NETBSD_SOURCE 1
    | #define __BSD_VISIBLE 1
    | #define _BSD_TYPES 1
    ----------
    nosy: +skrah


    Python tracker <report@bugs.python.org>
    <http://bugs.python.org/issue13057\>


    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Sep 29, 2011

    To me this looks like stdio.h should be included as well. Could
    you try the patch?

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 30, 2011

    Hello Stefan,

    Hmm..... how do I apply the patch? I download the issue-13057.diff file and then.....?

    Regards,
    Wah Meng

    @ezio-melotti
    Copy link
    Member

    "patch -p1 < issue-13057.diff" in the directory where configure is should do the trick.

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 30, 2011

    I tried.... here is the outcome. It says it can't find a patch??

    $ cat issue-13057.diff
    diff -r f612b783bc17 configure
    --- a/configure Thu Sep 29 07:52:46 2011 +0800
    +++ b/configure Thu Sep 29 21:39:32 2011 +0200
    @@ -8619,6 +8619,7 @@
         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     /* end confdefs.h.  */
     #include <pthread.h>
    +#include <stdio.h>

    void * start_routine (void *arg) { exit (0); }
    int

    $ patch -p1 < issue-13057.diff
    Hmm...  I can't seem to find a patch in there anywhere.
    $ pwd
    /home/r32813/Build/2.7.1/Python-2.7.1
    $

    Regards,
    Wah Meng

    @ezio-melotti
    Copy link
    Member

    If that's a Mercurial clone of Python you can try "hg import --no-commit issue-13057.diff". Otherwise you could just edit configure manually -- the attached patch is trivial. You could also install "patch".

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 30, 2011

    Mercurial clone of python? Haha I am not sure what that is. My unix also won't recognize "hg", and will ignore "import --no-commit issue-13057.diff".

    I went ahead to edit configure file. Partially understanding the content of .diff file, I edited the configure and here is the difference...

    I will try to rebuild now...

    $ diff configure.original configure
    8619a8620,8624
    >  #include <pthread.h>
    >  +#include <stdio.h>
    > 
    >   void * start_routine (void *arg) { exit (0); }
    >    int
    $ 

    Regards,
    Wah Meng

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 30, 2011

    Hello,

    I tried rebuild but it is still the same. :( Attached is the extract of the modified configure file, with line number at the side (from VI editor). Basically my changes are added as from line 8620 through 8624. I am not sure if this is meant to be, just my best guess from the patch file. Appreciate your advice.

    8612 $as_echo_n "checking for pthread_create in -lpthreads... " >&6; }
    8613 if test "${ac_cv_lib_pthreads_pthread_create+set}" = set; then :
    8614 $as_echo_n "(cached) " >&6
    8615 else
    8616 ac_check_lib_save_LIBS=$LIBS
    8617 LIBS="-lpthreads $LIBS"
    8618 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    8619 /* end confdefs.h. */
    8620 #include <pthread.h>
    8621 +#include <stdio.h>
    8622
    8623 void * start_routine (void *arg) { exit (0); }
    8624 int
    8625
    8626 /* Override any GCC internal prototype to avoid an error.
    8627 Use char because int might match the return type of a GCC
    8628 builtin and then its argument prototype would still apply. */
    8629 #ifdef __cplusplus
    8630 extern "C"
    8631 #endif

    Regards,
    Wah Meng
    Genesis Wafermap Support Ticket:
    To report a problem: http://dyno.freescale.net/Question/QuestionMain3.asp?location=zmy02&category=&tickettype=6820
    To request a service: http://dyno.freescale.net/Question/Questionmain3.asp?location=74&category=2&tickettype=6819
    Or if it is related to EWM or DSA: http://dyno.freescale.net/Question/Questionmain3.asp?location=ZMY02&tickettype=6539

    @ezio-melotti
    Copy link
    Member

    You just have to add:
    #include <stdio.h>
    
    just after:
    #include <pthread.h>

    The + in the diff only means that the line was added and shouldn't be included in the file.

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 30, 2011

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 30, 2011

    Sorry, there a more than one entry of "#include <pthread.h>" in configure file. So do I inject everywhere?

    Regards,
    Wah Meng
    Genesis Wafermap Support Ticket:
    To report a problem: http://dyno.freescale.net/Question/QuestionMain3.asp?location=zmy02&category=&tickettype=6820
    To request a service: http://dyno.freescale.net/Question/Questionmain3.asp?location=74&category=2&tickettype=6819
    Or if it is related to EWM or DSA: http://dyno.freescale.net/Question/Questionmain3.asp?location=ZMY02&tickettype=6539

    @ezio-melotti
    Copy link
    Member

    After the one at line 8620.

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 30, 2011

    Wow..... I added it everywhere in the file. I love you!! (Ermm... I mean, literally)

    It can work now. :). I will move on to migrate my application with this new python. Hopefully I don't see other modules breaking.

    Thanks for the GREAT helps!!! :)

    $ python
    Python 2.7.1 (r271:86832, Sep 27 2011, 15:19:26) [C] on hp-ux11
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import thread
    >>> def test():
    ...   print "Hello World"
    ... 
    >>> thread.start_new_thread(test,())
    2
    >>> Hello World

    Regards,
    Wah Meng
    Genesis Wafermap Support Ticket:
    To report a problem: http://dyno.freescale.net/Question/QuestionMain3.asp?location=zmy02&category=&tickettype=6820
    To request a service: http://dyno.freescale.net/Question/Questionmain3.asp?location=74&category=2&tickettype=6819
    Or if it is related to EWM or DSA: http://dyno.freescale.net/Question/Questionmain3.asp?location=ZMY02&tickettype=6539

    @birkenfeld
    Copy link
    Member

    Could you please stop putting these unrelated links into your posts? It is really annoying. Thanks.

    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 30, 2011

    I put up an issue the python I build is not able to run thread.start_new_thread. Someone replied to me that there is a bug in configure file and I follow the patch and rebuild my python, my thread is working after the patch is applied. I ended that issue discussion with thanks to the person who answered me and helped me.

    Sorry which one is unrelated?

    Regards,
    Wah Meng

    @wahmeng wahmeng mannequin closed this as completed Sep 30, 2011
    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Sep 30, 2011

    Wah Meng: I think there are a couple of misconceptions that
    need to be cleared up:

    1. Georg's complaint was about the links to http://dyno.freescale.net/
      in you posts.

    2. This is not a support hotline but a *bug tracker*. Since
      the bug in configure has not been fixed, this issue needs
      to stay open.

    @skrah skrah mannequin added the build The build process and cross-build label Sep 30, 2011
    @skrah skrah mannequin reopened this Sep 30, 2011
    @skrah skrah mannequin added the build The build process and cross-build label Sep 30, 2011
    @wahmeng
    Copy link
    Mannequin Author

    wahmeng mannequin commented Sep 30, 2011

    1.) I see. Sorry ya, I didn't notice. They are automatically generated as my email footer.
    2.) Ok, appreciate the information and helps!

    Regards,
    Wah Meng

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 22, 2012

    New changeset b4f6cd5f9ab7 by Stefan Krah in branch '2.7':
    Issue bpo-13057: Include stdio.h when NULL is used in configure.ac.
    http://hg.python.org/cpython/rev/b4f6cd5f9ab7

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 22, 2012

    New changeset f0baa6be2bf1 by Stefan Krah in branch '3.3':
    Issue bpo-13057: Include stdio.h when NULL is used in configure.ac.
    http://hg.python.org/cpython/rev/f0baa6be2bf1

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Nov 22, 2012

    Fixed in 2.7, 3.3 and 3.4.

    @skrah skrah mannequin closed this as completed Nov 22, 2012
    @py-user
    Copy link
    Mannequin

    py-user mannequin commented Jan 18, 2013

    found a redundant code (stdlib.h already defines the NULL macro)

    commit e33747a4b1a45acdd696a4e07bbd40ea7fb37366
    Author: Stefan Krah <skrah@bytereef.org>
    Date: Thu Nov 22 22:49:11 2012 +0100

    Issue bpo-13057: Include stdio.h when NULL is used in configure.ac.
    
    --HG--
    branch : 3.3
    

    diff --git a/configure b/configure
    index 4a861ed..534c8df 100755
    --- a/configure
    +++ b/configure

    ...

    @@ -14833,6 +14834,7 @@ else
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     /* end confdefs.h.  */
     
    +#include <stdio.h>
     #include<stdlib.h>
     int main() {
         size_t len = -1;

    @py-user
    Copy link
    Mannequin

    py-user mannequin commented Jan 18, 2013

    the hunk is from commit

    commit b2edc2629f5e0f11280ba9846d1a86346f4a7287
    Author: Stefan Krah <skrah@bytereef.org>
    Date: Thu Nov 22 23:47:32 2012 +0100

    Fix more usages of NULL without including stdio.h.
    
    --HG--
    branch : 3.3
    

    @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
    build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants