boostorg / process

Boost Process
https://www.boost.org/libs/process
117 stars 116 forks source link

boost::process:child constructor segmentation fault when passed an empty string #209

Open bee-rock opened 3 years ago

bee-rock commented 3 years ago

You can demonstrate this on the Wandbox online compiler using gcc 11.1.0 and c++11:

# prog.cc
#include <boost/process.hpp>
#include <system_error>

int main(){
    try {
        boost::process::child("");
    } catch(const std::system_error& e) {
    }
}
 g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.76.0/gcc-11.1.0/include -std=c++11

Start
Segmentation fault
Finish

The documentation on https://www.boost.org/doc/libs/1_76_0/doc/html/boost_process/tutorial.html#boost_process.tutorial.error_handling leads me to believe that this case should throw a std::system_error rather than segfault.

ArielSilver commented 1 year ago

@klemens-morgenstern This is still happening. The line: boost::process::child(""); causes the following: image

Of course such scenario should fail, but I don't think it should cause a segmentation fault. I think it should fail in the executer.hpp after a failed execv (In linux). Regarding Windows I will find a similar solution.

Do you want me to create a pull request for this?