Issue with Modal View Session

I tweaked the code further like this to clearly point out what is going on:

{
  DLOG_F(INFO, "Start of block");
  auto dialog = VSTGUI::owned<MyContainer>(new MyContainer({0, 0, 100, 100}));
  DLOG_F(INFO, "before beginModalViewSession...");
  auto id = button->getFrame()->beginModalViewSession(dialog);
  DLOG_F(INFO, "after beginModalViewSession.");
  DLOG_F(INFO, "before endModalViewSession...");
  button->getFrame()->endModalViewSession(*id);
  DLOG_F(INFO, "after endModalViewSession.");
  DLOG_F(INFO, "End of block");
}
DLOG_F(INFO, "After block");

And this is the output:

2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:102   INFO| Start of block
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:33    INFO| MyContainer
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:104   INFO| before beginModalViewSession...
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:44    INFO| MyContainer::remember
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:44    INFO| MyContainer::remember
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:44    INFO| MyContainer::remember
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:49    INFO| MyContainer::forget
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:106   INFO| after beginModalViewSession.
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:107   INFO| before endModalViewSession...
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:44    INFO| MyContainer::remember
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:49    INFO| MyContainer::forget
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:49    INFO| MyContainer::forget
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:49    INFO| MyContainer::forget
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:49    INFO| MyContainer::forget
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:56    INFO| MyContainer::beforeDelete
2020-08-07 07:55:12.724 (   4.803s) [            8A01]JTPTextButtonController:38    INFO| ~MyContainer
2020-08-07 07:55:12.724 (   4.804s) [            8A01]JTPTextButtonController:109   INFO| after endModalViewSession.
2020-08-07 07:55:12.724 (   4.804s) [            8A01]JTPTextButtonController:110   INFO| End of block
Exception: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

Or in other words:

beginModalViewSession does 3 remember + 1 forget => 2 remember
endModalViewSession does 1 remember and 4 forget => 3 forget

This would make sense IF the modal view session API was taking ownership of the view provided. As I pointed out this is the API for this call

	/** begin a new modal view session
	 *
	 *	A modal view session is active until endModalViewSession is called and in that time all UI
	 *	events are only dispatched to the modal view or its child views.
	 *	Modal view sessions can be stacked but must be ended in the same order.
	 *
	 *	@param view new modal view (ownership is shared with the caller)
	 *	@return a unique session identifier
	 */

So which one is wrong? Is the code meant to take ownership and the comment is wrong? Or is the comment right and the code is wrong and is missing a remember (or doing one too may forget)?

Thanks
Yan