This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Thread not working for python 2.7.1 built with HP Compiler on HP-UX 11.31 ia64
Type: compile error Stage: resolved
Components: Build Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, georg.brandl, py.user, python-dev, skrah, trent, wah meng
Priority: normal Keywords: patch

Created on 2011-09-29 02:38 by wah meng, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue-13057.diff skrah, 2011-09-29 19:45
Messages (24)
msg144584 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-29 02:38
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 #3696-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 #3696-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
msg144586 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2011-09-29 07:30
> 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?
msg144587 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-29 09:27
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 #2223-D: function "exit" declared implicitly
  void * start_routine (void *arg) { exit (0); }
                                     ^

"conftest.c", line 102: error #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>
_______________________________________
msg144622 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2011-09-29 19:45
To me this looks like stdio.h should be included as well. Could
you try the patch?
msg144660 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-30 03:33
Hello Stefan,

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

Regards,
Wah Meng
msg144662 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-09-30 04:04
"patch -p1 < issue-13057.diff" in the directory where configure is should do the trick.
msg144664 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-30 04:16
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
msg144665 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-09-30 04:20
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".
msg144666 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-30 04:38
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
msg144667 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-30 05:23
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
msg144668 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-09-30 05:29
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.
msg144669 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-30 05:41
Thank goodness. Let me try. 

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
msg144670 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-30 05:45
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
msg144671 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-09-30 05:45
After the one at line 8620.
msg144672 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-30 06:04
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
msg144675 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-09-30 06:33
Could you please stop putting these unrelated links into your posts? It is really annoying. Thanks.
msg144678 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-30 08:44
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
msg144685 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2011-09-30 11:18
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.
msg144686 - (view) Author: Wong Wah Meng (wah meng) Date: 2011-09-30 11:26
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
msg176127 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-22 21:38
New changeset b4f6cd5f9ab7 by Stefan Krah in branch '2.7':
Issue #13057: Include stdio.h when NULL is used in configure.ac.
http://hg.python.org/cpython/rev/b4f6cd5f9ab7
msg176128 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-22 21:59
New changeset f0baa6be2bf1 by Stefan Krah in branch '3.3':
Issue #13057: Include stdio.h when NULL is used in configure.ac.
http://hg.python.org/cpython/rev/f0baa6be2bf1
msg176134 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-11-22 22:25
Fixed in 2.7, 3.3 and 3.4.
msg180174 - (view) Author: py.user (py.user) * Date: 2013-01-18 05:13
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 #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;
msg180175 - (view) Author: py.user (py.user) * Date: 2013-01-18 05:22
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
History
Date User Action Args
2022-04-11 14:57:22adminsetgithub: 57266
2013-01-18 05:22:35py.usersetmessages: + msg180175
2013-01-18 05:20:15trentsetnosy: + trent
2013-01-18 05:13:03py.usersetnosy: + py.user
messages: + msg180174
2012-11-22 22:25:01skrahsetstatus: open -> closed
resolution: fixed
messages: + msg176134

stage: needs patch -> resolved
2012-11-22 21:59:01python-devsetmessages: + msg176128
2012-11-22 21:38:11python-devsetnosy: + python-dev
messages: + msg176127
2011-09-30 11:26:14wah mengsetmessages: + msg144686
2011-09-30 11:18:13skrahsetstatus: closed -> open
versions: + Python 3.1, Python 2.7, Python 3.2, Python 3.3
messages: + msg144685

components: + Build
type: compile error
stage: needs patch
2011-09-30 10:46:07wah mengsetstatus: open -> closed
2011-09-30 08:44:45wah mengsetmessages: + msg144678
2011-09-30 06:33:14georg.brandlsetnosy: + georg.brandl
messages: + msg144675
2011-09-30 06:04:26wah mengsetmessages: + msg144672
2011-09-30 05:45:59ezio.melottisetmessages: + msg144671
2011-09-30 05:45:02wah mengsetmessages: + msg144670
2011-09-30 05:41:44wah mengsetmessages: + msg144669
2011-09-30 05:29:28ezio.melottisetmessages: + msg144668
2011-09-30 05:23:50wah mengsetmessages: + msg144667
2011-09-30 04:38:16wah mengsetmessages: + msg144666
2011-09-30 04:20:40ezio.melottisetmessages: + msg144665
2011-09-30 04:16:02wah mengsetmessages: + msg144664
2011-09-30 04:04:15ezio.melottisetnosy: + ezio.melotti
messages: + msg144662
2011-09-30 03:33:25wah mengsetmessages: + msg144660
2011-09-29 19:45:30skrahsetfiles: + issue-13057.diff
keywords: + patch
messages: + msg144622
2011-09-29 09:27:48wah mengsetmessages: + msg144587
2011-09-29 07:30:54skrahsetnosy: + skrah
messages: + msg144586
2011-09-29 02:38:37wah mengcreate