onnx / onnx/optimizer

[BUG] The pass "adjust_slice_and_matmul" causes crash (malloc_error_break)

Open
#272 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
834
Forks
109
Avg merge
6h 55m
Merged PRs (30d)
2

Description

[BUG] The pass "adjust_slice_and_matmul" causes crash (malloc_error_break)

Issue
Running the single pass adjust_slice_and_matmul with onnxoptimizer 0.4.2 may cause crash. Details are provided to reproduce the issue with oracle inputs.

Environment

  • Ubuntu 20.04
  • Python 3.10
  • onnx==1.19.0
  • onnxruntime==1.23.2
  • onnxoptimizer==0.4.2 (latest)

Repro steps (run from this folder)

  1. Download and unzip the attached archive, then cd into the extracted directory
tar -xzvf adjust_slice_and_matmul_repro.tar.gz
cd adjust_slice_and_matmul_repro
  1. Create a Python environment (Python 3.10) and install dependencies:
python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -r requirements.txt
  1. Optimize a case with only adjust_slice_and_matmul (writes model.opt.onnx next to model.onnx):
  • python optimize_model.py --case ./case_02937_seed43509122
  1. Differential test original vs optimized outputs using stored oracle inputs:
  • python diff_test.py --case ./case_02937_seed43509122

Observed results
Crash : case_02937_seed43509122 (malloc error during diff run; see notes below).

Expected
adjust_slice_and_matmul should be semantics-preserving and should not cause crash when optimizing models.

Differential Test Output Details

  1. case_02937_seed43509122: diff test aborted with malloc checksum error after, no comparison result produced.
Python(21317,0x1f992e0c0) malloc: Incorrect checksum for freed object 0x127037200: probably modified after being freed.
Corrupt value: 0x42b444884512460f
Python(21317,0x1f992e0c0) malloc: *** set a breakpoint in malloc_error_break to debug

Attachments

  • README.md
  • requirements.txt
  • optimize_model.py (runs only adjust_slice_and_matmul and saves model.opt.onnx)
  • diff_test.py (runs original and optimized with same oracle inputs)
  • case_02937_seed43509122/ (original model and oracle inputs)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading README.md and running optimize_model.py followed by diff_test.py for case_02937_seed43509122 using requirements.txt. Compare the original and optimized model behavior and investigate the crash around the adjust_slice_and_matmul pass. Done means the case completes without malloc corruption and the pass remains semantics-preserving.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
machine-learning, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.