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

tcache_thread_shutdown(): unaligned tcache chunk detected #2359

Open
michaelaeriksen opened this issue Dec 30, 2024 · 2 comments
Open

tcache_thread_shutdown(): unaligned tcache chunk detected #2359

michaelaeriksen opened this issue Dec 30, 2024 · 2 comments

Comments

@michaelaeriksen
Copy link

michaelaeriksen commented Dec 30, 2024

When executing this with ubuntu + gcc I get a segfault. The exact same code works fine with Windows + Visual studio and Mac + clang. I have tried with gcc 13 and gcc 14 and they both generates the segfault below.

#include <folly/init/Init.h>
#include <folly/experimental/coro/Task.h>
#include <folly/experimental/coro/Sleep.h>
#include <folly/experimental/coro/BlockingWait.h>
#include <folly/experimental/coro/Timeout.h>

#include <iostream>
#include <chrono>

using namespace std::literals;

folly::coro::Task<void> TestFolly1()
{
  std::cout << "TestFolly1" << std::endl;
  co_await folly::coro::sleep(1s);
  co_return;
}

folly::coro::Task<void> Loop()
{
  folly::CancellationCallback onCancel{ co_await folly::coro::co_current_cancellation_token, []() noexcept
    {
      std::cerr << "Loop Canceled" << std::endl;
    } };

  auto token = co_await folly::coro::co_current_cancellation_token;
  while (not token.isCancellationRequested())
  {
    co_await folly::coro::sleep(1s);
  }

  co_return;
}

folly::coro::Task<bool> TestFolly2()
{
  std::cout << "TestFolly2" << std::endl;

  co_await folly::coro::co_awaitTry(folly::coro::timeout(Loop(), 2s));
  co_return true;
}

void TestFolly()
{
  std::cout << "Start Test" << std::endl;
  folly::coro::blockingWait(TestFolly1().scheduleOn(folly::getGlobalCPUExecutor().get()));
  folly::coro::blockingWait(TestFolly2().scheduleOn(folly::getGlobalCPUExecutor().get()));
  std::cout << "End Test" << std::endl;
}

int main(int argc, char* argv[])
{
  folly::Init init(&argc, &argv);

  TestFolly();

  std::cout << "End Main" << std::endl;

  return 0;
}

The error is

Start Test
TestFolly1
TestFolly2
Loop Canceled
End Test
End Main
tcache_thread_shutdown(): unaligned tcache chunk detected
*** Aborted at 1735518039 (Unix time, try 'date -d @1735518039') ***
*** Signal 6 (SIGABRT) (0x3e8000afb6d) received by PID 719725 (pthread TID 0x791861e00640) (linux TID 719727) (maybe from PID 719725, UID 1000) (code: -6), stack trace: ***
./folly_tool[0x66785d]
./folly_tool[0x5d898b]
./folly_tool[0x5d6d63]
./folly_tool[0x5d6e23]
/lib/x86_64-linux-gnu/libc.so.6(+0x4251f)[0x791862a4251f]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x12c)[0x791862a969fc]
/lib/x86_64-linux-gnu/libc.so.6(raise+0x15)[0x791862a42475]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xd2)[0x791862a287f2]
/lib/x86_64-linux-gnu/libc.so.6(+0x89675)[0x791862a89675]
/lib/x86_64-linux-gnu/libc.so.6(+0xa0cfb)[0x791862aa0cfb]
/lib/x86_64-linux-gnu/libc.so.6(+0xa56c3)[0x791862aa56c3]
/lib/x86_64-linux-gnu/libc.so.6(+0x9494e)[0x791862a9494e]
/lib/x86_64-linux-gnu/libc.so.6(+0x12684f)[0x791862b2684f]
(safe mode, symbolizer not available)
Aborted (core dumped)
@michaelaeriksen
Copy link
Author

Looks like a regression or API change after release 2024.07.01

The sample code above works until v2024.07.01.00 after that it fails with a segfault

v2024.05.02.00 - works
v2024.06.03.00 - works
v2024.07.01.00 - works
v2024.07.08.00 - fails
v2024.07.15.00 - fails
v2024.07.22.00 - fails
v2024.07.29.00 - fails
v2024.08.05.00 - fails
v2024.12.16.00 - fails

@Ko496-glitch
Copy link

Hi, I am getting started on open source contribution. I believe i can take on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants