unintialize value fixed and std::atomic used in Runner 75/17075/2
Cedric Delamarre [Thu, 20 Aug 2015 15:29:41 +0000 (17:29 +0200)]
Change-Id: I84c35ac62b7c662eb0fa04e8f282a292d3425248

scilab/modules/core/includes/runner.hxx
scilab/modules/core/src/cpp/runner.cpp
scilab/tools/profiling/valgrind.supp

index 15dbe57..7ed90b3 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef __RUNNER_HXX__
 #define __RUNNER_HXX__
 
+#include <atomic>
+
 #include "exp.hxx"
 #include "execvisitor.hxx"
 
@@ -30,6 +32,7 @@ public :
         m_theProgram = _theProgram;
         m_visitor = _visitor;
         m_isConsoleCommand = false;
+        m_isInterruptible = true;
     }
 
     Runner(ast::Exp* _theProgram, ast::ExecVisitor *_visitor, bool _isConsoleCommand, bool _isInterruptible)
@@ -89,8 +92,8 @@ public:
     static void exec(ast::Exp* _theProgram, ast::ExecVisitor *_visitor);
 
 private:
-    static Runner* m_RunMe;
-    static bool m_bInterruptibleCommand;
+    static std::atomic<Runner*> m_RunMe;
+    static std::atomic<bool> m_bInterruptibleCommand;
 };
 
 extern "C"
@@ -101,4 +104,4 @@ extern "C"
     void StaticRunner_setInterruptibleCommand(int val);
 }
 
-#endif /* !__RUNNER_HXX__ */
\ No newline at end of file
+#endif /* !__RUNNER_HXX__ */
index 5982dce..eabfb2a 100644 (file)
@@ -24,8 +24,8 @@ extern "C"
 
 using namespace ast;
 
-Runner* StaticRunner::m_RunMe = NULL;
-bool StaticRunner::m_bInterruptibleCommand = true;
+std::atomic<Runner*> StaticRunner::m_RunMe(nullptr);
+std::atomic<bool> StaticRunner::m_bInterruptibleCommand(true);
 
 void StaticRunner::launch()
 {
@@ -105,35 +105,25 @@ void StaticRunner::setRunner(Runner* _RunMe)
 
 Runner* StaticRunner::getRunner(void)
 {
-    ThreadManagement::LockRunner();
     Runner* tmp = m_RunMe;
     m_RunMe = NULL;
-    ThreadManagement::UnlockRunner();
     ThreadManagement::SendAvailableRunnerSignal();
     return tmp;
 }
 
 bool StaticRunner::isRunnerAvailable(void)
 {
-    ThreadManagement::LockRunner();
-    bool bOut = m_RunMe != NULL;
-    ThreadManagement::UnlockRunner();
-    return bOut;
+    return m_RunMe != NULL;
 }
 
 void StaticRunner::setInterruptibleCommand(bool _bInterruptibleCommand)
 {
-    ThreadManagement::LockRunner();
     m_bInterruptibleCommand = _bInterruptibleCommand;
-    ThreadManagement::UnlockRunner();
 }
 
 bool StaticRunner::isInterruptibleCommand()
 {
-    ThreadManagement::LockRunner();
-    bool bIsInterruptibleCommand = m_bInterruptibleCommand;
-    ThreadManagement::UnlockRunner();
-    return bIsInterruptibleCommand;
+    return m_bInterruptibleCommand;
 }
 
 void StaticRunner::execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor,
@@ -157,10 +147,8 @@ void StaticRunner::execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor
 
 void StaticRunner::exec(ast::Exp* _theProgram, ast::ExecVisitor *_visitor)
 {
-    ThreadManagement::LockRunner();
     Runner *runMe = new Runner(_theProgram, _visitor);
     setRunner(runMe);
-    ThreadManagement::UnlockRunner();
     launch();
 }
 
index 99b669d..d0160ad 100644 (file)
    fun:tgetstr
 }
 {
-   dlerror leak thread local storage memory
+   dynamic-leak/dlerror_run
    Memcheck:Leak
    match-leak-kinds: reachable
-   fun:calloc
+   ...
    fun:_dlerror_run
 }
 {
-   pthread_create will be clear on exit
+   dynamic-leak/dl_init
+   Memcheck:Leak
+   match-leak-kinds: reachable
+   ...
+   fun:_dl_init
+}
+{
+   dynamic-leak/dl_allocate_tls
    Memcheck:Leak
    match-leak-kinds: possible
-   fun:calloc
-   fun:allocate_dtv
+   ...
    fun:_dl_allocate_tls
-   fun:allocate_stack
-   fun:pthread_create@@GLIBC_2.2.5
-   fun:__CreateThreadWithParams
-   fun:interactiveMain
-   fun:RunScilabEngine
-   fun:main
+   ...
 }