Re: crash in GUI / ProjectCenter

Riccardo Mottola <[email protected]> Fri, 13 Jan 2023 01:46:58 +0100
Newsgroups gmane.comp.lib.gnustep.devel
Organization GNUstep
Message-ID <66264de92e5c59a67cf234cb09170a74@narya>
Hi Wolfgang!


I had a nice hacking session with Fred this evening and ... fresh 
mind, new fixes.!

I found the memory issue - there was an issue with subview! 
ProjectCenter had some complex code where a subview was released 
twice.
I was able to refactor things and keep vars more localy and fix that. 
Thanks for the "hint".

On 2023-01-11 12:46:36 +0100 Wolfgang Lux <[email protected]> 
wrote:


> 
> I'm not so sure about my suggested fix/hack. Certainly, it does the 
> job and I 
> don't see a reason why a window should be updating its cursor 
> rectangles 
> after the window has been closed (at least if it is supposed to be 
> released 
> at that point). Another option would likely be to close the backend 
> connection more swiftly when a window is closed. For instance, in 
> -[NSWindow 
> orderWindow:relativeTo:] we might change the last condition from
>   else if ([self isOneShot])
> to
>   else if ([self isOneShot] || (_f.has_closed && 
> _f.is_released_when_closed))
> to close the backend window immediately rather than waiting for this 
> to 
> happen from an autorelease pool.
> 
> One thing that is worrying is that you saw a crash even when 
> resetting the 
> delegates in the dealloc method. The stacktrace looks like -[NSWindow 
> resetCursorRects] gets called for a window with a corrupted view 
> hierarchy 
> where a child window seems to have been deallocated while it is still 
> present 
> in the hierarchy. This is something that should never happen (at 
> least not 
> where sendEvent: can possibly be called). So maybe there is some 
> other memory 
> management bug at play here.

now the delegate problem remains "only". I am able to work-around this 
now, with this patch:

+++ b/Framework/PCProjectWindow.m
@@ -260,6 +260,8 @@
  - (void)dealloc
  {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
+  [h_split setDelegate:nil];
+  [v_split setDelegate:nil];
    [projectWindow close];

    [super dealloc];

unsetting the delegate and fixing the view release issue.. solves the 
crash, at least for ProjectCenter.
Where else where you experiencing the issue?

We need to think if this delegate-to-nil fix is proper of GUI orthe 
GUI code is safe and the work-around in ProjectCenter is fine. 
However, if you noticed things elsewhere, we might need to check.

What's your point? Fred?

Riccardo

-- 
Sent with pride with GNUMail running on GNUstep on Debian GNU/Linux on 
a SunFire with Niagara SPARC64.