From 4ab6d8f658166e94c24af1676a22474da261f267 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 10 Sep 2014 10:43:32 +0200 Subject: [PATCH 1/4] fixed clone method for IndexRangeNode --- arangod/Aql/Optimizer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arangod/Aql/Optimizer.cpp b/arangod/Aql/Optimizer.cpp index 9422ff3f8a..8eea00c1a6 100644 --- a/arangod/Aql/Optimizer.cpp +++ b/arangod/Aql/Optimizer.cpp @@ -124,7 +124,7 @@ int Optimizer::createPlans (ExecutionPlan* plan, int level; auto p = _plans.pop_front(level); - if (level == maxRuleLevel) { + if (level >= maxRuleLevel) { _newPlans.push_back(p, level); // nothing to do, just keep it } else { // find next rule @@ -181,7 +181,7 @@ int Optimizer::createPlans (ExecutionPlan* plan, break; } } - + TRI_ASSERT(_plans.size() >= 1); estimatePlans(); From f053299f9a1e39f07967a8ebf2e93a30536984b2 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 10 Sep 2014 10:54:11 +0200 Subject: [PATCH 2/4] check memory --- lib/BasicsC/common.h | 99 ++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/lib/BasicsC/common.h b/lib/BasicsC/common.h index 7d50acabf0..422adb89f4 100644 --- a/lib/BasicsC/common.h +++ b/lib/BasicsC/common.h @@ -156,7 +156,7 @@ static inline void* CONST_CAST (void const* ptr) { /// @brief incrementing a uint64_t modulo a number with wraparound //////////////////////////////////////////////////////////////////////////////// -static inline uint64_t TRI_IncModU64(uint64_t i, uint64_t len) { +static inline uint64_t TRI_IncModU64 (uint64_t i, uint64_t len) { // Note that the dummy variable gives the compiler a (good) chance to // use a conditional move instruction instead of a branch. This actually // works on modern gcc. @@ -165,7 +165,7 @@ static inline uint64_t TRI_IncModU64(uint64_t i, uint64_t len) { return i < len ? i : dummy; } -static inline uint64_t TRI_DecModU64(uint64_t i, uint64_t len) { +static inline uint64_t TRI_DecModU64 (uint64_t i, uint64_t len) { if ((i--) != 0) { return i; } @@ -203,12 +203,11 @@ static inline uint64_t TRI_DecModU64(uint64_t i, uint64_t len) { #endif #endif -static inline void _backtrace(void) -{ +static inline void _backtrace (void) { #if HAVE_BACKTRACE - void *stack_frames[50]; + void* stack_frames[50]; size_t size, i; - char **strings; + char** strings; size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*)); strings = backtrace_symbols(stack_frames, size); @@ -234,41 +233,45 @@ static inline void _backtrace(void) // if the line could be processed, attempt to demangle the symbol if (mangled_name && offset_begin && offset_end && mangled_name < offset_begin) { - *mangled_name++ = '\0'; - *offset_begin++ = '\0'; - *offset_end++ = '\0'; - int status = 0; - char * demangled_name = abi::__cxa_demangle(mangled_name, 0, 0, &status); - if (status == 0) { - fprintf(stderr, "%s() [%p] %s\n", strings[i], stack_frames[i], demangled_name); - } - else { - fprintf(stderr, "%s\n", strings[i]); - } - free(demangled_name); + *mangled_name++ = '\0'; + *offset_begin++ = '\0'; + *offset_end++ = '\0'; + int status = 0; + char * demangled_name = abi::__cxa_demangle(mangled_name, 0, 0, &status); + if (demangled_name != nullptr) { + if (status == 0) { + fprintf(stderr, "%s() [%p] %s\n", strings[i], stack_frames[i], demangled_name); + } + else { + fprintf(stderr, "%s\n", strings[i]); + } + TRI_SystemFree(demangled_name); + } } else #endif - { - fprintf(stderr, "%s\n", strings[i]); - } + { + fprintf(stderr, "%s\n", strings[i]); + } } - else + else { fprintf(stderr, "[%p]\n", stack_frames[i]); + } + } + if (strings != NULL) { + TRI_SystemFree(strings); } - free(strings); #endif } #ifdef __cplusplus #include #include -static inline void _getBacktrace(std::string &btstr) -{ +static inline void _getBacktrace (std::string& btstr) { #if HAVE_BACKTRACE - void *stack_frames[50]; + void* stack_frames[50]; size_t size, i; - char **strings; + char** strings; size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*)); strings = backtrace_symbols(stack_frames, size); @@ -300,26 +303,28 @@ static inline void _getBacktrace(std::string &btstr) *offset_end++ = '\0'; int status = 0; char * demangled_name = abi::__cxa_demangle(mangled_name, 0, 0, &status); - if (status == 0) { - ss << stack_frames[i]; - btstr += strings[i] + - std::string("() [") + - ss.str() + - std::string("] ") + - demangled_name + - std::string("\n"); + + if (demangled_name != nullptr) { + if (status == 0) { + ss << stack_frames[i]; + btstr += strings[i] + + std::string("() [") + + ss.str() + + std::string("] ") + + demangled_name + + std::string("\n"); + } + else { + btstr += strings[i] + + std::string("\n"); + } + TRI_SystemFree(demangled_name); } - else { - btstr += strings[i] + - std::string("\n"); - } - free(demangled_name); } - else - { - btstr += strings[i] + - std::string("\n"); - } + else { + btstr += strings[i] + + std::string("\n"); + } } else { ss << stack_frames[i]; @@ -327,7 +332,9 @@ static inline void _getBacktrace(std::string &btstr) std::string("\n"); } } - free(strings); + if (string != NULL) { + TRI_SystemFree(strings); + } #endif } #endif From ba21bf401920c860825fa4470c433a3b0499598d Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 10 Sep 2014 10:54:32 +0200 Subject: [PATCH 3/4] fixed cloning of IndexRangeNodes --- arangod/Aql/ExecutionNode.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arangod/Aql/ExecutionNode.h b/arangod/Aql/ExecutionNode.h index f020589c9b..c621c08661 100644 --- a/arangod/Aql/ExecutionNode.h +++ b/arangod/Aql/ExecutionNode.h @@ -910,6 +910,8 @@ namespace triagens { virtual ExecutionNode* clone () const { std::vector> ranges; for (size_t i = 0; i < _ranges.size(); i++){ + ranges.push_back(std::vector()); + for (auto x: _ranges.at(i)){ ranges.at(i).push_back(x); } From 4c91bce5a762766380ac69e030fcc843af731408 Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Wed, 10 Sep 2014 11:06:29 +0200 Subject: [PATCH 4/4] fix typo --- lib/BasicsC/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/BasicsC/common.h b/lib/BasicsC/common.h index 422adb89f4..97fd75a57e 100644 --- a/lib/BasicsC/common.h +++ b/lib/BasicsC/common.h @@ -332,7 +332,7 @@ static inline void _getBacktrace (std::string& btstr) { std::string("\n"); } } - if (string != NULL) { + if (strings != NULL) { TRI_SystemFree(strings); } #endif