]> www.ginac.de Git - ginac.git/commitdiff
[bugfix] log_series: avoid infinite recursion
authorAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Tue, 1 Jul 2014 18:46:11 +0000 (21:46 +0300)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Mon, 21 Jul 2014 05:45:10 +0000 (08:45 +0300)
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
ginac/inifcns_trans.cpp

index 3a1a36b5bd8d3c615a8ee3211efd782626e0a84a..2fe28415ecaed6c8734b8396b5ceb6db14a88e1f 100644 (file)
@@ -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<pseries>(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;
 }
 
index c5551f75a2e77e4c247914d4cd531df458b7b1c9..682a981b772f3bda2854bf187698980b995a7084 100644 (file)
@@ -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<symbol>(rel.lhs())).is_zero()) {
+               throw do_taylor();
+       }
+
        if (must_expand_arg) {
                // method:
                // This is the branch point: Series expand the argument first, then