Missing return statements in file default_launcher.hpp cause an 'illegal instruction'

Open
#527 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp

Research direction

Open boost/process/v2/posix/default_launcher.hpp and inspect invoke_on_success, invoke_on_error, invoke_on_fork_error, and invoke_on_exec_error. Confirm that each function's declared return type matches its callback, then ensure all four callback results are returned and verify the reported illegal-instruction crash no longer occurs.

Written by the indexing model from the issue text.

Description

In boost/process/v2/posix/default_launcher.hpp there is a template function invoke_on_success defined as

template<typename Launcher, typename Init>
inline auto invoke_on_success(Launcher & launcher, const filesystem::path &executable,
                              const char * const * (&cmd_line),
                              Init && init, derived && )
-> decltype(init.on_success(launcher, executable, cmd_line))
{
      init.on_success(launcher, executable, cmd_line);
}

This function is supposed to have a return value, but a return statement is missing. This causes (on my installation, using recent versions of both g++ and clang++) an 'illegal instruction' followed by an inevitable crash.

Adding a return statement solved the problem:

template<typename Launcher, typename Init>
inline auto invoke_on_success(Launcher & launcher, const filesystem::path &executable,
                              const char * const * (&cmd_line),
                              Init && init, derived && )
-> decltype(init.on_success(launcher, executable, cmd_line))
{
      return init.on_success(launcher, executable, cmd_line);
}

The same problem occurs (in the same file default_launcher.hpp) with the routines
invoke_on_error, invoke_on_fork_error and invoke_on_exec_error

Dominant language
C++
Stars
145
Forks
151
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/process

All issues in boostorg/process

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.