I just saw this as a regression, I'm not worried if the fix is not accepted.
Yes, it does not appear to crash using ANSI. But with unicode it's guaranteed to crash within the first 5 times in the loop.
I still have the original ubuntu 12.04 VM I set up to test nsis with (has the old mingw32 toolchain), plus a 14.04 VM, and a windows xp VM. All of those use python 2.7.x. It's a good variety and gives decent coverage for finding small issues, or in this case a big issue.
Forgot to mention why I used a preformatted block for the quotes, it's because the OutFile command doesn't like spaces in the name or path, and I took advantage of the fact that in the script single quotes and double quotes are treated the same by makensis, so this multi quote trick in python works.
Scons error with Python < 3.6
I finally got round to debugging this. I compiled a debug build and ran it with x32dbg, and it stopped with an access violation, around where GlobalReAlloc() is. I tried a handful of different ways of reallocating that memory, but same result. So I thought, why not just discard the contents every time it is full, and reset the output pointer? This is probably not ideal since it overwrites old data with new data, but at least the plugin doesn't crash any more. I attached a patch with the potential...
I see what is going on. The proper makensis.exe is in the "Bin" folder. The one in the root NSIS dir is just a helper exe that redirects to "Bin\makensis.exe". So put your compiled makensis.exe in the "Bin" directory.
Related bug: https://sourceforge.net/p/nsis/bugs/1301/