Bug 107954

Summary: radv_shader_compile_to_nir doesn't check for bad entry point
Product: Mesa Reporter: Dave Gilbert <freedesktop>
Component: Drivers/Vulkan/radeonAssignee: mesa-dev
Status: RESOLVED WONTFIX QA Contact: mesa-dev
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Dave Gilbert 2018-09-16 19:26:06 UTC
I screwed up my vulkan calling and ended up getting radv_shader_compile_to_nir to seg because it has:

251 entry_point = spirv_to_nir(spirv, module->size / 4,
             spec_entries, num_spec_entries,
             stage, entrypoint_name,
             &spirv_options, &nir_options);
252 nir = entry_point->shader;
    assert(nir->info.stage == stage);

it's dereferencing 'entry_point' on 252, but if the caller screws up entry_point can be NULL from spirv_to_nir;

Could this failure be made cleaner?

(Nothing else printed anything first before the seg by default;
spirv_to_nir took a bit of an odd route; it checks b->entry_point = NULL then call vrn_fail that jumps back to it's setjmp handler and cleans up - so it's not obvious to me why it also has a ralloc_free(b), return NULL if the vtn_fail is going to take the setjmp).

My screwup incidentally was a cut-and-paste where I'd copied the code for my vertex shader for my fragment shader and so I was trying to find the fragment shader entrypoint in my vertex shader.
Comment 1 Samuel Pitoiset 2018-09-17 09:20:11 UTC
Should be fixed with
https://patchwork.freedesktop.org/patch/249829/
Comment 2 Jason Ekstrand 2018-09-17 09:24:49 UTC
That's not the job of the driver.  You should be running with validation layers enabled while developing applications.
Comment 3 Samuel Pitoiset 2018-09-17 14:35:54 UTC
Actually, I do agree with Jason's point of view. We are not going to fix anything inside the driver.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.