Skip to content
This repository was archived by the owner on Jun 23, 2026. It is now read-only.
This repository was archived by the owner on Jun 23, 2026. It is now read-only.

looping through all devices causes pthread_detach to segfault #101

Description

@psteinb

Hi - I am trying to contribute a stream benchmark using HCC
psteinb/GPU-STREAM/tree/hcc
I got the code to compile, but a simple loop through all devices

void listDevices(void)
{
  // Get number of devices
  std::vector<hc::accelerator> accs = hc::accelerator::get_all();

  // Print device names
  if (accs.empty())
  {
    std::cerr << "No devices found." << std::endl;
  }
  else
  {
    std::cout << std::endl;
    std::cout << "Devices:" << std::endl;
    for (int i = 0; i < accs.size(); i++)
    {
      std::cout << i << ": " << getDeviceName(accs[i]) << std::endl;
    }
    std::cout << std::endl;
  }
}

causes a segfault that originates in Kalmar::HSAContext::~HSAContext:

(ROCm-gdb) bt
#0  0x00007ffff7480545 in pthread_detach () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007fffeeadc204 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime-tools64.so.1
#2  0x00007fffeeadd12e in OnUnload () from /opt/rocm/hsa/lib/libhsa-runtime-tools64.so.1
#3  0x00007ffff669a162 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1
#4  0x00007ffff669a24c in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1
#5  0x00007ffff669a488 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1
#6  0x00007ffff669028f in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1
#7  0x00007fffee6db253 in HsaDebugAgent_hsa_shut_down () at HSAIntercept.cpp:49
#8  0x00007ffff6a80bd1 in Kalmar::HSAContext::~HSAContext() () from /opt/rocm/hcc-lc/lib/libmcwamp_hsa.so
#9  0x00007ffff6ed8259 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#10 0x00007ffff6ed82a5 in exit () from /lib/x86_64-linux-gnu/libc.so.6
#11 0x000000000040ebc5 in parseArguments (argc=2, argv=0x7fffffffe428) at /home/steinb95/development/gpu_stream/main.cpp:279
#12 0x000000000040ea78 in main (argc=2, argv=0x7fffffffe428) at /home/steinb95/development/gpu_stream/main.cpp:63

listDevices is called by parseArguments in main.cpp:279. What am I missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions