[haiku-bugs] Re: [Haiku] #12286: Menus seem to be leaking ports

  • From: "jackburton" <trac@xxxxxxxxxxxx>
  • Date: Thu, 06 Aug 2015 15:08:44 -0000

#12286: Menus seem to be leaking ports
----------------------------------+----------------------------
Reporter: ttcoder | Owner: axeld
Type: bug | Status: new
Priority: high | Milestone: R1/beta1
Component: Kits/Interface Kit | Version: R1/Development
Resolution: | Keywords:
Blocked By: | Blocking:
Has a Patch: 0 | Platform: All
----------------------------------+----------------------------

Comment (by jackburton):

Replying to [comment:16 bonefish]:

Replying to [comment:13 jackburton]:

I guess commit 285b7163ad41e00841d0dc28b48fe10902a350bc is the culprit
then, since it changed the code to use MouseDownThread(), which calls
kill_thread instead of wait_for_thread.

I don't see the "instead". The use of `MouseDownThread` just seems to be
an addition.

Yeah, sorry, I misread the commit message.
By the way, maybe John could explain that change, because I don't
understand it completely. It seems that now two threads are used instead
of one.


Replying to [comment:14 jackburton]:
MouseDownThread is also used in Tracker (DialogPane) and Deskbar
(ExpandoMenuBar), so before changing the kill_thread() to
wait_for_thread() we should review its usage there, too.

`wait_for_thread()` is not correct either, since in that case the thread
itself invokes the destructor. With `kill_thread()` it commits suicide,
with `wait_for_thread()` it would wait for itself (not sure off the top of
my head, if that would cause it to hang indefinitely or return an error).
`exit_thread()` would be more correct (when invoked from the thread
itself), but it would still leak the allocated memory.

As is the class is simply badly designed. And yes, its other uses should
be checked as well before changing anything.

@Bonefish: Is there no way to force kill_thread() to kill the used
ports, too ?

No. `kill_thread()` is even [https://www.haiku-os.org/legacy-
docs/bebook/TheKernelKit_ThreadsAndTeams.html#kill_thread documented in
the BeBook] as being problematic with respect to resource leaks. It should
be used only as a last resort.

Ok, thank you.

--
Ticket URL: <https://dev.haiku-os.org/ticket/12286#comment:17>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: