rocr: Fix asyncHandler segfault (#2261)

Fix initialization order for the async events handler. The polling
thread would launch before the wake signal is initialized.
このコミットが含まれているのは:
David Yat Sin
2025-12-17 23:52:20 -05:00
committed by GitHub
コミット 5ebd50c0b4
2個のファイルの変更21行の追加15行の削除
+11 -7
ファイルの表示
@@ -569,12 +569,16 @@ class Runtime {
struct AsyncEventsInfo;
struct AsyncEventsControl {
AsyncEventsControl(AsyncEventsInfo *asyncInfo);
void Start();
void Shutdown();
hsa_signal_t wake;
os::Thread thread_;
bool exit;
};
private:
AsyncEventsInfo* info_;
os::Thread thread_;
};
struct AsyncEvents {
void PushBack(hsa_signal_t signal, hsa_signal_condition_t cond,
@@ -682,13 +686,13 @@ class Runtime {
};
struct AsyncEventsInfo {
bool monitor_exceptions;
AsyncEventsControl control;
AsyncEvents events;
ConcurrentAsyncEvents new_events;
AsyncEventsInfo(bool exceptions);
~AsyncEventsInfo();
bool monitor_exceptions;
AsyncEvents events;
ConcurrentAsyncEvents new_events;
AsyncEventsControl control;
};
struct PrefetchRange;
+10 -8
ファイルの表示
@@ -2314,9 +2314,10 @@ void Runtime::PrintMemoryMapNear(void* ptr) {
}
Runtime::AsyncEventsInfo::AsyncEventsInfo(bool exceptions_)
: control(this), events(), new_events(), monitor_exceptions(exceptions_) {
: monitor_exceptions(exceptions_), events(), new_events(), control(this) {
events.PushBack(control.wake, HSA_SIGNAL_CONDITION_NE, 0, NULL, NULL);
control.Start();
}
Runtime::AsyncEventsInfo::~AsyncEventsInfo() {
@@ -2324,19 +2325,20 @@ Runtime::AsyncEventsInfo::~AsyncEventsInfo() {
}
Runtime::AsyncEventsControl::AsyncEventsControl(AsyncEventsInfo *asyncInfo)
: exit(false) {
int priority = asyncInfo->monitor_exceptions ? os::OS_THREAD_PRIORITY_DEFAULT :
runtime_singleton_->flag().async_events_thread_priority();
: info_(asyncInfo), exit(false) {
auto err = HSA::hsa_signal_create(0, 0, NULL, &wake);
if (err != HSA_STATUS_SUCCESS)
throw AMD::hsa_exception(HSA_STATUS_ERROR, "Failed to allocate async handler signal");
}
asyncInfo->control.thread_ = os::CreateThread(AsyncEventsLoop, asyncInfo, 0, priority);
if (!asyncInfo->control.thread_)
void Runtime::AsyncEventsControl::Start() {
int priority = info_->monitor_exceptions ? os::OS_THREAD_PRIORITY_DEFAULT :
runtime_singleton_->flag().async_events_thread_priority();
thread_ = os::CreateThread(AsyncEventsLoop, info_, 0, priority);
if (!thread_)
throw AMD::hsa_exception(HSA_STATUS_ERROR, "Failed to initialize async handler thread");
}
Runtime::Runtime()