octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #62459] Severe memory leak when functions are


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #62459] Severe memory leak when functions are nested
Date: Mon, 16 May 2022 18:51:54 -0400 (EDT)

Follow-up Comment #10, bug #62459 (project octave):

Reviewing the ASAN logs, I think I see the roots of the deadlock, but it is
still not 100% clear:

* An anonymous function (named say f_anon or f_blah) is created. At this point
it has made one copy of the input matrix p. It has not been called yet.

* A nested function calls the anonymous function f_anon which was defined in
the enclosing scope. At this point a fresh copy of memory seems to be
allocated for that invocation of the anonymous function.

* When the nested function exits, it does not realize that memory was
allocated on its behalf when it invoked the anonymous function, so it does not
know to release it. The destructors for those temporary variables are not
called.

* The anonymous function does not know that its caller has exited and
therefore does not know to release the memory either.

In effect, any destructors that might be called ordinarily are blocked by the
anonymous function waiting for its caller nested function. In C++ terminology,
RAII is prevented by the interaction between the nested function and the
anonymous function.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62459>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]