From: Alexei Sheplyakov Date: Mon, 4 Oct 2010 07:21:05 +0000 (+0200) Subject: Avoid infinite loop when unarchiving realsymbol and possymbol. X-Git-Tag: release_1-6-0~18^2~1^2~6 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=c40c54f17b68f79ee42833adb3364970385e2caa Avoid infinite loop when unarchiving realsymbol and possymbol. symbol::read_archive(): explicitly set status_flags::evaluated (and status_flags::expanded) on object being unarchived. These flags get reset by basic::operator=(const basic&) for realsymbol and possymbol, and nothing sets (except symbol ctor), so automatic evaluation never terminates (or rather, terminates due to a stack overflow). Therefore it's necessary need to set status_flags::evaluated explicitly. Thanks to Markus Fröb for a bugreport and a test case. (cherry picked from commit e99d0d58c1bbaa8ee73e4a90a90aa1086f2f813d) --- diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index 9897bb4c..c9db110f 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -109,6 +109,15 @@ void symbol::read_archive(const archive_node &n, lst &sym_lst) for (lst::const_iterator it = sym_lst.begin(); it != sym_lst.end(); ++it) { if (is_a(*it) && (ex_to(*it).name == tmp_name)) { *this = ex_to(*it); + // XXX: This method is responsible for reading realsymbol + // and possymbol objects too. But + // basic::operator=(const basic& other) + // resets status_flags::evaluated if other and *this are + // of different types. Usually this is a good idea, but + // doing this for symbols is wrong (for one, nothing is + // going to set status_flags::evaluated, evaluation will + // loop forever). Therefore we need to restore flags. + setflag(status_flags::evaluated | status_flags::expanded); return; } }