Re: big issues with state machine loading

Peter Soetens <[email protected]> Wed, 12 Feb 2014 22:50:45 +0100
Newsgroups gmane.science.robotics.orocos.devel
Message-ID <CAMYDobULp0GeKbMaFhX2Bi6u1uqvm5OzD2gRpDffp6sjWKb71w@mail.gmail.com>
Hi Thierry,

I found the problem. It must have been introduced during the porting
to Visual Studio. The fix for v2.x is in attachment. The problem was
that the skip parser needs to be stored on the stack, while it got
destructed when passed to the iterator.

I've pushed the fixes already to master and toolchain-2.7, but it's
indeed present in many versions.

Peter

On Wed, Feb 12, 2014 at 10:34 PM, Thierry Bultel <[email protected]> wrote:
> Le 12/02/2014 22:00, Peter Soetens a écrit :
>
> On Tue, Feb 11, 2014 at 9:53 PM, Thierry Bultel <[email protected]> wrote:
>
> Le 11/02/2014 21:43, Peter Soetens a écrit :
>
> On Tue, Feb 11, 2014 at 3:05 PM, Thierry Bultel <[email protected]> wrote:
>
> Le 11/02/2014 14:31, Peter Soetens a écrit :
>
> On Tue, Feb 11, 2014 at 10:18 AM, Thierry Bultel <[email protected]>
> wrote:
>
> Le 11/02/2014 10:01, Peter Soetens a écrit :
>
>
>
> On Sat, Feb 8, 2014 at 9:30 AM, Thierry Bultel <[email protected]> wrote:
>
> Hi all,
>
> We are currently evaluating orocos toolchain 2.7rc3
> My configuration is :
>
> - boost-1.53.0
> - gcc-4.7.3
>
> The test sample is the helloworld.cpp from the tutorials; here is the
> state machine script:
>
> StateMachine States {
>
>           initial state initState
>           {
>                   entry
>                   {
>                   }
>
>                   transition select Final
>           }
>           final state Final
>           {
>                   entry
>                   {
>                   }
>
> //
>           }
> }
>
> RootMachine  States sTates
>
>
> I am testing on 2 target architectures, the first one is intel and the
> second, arm
> The bug I am mentioning here occur one the real targets, as well as
> with
> qemu user.
>
> On intel, comments (both "//" and "/* ...*/" )in state machine are
> detected as errors:
>
> Hello [R]> scripting.loadStateMachines("statemachine.osd")
> 6.129 [ Info   ][ScriptingService::loadStateMachine] Parsing file
> statemachine.osd
> 6.247 [ ERROR  ][ScriptingService::loadStateMachine] statemachine.osd
> :Parse error at line 18: Syntactic error: Exptected ending '}' at end
> of
> state ( or could not find out what this line means ).
>    = false
>
> I can't reproduce this. An equally likely reason is the difference in
> Boost version, since boost::spirit changes from time to time. I'm
> using Boost 1.46.
>
> Peter,
>
> I do not quite agree. As I said, I can reproduce the bug with boost-1.35
> /
> orocos-1.x, too, If I upgrade from gcc-4.3.2 (from Debian )
> to gcc-4.7.3 (from buildroot).
> And it is not -only- related to comments, since a comment-less state
> machine
> crashes as well.
>
> Please tell me if you need more things, for instance I can provide you
> with
> our gcc toolchain and sysroot,
> as well as qemu-arm.
>
> Thanks for clarifying ! So the compiler it is...
>
> I'll start with setting up a virtual Ubuntu raring 64bit system which
> has gcc 4.7.3.
>
> That should do it to reproduce it.
>
> If you stay with x86 architecture, it will not crash but the "comment" bug
> will be the clue (hopefully)
>
> Hmm. a bunch of unit tests crash with the 4.7 and the 4.8 compiler,
> but the state machine unit test only crashes with 4.7 (Ubuntue 13.04)
> and goes fine with 4.8 (Ubuntu 13.10) both compiled in Debug mode.
>
> To summarise, Orocos 2.7 does not work on raring or saucy yet. This is
> not nice, since initial gdb and valgrind traces did not point at
> something obvious...and it is working on a bunch of other compilers
> (including Visual Studio 2010 and LLVM/clang)
>
> Peter
>
>
> Thanks Peter,
>
> Could you please point us the test results, or the way to run them ourselves
> ?
> On our side, seeing what it working or not, we could maybe consider
> upgrading
> to gcc-4.8, if feasible.
>
> If it can help you in your investigation, the bug is likely not a regression
> from an Orocos version to another, because it happens with our very old one,
> too.
>
> Regards
> Thierry

-- 
Orocos-Dev mailing list
[email protected]
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev
0001-scripting-fix-crash-of-skip-parser-definition.patch (text/x-patch, 2.1 KB)
From ab344c8dc948201ebab84c4cc96b7d0d1365e971 Mon Sep 17 00:00:00 2001
From: Peter Soetens <[email protected]>
Date: Wed, 12 Feb 2014 22:46:04 +0100
Subject: [PATCH 1/2] scripting: fix crash of skip parser definition

The parsers were not saved on the stack, causing a segfault later-on.

Signed-off-by: Peter Soetens <[email protected]>
---
 rtt/scripting/ProgramGraphParser.cpp |    5 ++---
 rtt/scripting/StateGraphParser.cpp   |    3 ++-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/rtt/scripting/ProgramGraphParser.cpp b/rtt/scripting/ProgramGraphParser.cpp
index 102f38b..f6935dd 100644
--- a/rtt/scripting/ProgramGraphParser.cpp
+++ b/rtt/scripting/ProgramGraphParser.cpp
@@ -674,9 +674,8 @@ namespace RTT
   {
       // end is not used !
     iter_t begin_copy = begin;
-    //skip_parser_t skip_parser = SKIP_PARSER;
-    //iter_pol_t iter_policy( skip_parser );
-    iter_pol_t iter_policy( ( comment_p( "#" ) | comment_p( "//" ) | comment_p( "/*", "*/" ) | (space_p - eol_p) | commonparser.skipper  ) );
+    skip_parser_t skip_parser = comment_p( "#" ) | comment_p( "//" ) | comment_p( "/*", "*/" ) | (space_p - eol_p) | commonparser.skipper;
+    iter_pol_t iter_policy( skip_parser );
     scanner_pol_t policies( iter_policy );
     scanner_t scanner( begin, end, policies );
     program_list.clear();
diff --git a/rtt/scripting/StateGraphParser.cpp b/rtt/scripting/StateGraphParser.cpp
index 57d5969..3d253e7 100644
--- a/rtt/scripting/StateGraphParser.cpp
+++ b/rtt/scripting/StateGraphParser.cpp
@@ -720,7 +720,8 @@ namespace RTT
         //skip_parser_t skip_parser = SKIP_PARSER;
         //iter_pol_t iter_policy( skip_parser );
 		//#define SKIP_PARSER
-        iter_pol_t iter_policy( ( comment_p( "#" ) | comment_p( "//" ) | comment_p( "/*", "*/" ) | (space_p - eol_p) | commonparser->skipper  ) );
+      skip_parser_t skip_parser = comment_p( "#" ) | comment_p( "//" ) | comment_p( "/*", "*/" ) | (space_p - eol_p) | commonparser->skipper;
+      iter_pol_t iter_policy( skip_parser );
         scanner_pol_t policies( iter_policy );
         scanner_t scanner( begin, end, policies );
 
-- 
1.7.9.5