Skip to content

blender: fix segfault when using both HIP and OSL#504149

Closed
frozolotl wants to merge 1 commit into
NixOS:masterfrom
frozolotl:blender_fix-hip-osl-segfault
Closed

blender: fix segfault when using both HIP and OSL#504149
frozolotl wants to merge 1 commit into
NixOS:masterfrom
frozolotl:blender_fix-hip-osl-segfault

Conversation

@frozolotl

Copy link
Copy Markdown
Contributor

This PR fixes an issue where enabling both ROCm and OpenShadingLanguage in Blender causes Blender to crash when performing a Cycles render.

Blender dlopens HIP, which is dynamically linked to rocm-comgr, which in turn links ROCm's libLLVM.
But then, Blender dynamically links OpenShadingLanguage, which links libLLVM 19.
And so, when HIP is invoked, it transitively calls ROCm's libLLVM, which then—due to symbol conflicts—calls functions in libLLVM 19.
One of those functions then dereferences a null pointer, causing a segfault in the process.

Switching out dlopen with dlmopen separates the namespaces of the two libLLVMs, fixing the issue.

If anyone wants to find a better solution, I'll mention that simply using the same version of LLVM for both ROCm and OpenShadingLanguage causes different issues because then libLLVM is initialized twice.

The bug was also mentioned in #502842.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@frozolotl frozolotl mentioned this pull request Mar 27, 2026
13 tasks
@nixpkgs-ci nixpkgs-ci Bot requested review from amarshall and veprbl March 27, 2026 16:41
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Mar 27, 2026
@drupol

drupol commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Great ! Would it be a good idea to upstream this patch ?

@frozolotl

frozolotl commented Mar 28, 2026

Copy link
Copy Markdown
Contributor Author

It appears as though this bug swatted itself? The latest master appears to work correctly now.

I think I'm more confused now than I was when submitting this PR, but hey, it's a good kind of confusion.

https://projects.blender.org/blender/blender/pulls/156456#issuecomment-1888351

EDIT: even #502842 works now?! I'm certain I had that issue happen on those exact commits. @amarshall too. It's weird.
The segfault does still happen on 5fab99f though. So it's not like I just can't reproduce it anymore.

@amarshall can you check whether your results are the same as mine?

@frozolotl frozolotl closed this Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants