From: Alexei Sheplyakov Date: Tue, 1 Jul 2014 18:46:11 +0000 (+0300) Subject: [bugfix] log_series: avoid infinite recursion X-Git-Tag: release_1-6-3~11 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=13964f3416ec9de8829b57d4a2bbd9fe9a6db4ef;hp=edfa67d26bac695b5ef9911f3cda3ff50232e35a;ds=sidebyside [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. --- 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