"Assertion failed" messages : strange programming practice at Adobe
Hi,
There's something that is bothering me with Lightroom. I'm currently trying to help a user who has problems when launching LR. He gets an "assertion failed" message and that's it. We'll certainly fix that but this kind of message just raises a question...
Assertions are small tests inserted in a program's code in order to verify that some condition is met when reaching a given part of the code during execution. If the condition is not met (the assertion failed), then the program immediately stops.
Assertions are used by developers when testing and debugging their code. Assertions are useless when the code is considered OK. During development, the program is compiled in "debug mode" and the assertions are embedded. When the program is considered ready, the compiler is switched to "release mode" and the assertions in the source code are ignored and not embedded in the final code. Why ? Because this code needs to be executed only during development.
Since the Lightroom users are sometimes getting these "assertion failed" messages, this means that the delivered code was compiled in debug mode, not in release mode. Since this code contains tests that are useful only during development, this more or less affects performance (because the assertion code is executed although it's not necessary).
Conclusion :
- If the distribution of code compiled in debug mode is a programming mistake, there's something to fix in the project management.
- If this is done voluntarily, this is strange programming practice. The "assertion failed" message doesn't give any indication about what caused the program crash (because the assertion can only be handled in debug mode when the program is run under the control of a debugger). So the embedded test code is useless anyway (from a user's point of view).
It's important to note that when an assertion fails, this doesn't always mean that something went wrong. The assertion was inserted by the developer because he wanted to check something at some moment during the development phase. The assertion may fail when the program runs in the field because the test was related to the developer's environment. So a debug assertion may fail in the field while there's absolutely no problem (but the program will stop anyway). This is why the distributed code should always be compiled in release mode.
Since performance problems are a hot topic in LR, I'm wondering why the developers would want to make things even worse by distributing a version of a program containing non functional code. It's a common mistake among junior developers to forget to switch to release mode when the code is considered ready for delivery. But since these errors have been reported so many times, the project managers are certainly aware of this.
So why are Adobe still distributing code compiled in debug mode ?
