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

spirv-diff crashing with OpString #5971

Closed
spencer-lunarg opened this issue Jan 29, 2025 · 2 comments · Fixed by #5988
Closed

spirv-diff crashing with OpString #5971

spencer-lunarg opened this issue Jan 29, 2025 · 2 comments · Fixed by #5988
Assignees
Labels
component:diff Issues related to spirv-diff

Comments

@spencer-lunarg
Copy link
Contributor

Take the following, duplicate it and go spirv-diff a.spv b.spv and it will crash with

/source/diff/diff.cpp:2734: opt::Instruction spvtools::diff::(anonymous namespace)::Differ::ToMappedSrcIds(const opt::Instruction &): Assertion `id_map_.IsDstMapped(operand.AsId())' failed.

               OpCapability Shader
               OpExtension "SPV_KHR_non_semantic_info"
          %1 = OpExtInstImport "GLSL.std.450"
         %12 = OpExtInstImport "NonSemantic.DebugPrintf"
               OpMemoryModel Logical GLSL450
               OpEntryPoint GLCompute %main "main"
               OpExecutionMode %main LocalSize 1 1 1
         %10 = OpString "unsigned == %u"
               OpSource GLSL 450
               OpSourceExtension "GL_EXT_debug_printf"
               OpName %main "main"
               OpName %foo "foo"
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
       %uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
   %uint_127 = OpConstant %uint 127
       %main = OpFunction %void None %3
          %5 = OpLabel
        %foo = OpVariable %_ptr_Function_uint Function
               OpStore %foo %uint_127
         %11 = OpLoad %uint %foo
         %13 = OpExtInst %void %12 1 %10 %11
               OpReturn
               OpFunctionEnd

cc @ShabbyX (might not get time to soon, but wanted to report it)

@spencer-lunarg spencer-lunarg changed the title spirv-diff spirv-diff crashing with OpString Jan 29, 2025
@s-perron s-perron added the component:diff Issues related to spirv-diff label Feb 5, 2025
@ShabbyX
Copy link
Contributor

ShabbyX commented Feb 7, 2025

Thanks for the report. spirv-diff is not creating a mapping for %10 which is only a parameter of OpExtInst. Normally, its expectation is that the parameters are already matched for other reasons (like %11 is matched because of OpLoad). In this case, it's just a string, so my assumption there was wrong. Should be easy to fix hopefully, at least assuming OpExtInst is the only one that's dealing with these not-really-otherwise-used values.

ShabbyX added a commit that referenced this issue Feb 7, 2025
@ShabbyX
Copy link
Contributor

ShabbyX commented Feb 7, 2025

Actually the crash itself was due something more trivial, the map of id->instruction was not being populated for debug instructions. This fixes the crash: #5988

The OpString instructions are still not correctly matched with that fix, but at least there is no crash.

ShabbyX added a commit that referenced this issue Feb 9, 2025
s-perron pushed a commit that referenced this issue Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:diff Issues related to spirv-diff
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants