This project is read-only.

pe2pe output not deterministic?

May 3, 2012 at 2:23 AM

I frequently disassemble my rewritten assemblies (using ildasm) to compare the IL against the previous version as I work on my rewriter. I've noticed that the order of local variables is not deterministic, so if I rewrite the same input assembly more than once, and disassemble each output, sometimes some of the locals are declared in a different order. This creates diffs throughout the affected functions.

Also, I noticed that sometimes conditional branches followed by an unconditional branch are inverted (into a single conditional branch), but sometimes not. Again, this is when executing the rewriter with the same inputs a second time.

Finally, sometimes the .maxstack declaration on a function can change from one run to another, with no other changes in the IL of the affected function.

Do you have any suggestions as to what might be causing this non-determinism? I suspect I can sort something to fix the order of the locals, but I don't have a clue where to start looking for the others.

It's not really a bug - just something I'd like to change to make debugging easier on myself.

May 12, 2012 at 2:43 AM

It would be nice if rewriting a decompiled assembly produced the same output given the same input. Unfortunately there is no easy fix. But you are very welcome to set up repro cases and create issues for individual cases of non derminism.