Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault in hsa_init on non-HSA platforms #11

Open
r-potter opened this issue Jan 12, 2016 · 2 comments
Open

Segfault in hsa_init on non-HSA platforms #11

r-potter opened this issue Jan 12, 2016 · 2 comments

Comments

@r-potter
Copy link

Prior to 1.0.3, calling hsa_init() on a non-HSA platform (such as an Intel CPU) was well behaved. I believe the behaviour was that hsa_init() succeeded, but that the runtime would report no agents or regions to the hsa_iterate_*.

With the 1.0.3 release, hsa_init segfaults. This is due to this line:

// Setup system region allocator.
if (reinterpret_castamd::MemoryRegion*(
core::MemoryRegion::Convert(system_region_))->fine_grain()) {

On non-HSA platforms, system_region_.handle == 0, so the call to fine_grain() dereferences a null pointer.

Having hsa_init() fail cleanly, or restoring the previous behaviour, where hsa_init() succeeds, but no agents and regions are reported would be preferable to a segfault.

It appears that simply adding a check for a null system_region_ restores this behaviour.

runtime.patch.txt

@tschwinge
Copy link

Confirming the problem (master branch: commit 576359e "HSA 1.0.3 Source"):

[...]
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff564e579 in core::Runtime::Load() () from [...]/libhsa-runtime64.so.1
(gdb) bt
#0  0x00007ffff564e579 in core::Runtime::Load() () from [...]/libhsa-runtime64.so.1
#1  0x00007ffff564d0ee in core::Runtime::Acquire() () from [...]/libhsa-runtime64.so.1
#2  0x00007ffff563910a in HSA::hsa_init() () from [...]/libhsa-runtime64.so.1
#3  0x00007ffff565e074 in hsa_init () from [...]/libhsa-runtime64.so.1
[...]

..., and that the patch posted by @r-potter, resolves this.

@jedwards-AMD
Copy link
Contributor

This will be fixed in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants