Skip to content

Commit

Permalink
Fix crash in urAdapterGet with non-initialized platforms
Browse files Browse the repository at this point in the history
Encountered in a bothched ASAN build, but makes sense to check platform
status before trying to query it.
  • Loading branch information
al42and authored and kbenzie committed Apr 22, 2024
1 parent 717791b commit 200e628
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/templates/ldrddi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace ur_loader
{
for( auto& platform : context->platforms )
{
if(platform.initStatus != ${X}_RESULT_SUCCESS)
continue;
platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( 1, &${obj['params'][1]['name']}[adapterIndex], nullptr );
try
{
Expand Down
3 changes: 3 additions & 0 deletions source/loader/ur_ldrddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet(
size_t adapterIndex = 0;
if (nullptr != phAdapters && NumEntries != 0) {
for (auto &platform : context->platforms) {
if (platform.initStatus != UR_RESULT_SUCCESS) {
continue;
}
platform.dditable.ur.Global.pfnAdapterGet(
1, &phAdapters[adapterIndex], nullptr);
try {
Expand Down

0 comments on commit 200e628

Please sign in to comment.