- 
                Notifications
    You must be signed in to change notification settings 
- Fork 802
Fix PAQ memory leak by never pushing redundant stages to backing vector #7442
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -397,9 +397,19 @@ bool Parser::MaybeParseHLSLAttributes(std::vector<hlsl::UnusualAnnotation *> &ta | |
| stage = hlsl::DXIL::PayloadAccessShaderStage::Miss; | ||
| } else if (shaderStage == "anyhit") { | ||
| stage = hlsl::DXIL::PayloadAccessShaderStage::Anyhit; | ||
| } | ||
| } | ||
|  | ||
| // mod.ShaderStages can only take four elements before it starts to | ||
| // migrate. Make sure not to add redundant stages. | ||
| 
      Comment on lines
    
      +402
     to 
      +403
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the problem is that we leak memory if the  | ||
| bool IsDuplicate = false; | ||
| for (auto s : mod.ShaderStages) | ||
| if (s == stage) { | ||
| IsDuplicate = true; | ||
| break; | ||
| } | ||
| if (!IsDuplicate) | ||
| mod.ShaderStages.push_back(stage); | ||
|  | ||
| mod.ShaderStages.push_back(stage); | ||
| ConsumeToken(); // consume shader type | ||
|  | ||
| if (Tok.is(tok::comma)) // check if we have a list of shader types | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // RUN: %dxc -T lib_6_9 %s | ||
|  | ||
| // COM: No FileCheck required: Error raised by ASAN-enabled DXC builds where underlying bug #7104 is not fixed. | ||
| // COM: This checks that the backing memory of the shader stages vector does not migrate when more than four (it's preallocated size) shader stages are added. | ||
|  | ||
| struct [raypayload] Payload | ||
| { | ||
| int a : read(anyhit,caller,miss,closesthit,closesthit) : write(anyhit,caller,miss,closesthit,caller); | ||
| }; | ||
|  | ||
| struct Attribs | ||
| { | ||
| float2 barys; | ||
| }; | ||
|  | ||
| [shader("closesthit")] | ||
| void ClosestHitInOut( inout Payload payload, in Attribs attribs ) | ||
| { | ||
| if (payload.a == 1) | ||
| payload.a = 2; | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could exit the while loop early here if mod.size() is 4?