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.:
PandaFramework pf = PandaFramework();
WindowFramework* wf = pf.open_window();
PT(MouseWatcher) mw = new MouseWatcher("mw");
nout << "done\n";
The last line in the debug log:
:pipeline(debug): Beginning the pipeline cycle
It still crashes with c0000374: heap corruption error.
Yes, I am building in release mode. Without MouseWatcher it runs normally.