View Issue Details

IDProjectCategoryView StatusLast Update
0015679CentOS-7glibcpublic2019-01-08 19:36
Reporterfgasper 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version7.6.1810 
Target VersionFixed in Version 
Summary0015679: posix_spawnp doesn’t indicate exec() failure
Descriptionposix_spawnp(3) states:

       If posix_spawn() or posix_spawnp() fail for any of the reasons that
       would cause fork() or one of the exec family of functions to fail, an
       error value shall be returned as described by fork() and exec, respec‐
       tively (or, if the error occurs after the calling process successfully
       returns, the child process shall exit with exit status 127).

When the exec() part of posix_spawnp() fails, however, no error value is reported.

Consider the following, which demonstrates the unreported failure from posix_spawnp() as well as how it can work with direct vfork/exec:
-----
#include <spawn.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>

extern char **environ;

int main(int argc, char *argv[]) {
    pid_t cpid;
    const char *path = "/is/not/there/hahahaha";

    int sub_errno;

    sub_errno = posix_spawnp( &cpid, path, NULL, NULL, argv, environ );

    printf("errno from posix_spawnp: %d\n", sub_errno);

    cpid = vfork();

    if (!cpid) {
        execve(path, argv, environ);
        sub_errno = errno;
        _exit(127);
    }

    printf("errno from direct vfork/execve: %d\n", sub_errno);

    return 0;
}
-----
Steps To ReproduceWrite a program similar to what I pasted above.
Additional Informationvfork(2) stipulates that behavior is undefined if the child process does things like modify a variable in the parent process, but that seems to be the only way to satisfy the definition of posix_spawnp(). That definition provides for exit(127) but only in cases where the error occurs after the calling process returns from posix_spawnp(). That’s not the case with vfork(), which blocks until execve() either succeeds or fails.
TagsNo tags attached.
abrt_hash
URL

Activities

TrevorH

TrevorH

2019-01-08 19:34

manager   ~0033541

CentOS is a rebuild of RHEL from the same source with only RH branding and logos removed. If you can recreate this problem on RHEL then you need to raise a bug on bugzilla.redhat.com to get them to fix it in RHEL.
fgasper

fgasper

2019-01-08 19:36

reporter   ~0033543

I don’t have access to RHEL but will go ahead and file there.

Issue History

Date Modified Username Field Change
2019-01-08 19:23 fgasper New Issue
2019-01-08 19:34 TrevorH Note Added: 0033541
2019-01-08 19:36 fgasper Note Added: 0033543