microsoft / microsoft/onnxruntime-extensions

DecodeImage is causing my program to exit

Open
#1,094 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
479
Forks
144
Avg merge
1d 8h
Merged PRs (30d)
11

Description

In operators/vision/image_decoder.hpp there is this line:

# operators/vision/image_decoder.hpp : 137
cinfo.err = jpeg_std_error(&jerr); // sets what happens when libjpg has an error

The problem with this is that now cinfo.err() will call exit:

# libjpeg/src/jerror.c : 66
METHODDEF(void)
error_exit(j_common_ptr cinfo)
{
  /* Always display the message */
  (*cinfo->err->output_message) (cinfo);

  /* Let the memory manager delete any temp files before we die */
  jpeg_destroy(cinfo);

  exit(EXIT_FAILURE);
}

Now, I have data being fed to generic models, and in this case when the data is invalid and given to an ImageDecoder node, my entire program just exits, instead of having an OrtStatus being returned.

I am running this with onnxruntime C api and usually models will just return an OrtStatus when they have an error. So I'm wondering if there is a workaround for this s.t. invalid images don't crash my program.

If this were to be changed, it could be that some other function that is not jpeg_std_error is used, s.t. cinfo.err doesn't call error_exit(), but instead sets an OrtStatus.

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 in operators/vision/image_decoder.hpp at line 137 and compare the libjpeg error path in libjpeg/src/jerror.c at line 66. Trace how invalid image data reaches cinfo.err and how the ONNX Runtime C API represents errors. Done means invalid images return an OrtStatus instead of terminating the program.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design, computer-vision
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.