As one of the previous posts said, there is a crash when one of the recipes selected has a probability. I believe it is because some recipes have probabilities but the product does not have the min_amount or max_amount variables you use (i.e. the product can be 0 or amount, such as in uranium processing)
Apologies, I completely misunderstood. It is in the debug print statement at the beginning of the product calc function (line 687 of control.lua?): a call to prod.amount