Do you disable interrupts when erasing block0, which contains interrupt vectors?
Are you operating from block3 to avoid copying flash routines to RAM? Then try disabling interrupts. If you can't disable interrupts, then you may use IVBR to switch to alternative interrupt vectors table. But, either you need to move your ISRs to RAM, which is more work than moving only flash routine. Or, you may try allocating vectors table and all ISR's in the same PPAGE of block3, and then enable interrupts and don't leave this PPAGE while interrupts are enabled IVBR'ed to this PPAGE.
Do you disable interrupts when erasing block0, which contains interrupt vectors?
Are you operating from block3 to avoid copying flash routines to RAM? Then try disabling interrupts. If you can't disable interrupts, then you may use IVBR to switch to alternative interrupt vectors table. But, either you need to move your ISRs to RAM, which is more work than moving only flash routine. Or, you may try allocating vectors table and all ISR's in the same PPAGE of block3, and then enable interrupts and don't leave this PPAGE while interrupts are enabled IVBR'ed to this PPAGE.