octave-maintainers
[Top][All Lists]
Advanced

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

Re: Function lock and octave call stack (Was: seg-fault for default bran


From: John W. Eaton
Subject: Re: Function lock and octave call stack (Was: seg-fault for default branch on Mac OSX?)
Date: Wed, 03 Sep 2008 11:38:54 -0400

On  3-Sep-2008, Michael Goffioul wrote:

| On Tue, Sep 2, 2008 at 9:16 PM, John W. Eaton <address@hidden> wrote:
| > The idea was that mlock would only be used inside Fmlock, so we should
| > get the caller (i.e., the .m file that called Fmlock), not the current
| > function (Fmlock).
| 
| This makes sense.
| 
| > Maybe we should define a separate internal function (or allow an
| > argument to the current mlock function) to allow locking the current
| > function on the call stack.
| 
| It's as easy as octave_call_stack::top()->lock(). But I was confused
| by the mlock() function presence. If this function is only intended
| to be used from Fmlock, then maybe its code should be inlined
| directly in Fmlock. Then you could redefine the C++ mlock to lock
| the function on the top of the stack. This seems more natural to me.

OK, how about the following change?  I see that mlock is also used in
mexLock, but I think incorrectly, since it seems it should be locking
the current mex function, not the calling function.

Thanks,

jwe

# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1220456171 14400
# Node ID 16ab78b816bc8ec897bd8c00934fc2e79a6cbc48
# Parent  163d20e4d39c450943e56e3b366ce671e384c232
variables.cc (mlock): lock current function

diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,7 @@
 2008-09-03  John W. Eaton  <address@hidden>
+
+       * variables.cc (mlock): Lock current function on the call stack.
+       (Fmlock): Lock caller.
 
        * symtab.cc (out_of_date_check_internal): If dispatch type is set,
        check for method.  If that fails, check for regular function. 
diff --git a/src/variables.cc b/src/variables.cc
--- a/src/variables.cc
+++ b/src/variables.cc
@@ -1888,7 +1888,7 @@
 void 
 mlock (void)
 {
-  octave_function *fcn = octave_call_stack::caller ();
+  octave_function *fcn = octave_call_stack::current ();
 
   if (fcn)
     fcn->lock ();
@@ -1938,7 +1938,14 @@
   octave_value_list retval;
 
   if (args.length () == 0)
-    mlock ();
+    {
+      octave_function *fcn = octave_call_stack::caller ();
+
+      if (fcn)
+       fcn->lock ();
+      else
+       error ("mlock: invalid use outside a function");
+    }
   else
     print_usage ();
 

reply via email to

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