简体   繁体   English

CImg在调试模式下引发异常,在Release中运行良好

[英]CImg throws an exception in Debug mode, works fine in Release

My program is written in C++. 我的程序是用C ++编写的。 I use Visual Studio 2017. 我使用Visual Studio 2017。

My code compiles and runs correctly in Release mode, but throws exception in Debug mode : 我的代码在Release模式下编译并正确运行,但在Debug模式下抛出异常

Unhandled exception at 0x00007FF9A4EAD428 (ucrtbase.dll) in MyAssemblyName.exe: An invalid parameter was passed to a function that considers invalid parameters fatal. MyAssemblyName.exe中0x00007FF9A4EAD428(ucrtbase.dll)的未处理异常:无效参数传递给认为无效参数致命的函数。

This exception is thrown in the img.assign() function img.assign()函数中抛出此异常

CImg<unsigned char> img;

try {
    img.assign(picPath.c_str());
}
catch (CImgException) {
    // ...
}

In CImg, this is the code being executed: 在CImg中,这是正在执行的代码:

std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
      struct jpeg_decompress_struct cinfo;
      struct _cimg_error_mgr jerr;
      cinfo.err = jpeg_std_error(&jerr.original);
      jerr.original.error_exit = _cimg_jpeg_error_exit;
      if (setjmp(jerr.setjmp_buffer)) { // JPEG error
        if (!file) cimg::fclose(nfile);
        throw CImgIOException(_cimg_instance
                             "load_jpeg(): Error message returned by libjpeg: %s.",
                             cimg_instance,jerr.message);
      }

      jpeg_create_decompress(&cinfo);
      jpeg_stdio_src(&cinfo,nfile);
      jpeg_read_header(&cinfo,TRUE);
      jpeg_start_decompress(&cinfo);

The exception is thrown when executing jpeg_read_header() . 执行jpeg_read_header()时抛出异常。

Why is this happening? 为什么会这样? Why only in Debug mode, not Release? 为什么只在Debug模式下,而不是Release?

我已经根据此答案更新了jpeg库,问题消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 调试模式下未处理的异常,但在发行版中工作正常 - Unhandled exception in debug mode but works fine in release 释放模式工作正常,但调试模式使用八度DLL提供了未处理的异常 - Release mode works fine but debug mode gives unhandled exception- using Octave DLLs 自定义 memory 管理器在发布模式下工作正常,但在调试模式下无法正常工作 - Custom memory manager works fine in release mode, but not in debug mode 在发布模式下OpenAL Soft崩溃(调试工作正常) - OpenAL Soft crashes in release mode (debug works fine) 为什么在发布模式下不能访问 for 循环,但在调试中它工作正常 - Why isn´t the for loop accessed in release mode, but in debug it works fine 调试运行良好,但不在发布模式下 - Debug runs fine, but not in release mode 程序可以在Debug中正常运行,但不能在Release中正常运行 - Program works fine in Debug, but not in Release 释放模式而不是调试模式下的异常 - exception in release mode and not in debug mode 在调试模式下访问冲突,但在发布模式下很好 - Access Violation in debug mode, but fine in release mode SFML 2.1程序在调试模式下运行良好,但在发布模式下崩溃 - SFML 2.1 program runs fine in debug mode, but crashes in release mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM