OPENCV_CAN_BREAK_BINARY_COMPATIBILITY breaks binary (Bug #2218)


Added by Reto Grieder over 12 years ago. Updated over 12 years ago.


Status:Cancelled Start date:2012-07-31
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:trash
Target version:- Estimated time:0.50 hour
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

The other week I wanted to compile OpenCV 2.4.2 and I went through all the CMake options and I ticked OPENCV_CAN_BREAK_BINARY_COMPATIBILITY among a few other changes.
The resulting binary was literally broken because OpenCV internally sometimes called the wrong functions (mix up with function addresses I guess). It became evident when calling cv::findContours(). Then the matrix functions needed() and kind() were mixed up: the one with the int parameter was called instead of the other one. Consequently, that int parameter had some undefined value.

I thought: how can that possibly even happen? It turned out to be OPENCV_CAN_BREAK_BINARY_COMPATIBILITY. It is only used in very few locations in the code and has something to do with the destructor. I'm guessing that the macro might not be defined for every compilation unit, therefore creating discrepancies.

System: CMake 2.8.8 on Windows 7 64 bit, compiling with Visual Studio 2008 SP1, 32 bit.

I'm currently very busy, that's way my information on this is so scarce.

In short: please double check whether the macro in question really is defined exactly the same for EVERY compilation unit.


Associated revisions

Revision 25d2ab8a
Added by Andrey Pavlenko about 11 years ago

Merge pull request #2218 from alalek:fix_defects_code_coverity

History

Updated by Daniil Osokin over 12 years ago

Reto, please, give a code with bug, in this situation, we will reproduce and process it, or I'll cancel this task.

  • Assignee deleted (Alexander Shishkov)

Updated by Andrey Kamaev over 12 years ago

Indeed OPENCV_CAN_BREAK_BINARY_COMPATIBILITY breaks binary compatibility. If you need compatible binaries then don't touch this option.

  • Status changed from Open to Cancelled
  • Category changed from build/install to trash

Updated by Reto Grieder over 12 years ago

Andrey Kamaev wrote:

Indeed OPENCV_CAN_BREAK_BINARY_COMPATIBILITY breaks binary compatibility. If you need compatible binaries then don't touch this option.

Andrey, please read the text carefully. I'm not talking about breaking binary compatibility. I'm talking about breaking the binary. It literally cannot be used.

Updated by Reto Grieder over 12 years ago

So, I tested again by generating a default VS 2008 32 bit project on my system.
I then built OpenCV core and imageproc with OPENCV_CAN_BREAK_BINARY_COMPATIBILITY = ON and OPENCV_CAN_BREAK_BINARY_COMPATIBILITY = OFF and replaced my standard binaries with them. Afterwards, I ran some program that uses OpenCV and has been running well for a while now.
In the first case, I get a stack overflow, in the second case, everything works as expected.

I can directly make this option responsible for breaking the binaries.

So, some investigations later, I found the culprit. The option is modifying OpenCV header files (making some dtors virtual). That is not a problem at all.
But SOMEWHERE, there should be a mentioning that when enabling this option, EVERY user of the library also has to add this option to his own flags.

Considering that there are no other flags I'm aware of that you have to manually set, this should be automated. I don't know how exactly you deal with such options. Maybe you have a configurable header file that also gets distributed (not aware of any) or maybe you can convince the OpenCVConfig.cmake script to add a compiler flag.

Please apologize if I don't answer quickly. Somehow that "Email issue updates" didn't work for me. At least no for the original post.

Also available in: Atom PDF