Zorba 2.8 debug build test failure on Windows Server 2003

Bug #1154984 reported by moshangcheng
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
Critical
Markos Zaharioudakis

Bug Description

I built Zorba2.8 on Windows Server 2003 with VS2010 and ran test after build, but some test cases crashed. I found that these crashes are located at src\compiler\rewriter\rules\flwor_rules.cpp line 259. The following is the related code:
     for(; ite != end; ++ite)
      {
        var_expr* var = ite->second;
        int uses = expr_tools::count_variable_uses(theFlwor, var, 1, NULL);

        if (uses == 0 && !ite->first->isNonDiscardable())
        {
          gc->removeNonGroupingVar(ite);
          --ite;
          end = gc->endNonGroupVars();
        }
      }
According to C++ API, http://www.cplusplus.com/reference/vector/vector/erase/. The iterator pointing to ite and beyond are invalidated. So the behavior of "--ite" is unexpected. To solve this problem, the vector::erase() has a return value, an iterator pointing to the new location of the element that followed the last element erased. Maybe we change it to the following code:
  while(ite != end)
  {
 var_expr* var = ite->second;
 int uses = expr_tools::count_variable_uses(theFlwor, var, 1, NULL);

 if (uses == 0 && !ite->first->isNonDiscardable())
 {
   ite = gc->removeNonGroupingVar(ite);
   end = gc->endNonGroupVars();
 }
 else
 {
   ++ite;
 }
  }
And we should change the return value type of removeNonGroupingVar from "void" to "iterator".

Changed in zorba:
importance: Undecided → Critical
assignee: nobody → Markos Zaharioudakis (markos-za)
milestone: none → 2.9
tags: added: build-scripts
tags: added: windows
tags: added: segfault
removed: build-scripts
Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

The fix suggested by our user has been applied. Thanks!

Changed in zorba:
status: New → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.