I should have been clear, the KePub code is identical. The driver unpacks the ePub, does some cleanup (you can see what by looking at the driver options), and adds the Kobo spans. The conversion process runs all of calibre' standard conversion to ePub (and you can convert ePub to ePub) and then runs the driver's KePub code against that unpacked converted ePub.
I'd like to get the ePub that generates the KePub that's causing the Kobo to crash. Could you upload it to
https://www.dropbox.com/request/YS51qPlpvXcndymRhlfO please?