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

Dynamically loading libjulia with SIGCHLD ignored causes error waitpid: No child processes #57240

Closed
topolarity opened this issue Feb 3, 2025 · 5 comments · Fixed by #57241
Closed

Comments

@topolarity
Copy link
Member

#include <dlfcn.h>
#include <stdio.h>
#include <signal.h>

int main(int argc, char *argv[])
{
    signal(SIGCHLD, SIG_IGN);
    void *handle = dlopen(LIBJULIA_PATH, RTLD_LAZY);
    return 0;
}
$ gcc -fPIC testjulia.c -DLIBJULIA_PATH="`pwd`/usr/lib/libjulia.so"
$ ./a.out
Error during libstdcxxprobe in parent process:
waitpid: No child processes
topolarity added a commit to topolarity/julia that referenced this issue Feb 3, 2025
topolarity added a commit to topolarity/julia that referenced this issue Feb 3, 2025
topolarity added a commit to topolarity/julia that referenced this issue Feb 3, 2025
@vtjnash
Copy link
Member

vtjnash commented Feb 3, 2025

Ignoring SIGCHLD makes it invalid to spawn child processes. This is a unix feature and not something julia can change.

@vtjnash vtjnash closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2025
@topolarity
Copy link
Member Author

Ignoring SIGCHLD makes it invalid to spawn child processes. This is a unix feature and not something julia can change.

Julia should support running basic programs without needing to spawn child processes then.

@topolarity
Copy link
Member Author

Or notice that SIGCHLD is ignored and back off from probing libstdc++ incorrectly

@topolarity topolarity reopened this Feb 3, 2025
@vtjnash
Copy link
Member

vtjnash commented Feb 3, 2025

Or just don't block SIGCHLD? There are a lot of ways to set up an invalid configuration which we will not support.

@topolarity
Copy link
Member Author

Or just don't block SIGCHLD? There are a lot of ways to set up an invalid configuration which we will not support.

We at least need a better error message IMO, since this is a report from a real situation in the wild.

We're trying to provide a good experience for using Julia-compiled versions of "simple" libraries whose C equivalents do not have so many of these "poorly composing" constraints around signals, thread lifetimes, etc. and trying to minimize that surface area (or else document/guard where it cannot be shrunk) is important, I think .

topolarity added a commit that referenced this issue Feb 4, 2025
…57241)

The `fork()` we do here relies on `SIGCHLD` to make sure that we don't
race against the child.

This is easy to see in an embedding application that dynamically links
`libjulia`:
```c
int main(int argc, char *argv[])
{
    signal(SIGCHLD, SIG_IGN);
    void *handle = dlopen("path/to/libjulia.so", RTLD_LAZY);
    return 0;
}
```

Without this change, this fails with an error message:
```
Error during libstdcxxprobe in parent process:
waitpid: No child processes
```

Resolves #57240
KristofferC pushed a commit that referenced this issue Feb 6, 2025
…57241)

The `fork()` we do here relies on `SIGCHLD` to make sure that we don't
race against the child.

This is easy to see in an embedding application that dynamically links
`libjulia`:
```c
int main(int argc, char *argv[])
{
    signal(SIGCHLD, SIG_IGN);
    void *handle = dlopen("path/to/libjulia.so", RTLD_LAZY);
    return 0;
}
```

Without this change, this fails with an error message:
```
Error during libstdcxxprobe in parent process:
waitpid: No child processes
```

Resolves #57240

(cherry picked from commit daf865e)
KristofferC pushed a commit that referenced this issue Feb 6, 2025
…57241)

The `fork()` we do here relies on `SIGCHLD` to make sure that we don't
race against the child.

This is easy to see in an embedding application that dynamically links
`libjulia`:
```c
int main(int argc, char *argv[])
{
    signal(SIGCHLD, SIG_IGN);
    void *handle = dlopen("path/to/libjulia.so", RTLD_LAZY);
    return 0;
}
```

Without this change, this fails with an error message:
```
Error during libstdcxxprobe in parent process:
waitpid: No child processes
```

Resolves #57240

(cherry picked from commit daf865e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants