rocr: Fix asyncHandler segfault (#2261)

Fix initialization order for the async events handler. The polling
thread would launch before the wake signal is initialized.
Este commit está contenido en:
David Yat Sin
2025-12-17 23:52:20 -05:00
cometido por GitHub
padre 96f6b6e251
commit 5ebd50c0b4
Se han modificado 2 ficheros con 21 adiciones y 15 borrados
@@ -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()