From 13964f3416ec9de8829b57d4a2bbd9fe9a6db4ef Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Tue, 1 Jul 2014 21:46:11 +0300 Subject: [PATCH 1/1] [bugfix] log_series: avoid infinite recursion Check if the argument is on a branch cut check if it actually depends on the expansion variable before trying to expand around a different point in order to avoid the infinite recursion (or rather a segfault due to a stack overflow). Thanks to Mario Prausa for a bugreport. --- check/exam_inifcns.cpp | 9 +++++++++ ginac/inifcns_trans.cpp | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/check/exam_inifcns.cpp b/check/exam_inifcns.cpp index 3a1a36b5..2fe28415 100644 --- a/check/exam_inifcns.cpp +++ b/check/exam_inifcns.cpp @@ -318,6 +318,15 @@ static unsigned inifcns_consist_log() if (ex(log(pow(a,b))).is_equal(b*log(a))) ++result; + // infinite recursion log_series + ex e(log(-p)); + ex ser = ex_to(e.series(z, 1)) + .convert_to_poly(/* no_order = */ true); + if (!ser.is_equal(e)) { + clog << "series(" << e << ", " << z << "): wrong result" << endl; + ++result; + } + return result; } diff --git a/ginac/inifcns_trans.cpp b/ginac/inifcns_trans.cpp index c5551f75..682a981b 100644 --- a/ginac/inifcns_trans.cpp +++ b/ginac/inifcns_trans.cpp @@ -204,6 +204,10 @@ static ex log_series(const ex &arg, if (arg_pt.is_zero()) must_expand_arg = true; + if (arg.diff(ex_to(rel.lhs())).is_zero()) { + throw do_taylor(); + } + if (must_expand_arg) { // method: // This is the branch point: Series expand the argument first, then -- 2.44.0