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

Security Fuzz Test Fixes #21608

Merged
merged 16 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
jingyanwangms marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,14 @@ Package.resolved
.build/
.swiftpm/
repros/

b\
build\
b/
build/
build*\

build2/
build3/

b3/
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ setlocal
set PATH=C:\Program Files\Git\usr\bin;%PATH%

rem Requires a Python install to be available in your PATH
python "%~dp0\tools\ci_build\build.py" --build_dir "%~dp0\build\Windows" %*
python "%~dp0\tools\ci_build\build.py" --build_dir "%~dp0\build2\Windows" %*
1 change: 1 addition & 0 deletions onnxruntime/core/framework/tensorprotoutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,7 @@ common::Status ConstantNodeProtoToTensorProto(const ONNX_NAMESPACE::NodeProto& n
common::Status ConstantNodeProtoToTensorProto(const ONNX_NAMESPACE::NodeProto& node,
const std::filesystem::path& model_path,
ONNX_NAMESPACE::TensorProto& tensor) {
ORT_ENFORCE(node.output_size() == 1, "NodeProto for Constant should have 1 output. Got:", node.output_size());
return ConstantNodeProtoToTensorProto(node, model_path, tensor, node.output(0));
}

Expand Down
4 changes: 4 additions & 0 deletions onnxruntime/core/optimizer/unsqueeze_elimination.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Status UnsqueezeElimination::Apply(Graph& graph, Node& node, RewriteRuleEffect&
// Generate new dims.
InlinedVector<int64_t> new_dims(output_rank, 0);
for (int64_t axis : axes) {
if (static_cast<size_t>(axis) >= new_dims.size() || static_cast<size_t>(axis) < 0) {
jingyanwangms marked this conversation as resolved.
Show resolved Hide resolved
LOGS(logger, WARNING) << "UnsqueezeElimination cannot remove node due to invalid axes" << node.Name();
return Status::OK();
}
new_dims[static_cast<size_t>(axis)] = 1;
}

Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/core/providers/cpu/quantization/qlinearconv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ Status QLinearConv<ActType>::PrePack(const Tensor& tensor, int input_idx, Alloca
const int64_t M = shape[0];
const int64_t C = shape[1];

// Verify that the total number of output channels is a multiple of the group count.
if (M % conv_attrs_.group != 0) {
// Verify that conv_attrs_.group is not 0 and the total number of output channels is a multiple of the group count.
if (conv_attrs_.group == 0 || M % conv_attrs_.group != 0) {
return Status::OK();
}

Expand Down
25 changes: 24 additions & 1 deletion onnxruntime/test/fuzzing/src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,30 @@ void mutateModelTest(onnx::ModelProto& model_proto,
//
std::wstring modelPrefix = L"/ReproMutateModel_";
if (seed == 0) {
seed = static_cast<unsigned int>(std::chrono::system_clock::now().time_since_epoch().count());
// seed = static_cast<unsigned int>(std::chrono::system_clock::now().time_since_epoch().count());
// Bug 1 - fixed in attention_fusion.cc
// attention_past_no_unidir.onnx
// seed = 2161642583; // Bug 1
// seed = 2647017145; // Bug 2 - fixed
// seed = 2913110292; // Bug 3 - fixed
// Bug 4 - fixed with bug 7
// /r "C:\Users\jingywa\source\onnxruntime\build\Windows\RelWithDebInfo\RelWithDebInfo\testdata\transform\bert_toy_opset14.onnx" 548860496
// Call stack starts from asan_win.cpp
// seed = 548860496; // Bug 4
// Bug 5 - fixed in unsqueeze_elimination.cc
// /r "C:\Users\jingywa\source\onnxruntime\build\Windows\RelWithDebInfo\RelWithDebInfo\testdata\transform\fusion\fuse-conv-add-no-bias.onnx" 3412260231
// /t /v "C:\Users\jingywa\source\onnxruntime\build\Windows\RelWithDebInfo\RelWithDebInfo\testdata\transform\fusion\fuse-conv-add-no-bias.onnx" 10 m
// Call stack starts from asan_win.cpp
// Assertion failed: false && "i < size()", file C:\Users\jingywa\source\onnxruntime\build\Windows\Debug\_deps\abseil_cpp-src\absl/container/inlined_vector.h, line 363
seed = 3412260231; // Bug 5
// seed = 191684599; // Bug 6 - fixed in qlinearconv.cc?
// Bug 7 - fixed in tensorprotoutils.cc
// /r "C:\Users\jingywa\source\onnxruntime\build\Windows\RelWithDebInfo\RelWithDebInfo\testdata\leconv_Opset17.onnx 1858054927
// seed = 1858054927; // Bug 7

// Bug 8 - Need to fix unit test error.
// /r "C:\Users\jingywa\source\onnxruntime\build\Windows\RelWithDebInfo\RelWithDebInfo\testdata\pipeline_vectorize.onnx" 1332387938
// seed = 1332387938;
modelPrefix = L"/MutateModel_";
}

Expand Down
Loading