|
From: | Bill Gray |
Subject: | Re: delwin() and deleting windows with subwindows |
Date: | Thu, 11 Aug 2022 22:31:43 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 |
On 8/11/22 17:53, G. Branden Robinson wrote:
At 2022-08-11T12:35:49-0400, Bill Gray wrote:Delete subwindows recursively, and that access attempts to read freed memory. One shouldn't be doing such things; once a parent window is deleted, you shouldn't try to do anything with the subwindow. But I'll bet you that some code does so, and recursive deletion would break that code.Why not implement recursive deletion for now, and see if anything squawks? Any application that chases pointers into freed memory is surely busted at a fundamental level, quite apart from violating the documented assumptions of the XSI Curses spec.
I was tempted to keep recursive deletion (the code was all written and tested), but I've chickened out.
The problem is that with any of the current approaches, you quite definitely _wouldn't_ be chasing pointers into freed memory, because the subwindow wouldn't actually be freed; you'd either get an error code, or only the parent window would be freed. The subwindow would remain as allocated memory and accesses to it would be safe. And as Thomas points out, exactly what the spec's "documented assumptions" are is a little ambiguous; I could be persuaded either way on that point.
Right now, ncurses, SVr4 curses, and PDCursesMod will just give you an error code if you delwin() a parent window... which means you may fail to free up memory you meant to free up, but I don't see any other downside to it. If you later call delscreen(), all windows and subwindows associated with that screen will be freed anyway, with both ncurses and PDCursesMod.
-- Bill
Regards, Branden
[Prev in Thread] | Current Thread | [Next in Thread] |