Skip to content

catch exception in coroutine on windows produces segfault #153949

@kelbon

Description

@kelbon

I created pr with reproducing bug, its producing segfault (only on windows)

kelbon/kelcoro#48

dd::task<int> foo1(int i) try {
  abc c;
  for (;;) {
    if (i == 42)
      co_return 0;
    co_await std::suspend_always{};

    try {
      bar(c);
      break;
    } catch (std::exception& e) {
      // here `e` already dead, 
      std::cout << '"' << e.what() << '"';
    }
  }
  throw "";
} catch (...) {
  co_return 0;
}

Notes:
memory where exception allocated is dead when catch block starts.

Its important that break in the try block, even if it is switch break, not break for for loop

Access violation reading location 0xFFFFFFFFFFFFFFFF.

corotuine:

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions