Aha! I think I have found it!
I haven't managed to recreate it but by narrowing down the location, partly through the logic that it must be a piece of code only applicable to NPRs, partly because of the evidence of NPRs without Duranium being affected and partly because of John's comment in the v4.0b bugs thread that mineral extraction was working but not construction when the hang occurred, I think I have found it by reading through the code. There is a section in NPR Planning which looks at different things to build. There is some preliminary code that ensures sufficient quantities of basic installations have been built and then a section for random selection of installations to build. Each item in the random selection checks for sufficient quantities of minerals. If insufficient minerals are available the selection code loops and randomly selects something else. I was already aware of the possibility that nothing may be found so the code counts each loop and when it reaches five loops, it exits automatically - or so I thought!
A variable holds the count of the number of loops and when that variable hits 5, the loop ends. However, I realised that the line of code that initialises the variable to zero was before the random selection but inside the loop! Which means that the variable is reset to zero at the start of each loop and will never reach 5. So if there are insufficient minerals to build any of the nine different installations in the random selection, the loop will never end and the program will hang.
I have now moved the line of code that initialises the variable to zero outside the loop, which should fix the problem. Thanks to everyone who contributed to tracking this down!
Steve