When upgrading from 1.6.4 to a 1.8.1 installation, the upgrade halted and did not display any further errors. When I checked the upgrade log in the log file from the moodledata folder, the last entry contained the message "Sorry, this activity is currently hidden". I stepped through the upgrade and discovered that it failed on the upgrade to version 2006100601 where it goes through and hides the exercise modules. I believe it failed on the call to 'rebuild_course_cache' at this point.
I confirmed this step was where it failed by restoring the database back to its 1.6.4 state, manually hiding the exercise module before the upgrade, and rerunning the upgrade. All went well after that.