Skip to content

Commit 7d088d8

Browse files
committed
Fix multiprocessing spawn on Darwin
1 parent 805a501 commit 7d088d8

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/SemLockBuiltins.java‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,12 @@ static PNone release(VirtualFrame frame, PSemLock self,
225225
}
226226
} catch (UnsupportedPosixFeatureException e) {
227227
/* We will only check properly the maxvalue == 1 case */
228-
if (posixLib.semTryWait(posixSupport, self.getHandle())) {
229-
/* it was not locked so undo wait and raise */
230-
posixLib.semPost(posixSupport, self.getHandle());
231-
throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SEMAPHORE_RELEASED_TOO_MANY_TIMES);
228+
if (self.getMaxValue() == 1) {
229+
if (posixLib.semTryWait(posixSupport, self.getHandle())) {
230+
/* it was not locked so undo wait and raise */
231+
posixLib.semPost(posixSupport, self.getHandle());
232+
throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SEMAPHORE_RELEASED_TOO_MANY_TIMES);
233+
}
232234
}
233235
}
234236
} catch (PosixException e) {

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PosixConstantsDarwin.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
*/
4141
package com.oracle.graal.python.runtime;
4242

43-
// Auto generated by gen_native_cfg.py at 2023-05-26 18:57:33.815121
44-
// on Darwin ol-mac-mini2-prague.cz.oracle.com 21.6.0 Darwin Kernel Version 21.6.0: Mon Apr 24 21:10:53 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_X86_64 x86_64 i386
43+
// Auto generated by gen_native_cfg.py at 2023-10-26 12:57:29.030972
44+
// on Darwin ol-mac-mini2-prague.cz.oracle.com 21.6.0 Darwin Kernel Version 21.6.0: Wed Oct 4 23:55:28 PDT 2023; root:xnu-8020.240.18.704.15~1/RELEASE_X86_64 x86_64 i386
4545
class PosixConstantsDarwin {
4646

4747
private PosixConstantsDarwin() {
@@ -68,6 +68,7 @@ static void getConstants(PosixConstants.Registry constants) {
6868
constants.put("SEEK_HOLE", 3);
6969
constants.put("SOMAXCONN", 128);
7070
constants.put("PIPE_BUF", 512);
71+
constants.put("SEM_VALUE_MAX", 32767);
7172
constants.put("O_ACCMODE", 0x00000003);
7273
constants.put("O_RDONLY", 0x00000000);
7374
constants.put("O_WRONLY", 0x00000001);

‎graalpython/python-libposix/src/posix.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ int64_t call_crypt(const char *word, const char *salt, int32_t *len) {
903903

904904
int64_t call_sem_open(const char *name, int32_t openFlags, int32_t mode, int32_t value) {
905905
sem_t* result = sem_open(name, openFlags, mode, value);
906-
if (result == SEM_FAILED) {
906+
if (result == (sem_t*)SEM_FAILED) {
907907
return -1;
908908
}
909909
return (int64_t)(uintptr_t)result;

‎scripts/gen_native_cfg.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
# include <sys/utsname.h>
8484
# include <sys/wait.h>
8585
# include <sysexits.h>
86+
# include <semaphore.h>
8687
#else
8788
# include <winsock2.h>
8889
# include <ws2tcpip.h>

0 commit comments

Comments
 (0)