python / cpython

The Python programming language
https://www.python.org
Other
62.47k stars 29.99k forks source link

semaphore errors from Python 2.3.x on AIX 5.2 #41470

Closed 8f065f23-baaa-41a2-8744-151add8ffc2c closed 16 years ago

8f065f23-baaa-41a2-8744-151add8ffc2c commented 19 years ago
BPO 1106262
Nosy @akuchling

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: ```python assignee = None closed_at = created_at = labels = [] title = 'semaphore errors from Python 2.3.x on AIX 5.2' updated_at = user = 'https://bugs.python.org/tww-china' ``` bugs.python.org fields: ```python activity = actor = 'akuchling' assignee = 'none' closed = True closed_date = closer = 'akuchling' components = ['None'] creation = creator = 'tww-china' dependencies = [] files = [] hgrepos = [] issue_num = 1106262 keywords = [] message_count = 3.0 messages = ['60639', '60640', '62575'] nosy_count = 3.0 nosy_names = ['akuchling', 'tww-china', 'lim_1'] pr_nums = [] priority = 'normal' resolution = 'duplicate' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue1106262' versions = [] ```

8f065f23-baaa-41a2-8744-151add8ffc2c commented 19 years ago

Newer versions of the AIX 5.2 libc implement POSIX semaphores and thus define _POSIX_SEMAPHORES in \<unistd.h>. However, when building Python 2.3.x (and I'm sure any other version with sem_init()), a few semaphore errors are encountered: building 'pcre' extension ./Modules/ld_so_aix gcc -bI:Modules/python.exp \ -L/opt/TWWfsw/python232/lib/support -Wl,-brtl \

-Wl,-blibpath:/opt/TWWfsw/python232/lib/support:/usr/lib \ build/temp.aix-5.2-2.3/pcremodule.o \ build/temp.aix-5.2-2.3/pypcre.o -L/opt/TWWfsw/python232/lib \ -o build/lib.aix-5.2-2.3/pcre.so sem_trywait: Permission denied sem_wait: Permission denied sem_post: Permission denied

I ran the Python process under truss and saw that the sem_init() from Python/thread_pthread.h worked successfully. fork() was then called and a sem_trywait() operation (probably from PyThread_acquire_lock()) was called. From the sem_init() man page (http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.aix.doc/libs/basetrf2/sem_init.htm): If the pshared parameter has a nonzero value, the semaphore is shared between processes. In this case, any process that can access the sem parameter can use it for performing sem_wait, sem_trywait, sem_post, and sem_destroy operations.

Only the sem parameter itself may be used for performing synchronization.

If the pshared parameter is zero, the semaphore is shared between threads of the process. Any thread in this process can use the sem parameter for performing sem_wait, sem_trywait, sem_post, and sem_destroy operations. The use of the semaphore by threads other than those created in the same process returns an error.

Setting the 2nd value of sem_init to 1 (was 0) solved the problem. However, I don't know if this is wise for security. Another solution is to set HAVE_BROKEN_POSIX_SEMAPHORES for "AIX/5" like for "SunOS/5.8".

6455ee23-f923-43b5-98c2-96b4fe1749fd commented 19 years ago

Logged In: YES user_id=701470

I can confirm this problem. I am using scons to build my project on AIX. I could not run parallel builds (-j4) on AIX. Randomly, but very often xlC invocation would stuck and I have 4 xlCcode hanging and taking all CPUs.

After adding HAVE_BROKEN_POSIX_SEMAPHORES for AIX and rebuilding Python parallel builds on AIX are fine. Trying first fix with changing 0 to 1 in sem_init also resolved this problem, but I started to get some other unexplained error from scons, so had to deactivate semaphores all together.

Albert, thanks for this report, it helped a lot.

akuchling commented 16 years ago

Fixed for bug bpo-1234.