octave-maintainers
[Top][All Lists]
Advanced

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

Re: Thread-safety issues in QtHandles


From: John W. Eaton
Subject: Re: Thread-safety issues in QtHandles
Date: Fri, 4 Nov 2011 21:01:40 -0400

On  4-Nov-2011, Michael Goffioul wrote:

| I tried it and got finally rid of the random crashes. My test case is
| to start the mirone GUI (which is a pretty heavy user of ui* stuff)
| and before all the changes, I could get a crash 50% of the time. Now,
| I've launched the GUI 10-15 times and didn't get a single crash.

OK.  I propose the change attached below.  We can make it permanent
later and actually remove the calls to DECLARE/DEFINE_OCTAVE_ALLOCATOR.

However, after doing this, I see a large number of problems from
valgrind, mostly about using uninitialized values.  I have to do more
testing to see whether these are actually not showing up if I use the
octave_allocator class.  But even if they are not, I'd bet that a
number of the problems are not new but are just showing up now because
the memory handed out by the octave_allocator class could have been
initialized for a previous use but still not actually initialized for
the current allocation.  But in that case, valgrind wouldn't flag it.

I'll do more testing and try to fix as many of the problems as I can.

I'll also see about adding a "check-with-valgrind" target in the
Makefile to make running the tests with valgrind easy to do.  It would
be nice if running the tests with valgrind didn't show any
problems...  If I can get close to that and there are no objections,
I'll check in the changes below.

jwe

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -167,6 +167,15 @@
   AC_DEFINE(BOUNDS_CHECKING, 1, [Define to use internal bounds checking.])
 fi
 
+USE_OCTAVE_ALLOCATOR=false
+AC_ARG_ENABLE(octave-allocator,
+  [AS_HELP_STRING([--enable-octave-allocator],
+     [use the obsolete octave_allocator class for many of Octave's objects 
(mostly octave_value types).  You probably do NOT want to enable this feature.  
(default is no)])],
+  [if test "$enableval" = yes; then USE_ALLOCATOR=true; fi], [])
+if $USE_OCTAVE_ALLOCATOR; then
+  AC_DEFINE(USE_OCTAVE_ALLOCATOR, 1, [Define to use octave_allocator class.])
+fi
+
 ### Make it possible to disable running Make in the doc directory.
 ### Useful for building on systems without TeX, for example.
 DOCDIR=doc
@@ -2188,6 +2197,7 @@
   gnuplot:                     $GNUPLOT
 
   Do internal array bounds checking:  $BOUNDS_CHECKING
+  Use octave_allocator:               $USE_OCTAVE_ALLOCATOR
   Build static libraries:             $STATIC_LIBS
   Build shared libraries:             $SHARED_LIBS
   Dynamic Linking:                    $ENABLE_DYNAMIC_LINKING $DL_API_MSG
diff --git a/liboctave/oct-alloc.h b/liboctave/oct-alloc.h
--- a/liboctave/oct-alloc.h
+++ b/liboctave/oct-alloc.h
@@ -72,6 +72,8 @@
       { ::operator delete (p); }
 #endif
 
+#if defined (USE_OCTAVE_ALLOCATOR)
+
 #define DECLARE_OCTAVE_ALLOCATOR \
   public: \
     void *operator new (size_t size, void *p) \
@@ -88,4 +90,12 @@
 #define DEFINE_OCTAVE_ALLOCATOR2(t, s) \
   octave_allocator t::allocator (sizeof (t), s)
 
+#else
+
+#define DECLARE_OCTAVE_ALLOCATOR
+#define DEFINE_OCTAVE_ALLOCATOR(t)
+#define DEFINE_OCTAVE_ALLOCATOR2(t, s)
+
 #endif
+
+#endif

reply via email to

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