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-fuzz: Segmentation fault in FuzzerPassInterchangeZeroLikeConstants::FindOrCreateToggledConstant #3663

Closed
andreperezmaselco opened this issue Aug 6, 2020 · 1 comment · Fixed by #3664
Labels
component:fuzzer Relates to the spirv-fuzz tool

Comments

@andreperezmaselco
Copy link
Collaborator

Program received signal SIGSEGV, Segmentation fault.
0x0000555555daae30 in
spvtools::fuzz::FuzzerPassInterchangeZeroLikeConstants::FindOrCreateToggledConstant
at source/fuzz/fuzzer_pass_interchange_zero_like_constants.cpp:41

Debugging spirv-fuzz, I found that the segmentation fault is caused because FindDeclaredConstant returns a null pointer that is used to call a function.

auto constant = GetIRContext()->get_constant_mgr()->FindDeclaredConstant(declaration->result_id());

if (!constant->IsZero()) {
  return 0;
}

declaration is %10 = OpSpecConstant %5 1, but opt::analysis::ConstantManager does not support OpSpecConstant.

@paulthomson
Copy link
Contributor

FuzzerPassInterchangeSignednessOfIntegerOperands and FuzzerPassInterchangeZeroLikeConstants both included specialization constants when trying to find integer constants with known values. However, this is incorrect behavior because we do not know the value of specialization constants. Furthermore, ConstantManager does not support them, and this led to crashes where we assumed we could look up specialization constants via the ConstantManager.

paulthomson pushed a commit that referenced this issue Aug 12, 2020
`FuzzerPassInterchangeSignednessOfIntegerOperands` and `FuzzerPassInterchangeZeroLikeConstants` both included specialization constants when trying to find integer constants with known values. However, this is incorrect behavior because we do not know the value of specialization constants. Furthermore, ConstantManager does not support them, and this led to crashes where we assumed we could look up specialization constants via the ConstantManager.

This change fixes both passes to ignore specialization constants.

Fixes #3663.
dnovillo pushed a commit to dnovillo/SPIRV-Tools that referenced this issue Aug 19, 2020
`FuzzerPassInterchangeSignednessOfIntegerOperands` and `FuzzerPassInterchangeZeroLikeConstants` both included specialization constants when trying to find integer constants with known values. However, this is incorrect behavior because we do not know the value of specialization constants. Furthermore, ConstantManager does not support them, and this led to crashes where we assumed we could look up specialization constants via the ConstantManager.

This change fixes both passes to ignore specialization constants.

Fixes KhronosGroup#3663.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:fuzzer Relates to the spirv-fuzz tool
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants