← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1070706 into lp:zorba

 

Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/bug-1070706 into lp:zorba.

Commit message:
Fixes a bug that leads to a crash if there are inline, anonymous functions in a stack trace.

Requested reviews:
  Markos Zaharioudakis (markos-za)
  Sorin Marian Nasoi (sorin.marian.nasoi)
Related bugs:
  Bug #1070706 in Zorba: "FOTS: try-catch tests that SEG FAULT"
  https://bugs.launchpad.net/zorba/+bug/1070706

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1070706/+merge/133484

Fixes a bug that leads to a crash if there are inline, anonymous functions in a stack trace.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1070706/+merge/133484
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/diagnostics/xquery_stack_trace.cpp'
--- src/diagnostics/xquery_stack_trace.cpp	2012-09-19 21:16:15 +0000
+++ src/diagnostics/xquery_stack_trace.cpp	2012-11-08 14:10:36 +0000
@@ -15,12 +15,16 @@
  */
 #include "stdafx.h"
 
+#include "xquery_stack_trace.h"
+
 #include <typeinfo>
 
+#include <store/api/item_factory.h>
+#include <store/api/store.h>
+#include <system/globalenv.h>
 #include <zorba/xquery_exception.h>
 
 #include "diagnostic.h"
-#include "xquery_stack_trace.h"
 
 namespace zorba {
 
@@ -56,6 +60,17 @@
     XQueryStackTrace::fn_arity_type fn_arity,
     ZorbaException &ze ) 
 {
+  store::Item_t lPrintedFunctionName;
+  if (fn_name == NULL)
+  {
+    GENV_STORE.getItemFactory()->createQName(
+        lPrintedFunctionName,
+        "",
+        "inline",
+        "anonymous");
+  } else {
+    lPrintedFunctionName = fn_name;
+  }
   if ( XQueryException *const xe = dynamic_cast<XQueryException*>( &ze ) )
   {
     XQueryStackTrace &trace = xe->query_trace();
@@ -77,7 +92,7 @@
 
     trace.push(
       XQueryStackTrace::Entry(
-        diagnostic::to_QName<XQueryStackTrace::fn_name_type>( fn_name ),
+        diagnostic::to_QName<XQueryStackTrace::fn_name_type>( lPrintedFunctionName ),
         fn_arity,
         call_loc.getFilename().c_str(),
         call_loc.getLineBegin(),

=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-040.spec'
--- test/rbkt/Queries/zorba/HigherOrder/hof-040.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/HigherOrder/hof-040.spec	2012-11-08 14:10:36 +0000
@@ -0,0 +1,1 @@
+Error: http://www.w3.org/2005/xqt-errors:FOER0000

=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-040.xq'
--- test/rbkt/Queries/zorba/HigherOrder/hof-040.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/HigherOrder/hof-040.xq	2012-11-08 14:10:36 +0000
@@ -0,0 +1,5 @@
+declare namespace o = "http://www.zorba-xquery.com/options/features";;
+declare namespace err = "http://www.w3.org/2005/xqt-errors";;
+declare option o:enable "hof";
+
+function () { fn:error() } ()
\ No newline at end of file


Follow ups