Well, that was festive. "I can reproduce that bug in 22 lines!"
Great.
The bug (and other reported curruptions) are definitely coming from the COW logic in register.c. This is what happens:
Setting up the exception handler (which is a continuation) triggers COW setting of the register stacks. Then on first subroutine return from __inner, the register stack is unCOWed (the chunk is copied). When then returning from __outer stack->top->used is still 2 end the same chunk gets popped off the stack, because the interpreter's stack is still unchanged.
The register restoring memcpy is the same *twice*:
memcpy (dstpp=0x824ca50, srcpp=0x4017d9a0, len=64)
So returning from __outer places P17 (the RetContinuation of __inner) in mains registers and ruins the PerlUndef that you wanted to print.
:get_string() not implemented in class 'RetContinuation'
... which then causes this error.
Just returning from mark_register_stack_cow() makes the bug vanish
(but doesn't fix anything)
As mentioned several times, a COWed buffer needs distinct buffer headers and shared buffer memory. The current implementation in register *and* other stacks is broken. *Fixes welcome*.
You can currently avoid the bug by not using Continuations and Exception Handlers.
Thanks for your test program, leo