Installer corrupted: invalid opcode
I've just spent quite some time figuring out why my installer is aborting and giving me a dialog box with:
"Installer corrupted: invalid opcode".
I couldn't find any forum posts or documentation to help me debug this, so I tracked it down, line by line in my script until I figured out which line it was. And then I guessed what the answer was. Here are the two lines that are causing me to get this error:
IfErrors 0 +2
!insertmacro LogProgressMessage '"There was an error..."'
The intent of "IfErrors 0 +2" is that if there are no errors to skip over the logging message. Note that LogProgressMessage is my own macro which uses GetTime to log a message with a date and time to a log file.
However, since this is a macro, not a statement, the +2 is very ineffective. In fact, I believe that when my macro is expanded out, the first statement is a "Push". There is of course a corresponding Pop, but if there is no error, the Push is skipped while the Pop is not.
Therefore there are three lessons here:
* More Pops than Pushes will cause your installer to abort with "Installer corrupted: invalid opcode".
* When using the +2 mechanism to jump over statements, you must be sure that the next line is really a statement, not a macro.
* In general it's much safer to use labels than to use the +2 mechanism (or any +n)