folly
folly copied to clipboard
tcache_thread_shutdown(): unaligned tcache chunk detected
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)