Fix SAM2 segmentation ASan crashes#20775
Conversation
Disable ORT graph optimization for the SAM2.1 encoder to avoid the ONNX Runtime 1.24.x session-init UAF, and keep dynamic decoder output shape buffers alive across dt_ai_run calls so ORT can write resolved dims safely during warmup and decode. Co-authored-by: codex@openai.com
|
Please describe the problem you are facing. What are the steps to reproduce it? |
|
Hey @sjuxax – same as #20774, there's been no movement here for a while, so I opened #20815 to port the part I could confidently review. #20815 takes the decoder shape-array lifetime fix ( I left out the I looked for other evidence before porting and couldn't find any:
We also already have a fallback chain in A few questions that would help me understand:
|
| // disabled so session creation stays on the safe path. SegNext and other | ||
| // non-SAM encoders keep the normal optimization level. | ||
| const dt_ai_opt_level_t encoder_opt | ||
| = (model_type == DT_SEG_MODEL_SAM) ? DT_AI_OPT_DISABLED : DT_AI_OPT_ALL; |
There was a problem hiding this comment.
This is too aggressive, results in performance regression for all
Disable ORT graph optimization for the SAM2.1 encoder to avoid the ONNX Runtime 1.24.x session-init UAF, and keep dynamic decoder output shape buffers alive across dt_ai_run calls so ORT can write resolved dims safely during warmup and decode.
Co-authored-by: codex@openai.com