In yesterday’s post, I gave an example of how simple command prompt recursion can bring Windows (XP and Vista) down to its knees. The same script brought into light another interesting problem. Namely, the execution behavior differs depending on whether the script is executed on a single core (including hyper-threaded) or dual core CPU.

When running the script under a single core CPU, everything looked pretty normal (the @echo off statement made sure that no output is generated from the script). When running under a dual core machine, however, I got the following output:

cmd recursion

cmd recursion

As you can see, there were some strange ASCII characters outputted which was absent when running on a single CPU. Given the simplicity of the code, the results should have been identical.

While I did not look at the memory dump at the time of the execution to figure out the exact cause of the problem, one thing for sure is that the command shell seemed to have some reentrancy issues when processes execute concurrently in a multi-processor environment. And since there’s no output statement in the original code, the screenshot above also suggests possible buffer overrun of cmd.exe during execution.

 

Be Sociable, Share!