Two things:
Firstly, you need to store it as a PT(MouseWatcher), because it is a reference-counted class. If you don’t hold a reference to it, the reference count will be zero and Panda3D may delete it at will.
PT(MouseWatcher) mw = new MouseWatcher("mw");
Secondly, you need to make sure that you compile in Release mode, because the Panda3D downloads are also compiled in Release mode.
Thank you for your reply, rdb. Unfortunately, wrapping a pointer in a PT makes little difference.
I can run the code in the first post (create a MouseWatcher and exit), but in a more useful situation I still get heap corruption. E.g.: