This typically happens when something interferes and causes the script to "lose" the focus on the specific portal row record where you clicked the button. Then the reference to Calc::CalcID is to the "first" related record--which will be the first portal row in an unsorted, unfiltered portal to the same table occurrence.
Most likely suspect is a commit records step--either a preceding script step in the button's script or in a script trigger performed script that gets performed prior to the button's script being performed.
I found that I'd wrongly set field by 'CalcID' rather than 'Calc_n'; stupid error.
Useful to see your info though for when a 'freeze' does happen.