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

TF_DISABLE_EXCEPTION_HANDLING does not disable all exceptions #565

Open
pavanakumar opened this issue Mar 25, 2024 · 0 comments
Open

TF_DISABLE_EXCEPTION_HANDLING does not disable all exceptions #565

pavanakumar opened this issue Mar 25, 2024 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@pavanakumar
Copy link

When compiling with -fno-exceptions and explicitly specifying TF_DISABLE_EXCEPTION_HANDLING before including the header even the simple example does not compile.

TF_DISABLE_EXCEPTION_HANDLING
#include <taskflow/taskflow.hpp>

int main(int nargs, char *args[]) {
  tf::Executor executor;
  tf::Taskflow taskflow("simple");

  auto [A, B, C, D] = taskflow.emplace([]() { std::cout << "TaskA\n"; },
                                       []() { std::cout << "TaskB\n"; },
                                       []() { std::cout << "TaskC\n"; },
                                       []() { std::cout << "TaskD\n"; });

  A.precede(B, C); // A runs before B and C
  D.succeed(B, C); // D runs after  B and C

  executor.run(taskflow).wait();

  return 0;
}

It looks like there are only two places that needs replacement (master branch)

In file taskflow/core/error.h line 20

template <typename... ArgsT>
//void throw_se(const char* fname, const size_t line, Error::Code c, ArgsT&&... args) {
void throw_re(const char* fname, const size_t line, ArgsT&&... args) {
  std::ostringstream oss;
  oss << "[" << fname << ":" << line << "] ";
  //ostreamize(oss, std::forward<ArgsT>(args)...);
  (oss << ... << args);
  throw std::runtime_error(oss.str());
}

and in taskflow/utility/object_pool.hpp line no 629

    else {
      //printf("create a new superblock\n");
      _gheap.mutex.unlock();
      f = 0;
      //s = static_cast<Block*>(std::malloc(sizeof(Block)));
      s = new Block();

      if(s == nullptr) {
        throw std::bad_alloc();
      }

Once they are made to respect TF_DISABLE_EXCEPTION_HANDLING the example compiles. Is it not possible to compile taskflow without exception safety?

@tsung-wei-huang tsung-wei-huang added the help wanted Extra attention is needed label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants