[PATCH] found a memory leak in /ginac/excompiler.cpp
Hello, during a longer debugging session i identified a memory leak in ginac/excompiler.cpp at line 116 and 121. Please refer the attached patch that fixes the issue. Best regards Ettl Martin -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
Hi! Martin Ettl wrote:
during a longer debugging session i identified a memory leak in ginac/excompiler.cpp at line 116 and 121. Please refer the attached patch that fixes the issue.
Thanks for the patch. I've applied it. Out of curiosity: what platform was this (OS, compiler and C library) where this turned out to be an actual memory leak? Bye -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
Hello Richard, i used Ubuntu Linux 9.10 with g++-4.4. Thanks for applying the patch. Best regards Martin -------- Original-Nachricht --------
Datum: Thu, 13 May 2010 23:02:48 +0200 Von: "Richard B. Kreckel" <kreckel@ginac.de> An: GiNaC discussion list <ginac-list@ginac.de> Betreff: Re: [GiNaC-list] [PATCH] found a memory leak in /ginac/excompiler.cpp
Hi!
Martin Ettl wrote:
during a longer debugging session i identified a memory leak in ginac/excompiler.cpp at line 116 and 121. Please refer the attached patch that fixes the issue.
Thanks for the patch. I've applied it.
Out of curiosity: what platform was this (OS, compiler and C library) where this turned out to be an actual memory leak?
Bye -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/> _______________________________________________ GiNaC-list mailing list GiNaC-list@ginac.de https://www.cebix.net/mailman/listinfo/ginac-list
-- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
Hello, i have checked the source of the current git head from ginac with the static code analysis tool cppcheck (http://sourceforge.net/projects/cppcheck/). It found a few uninitialized variables, const correctness issues... Please refer the attached output ( it may help to make ginac even more stable): [time_lw_M2.cpp:160]: (Style) The scope of the variable count can be reduced [time_lw_N.cpp:64]: (Style) The scope of the variable count can be reduced [exam_cra.cpp:85]: (Style) Function parameter 'ntimes' is passed by value. It could be passed by reference instead. [exam_inifcns_nstdsums.cpp:236]: (Style) Variable 'digitsbuf' is assigned a value that is never used [time_uvar_gcd.cpp:1854]: (Style) Function parameter 'deg' is passed by value. It could be passed by reference instead. [time_uvar_gcd.cpp:1889]: (Style) Function parameter 'deg' is passed by value. It could be passed by reference instead. [mul_eval_memleak.cpp:84]: (Style) Variable 'n_failures' is assigned a value that is never used [time_lw_Qprime.cpp:78]: (Style) The scope of the variable count can be reduced [exam_mod_gcd.cpp:39]: (Style) Function parameter 'deg' is passed by value. It could be passed by reference instead. [exam_mod_gcd.cpp:41]: (Style) Function parameter 'deg' is passed by value. It could be passed by reference instead. [exam_mod_gcd.cpp:97]: (Style) Function parameter 'deg' is passed by value. It could be passed by reference instead. [timer.cpp:85]: (Style) Unused variable: elapsed [timer.cpp:100] -> [timer.h:43]: (Style) The function 'timer::running' can be const [time_lw_Q.cpp:66]: (Style) The scope of the variable count can be reduced [../doc/examples/compile2.cpp:41]: (Style) Unused variable: comp [../doc/examples/compile2.cpp:41]: (Style) Unused variable: nregions [../doc/examples/compile1.cpp:36]: (Style) Variable 'result' is not assigned a value [../ginac/remember.cpp:36]: (Style) Member variable not initialized in the constructor 'remember_table_entry::last_access' [../ginac/basic.h:112]: (Style) Member variable not initialized in the constructor 'basic::hashvalue' [../ginac/archive.h:66]: (Style) Member variable not initialized in the constructor 'property_info::count' [../ginac/archive.h:66]: (Style) Member variable not initialized in the constructor 'property_info::type' [../ginac/archive.h:77]: (Style) Member variable not initialized in the constructor 'property::value' [../ginac/archive.h:77]: (Style) Member variable not initialized in the constructor 'property::name' [../ginac/archive.h:77]: (Style) Member variable not initialized in the constructor 'property::type' [../ginac/archive.h:308]: (Style) Member variable not initialized in the constructor 'archived_ex::root' [../ginac/archive.h:308]: (Style) Member variable not initialized in the constructor 'archived_ex::name' [../ginac/ptr.h:35]: (Error) Class refcounted which is inherited by class basic does not have a virtual destructor [../ginac/relational.h:90]: (Style) The function 'safe_bool_helper::nonnull' can be const [../ginac/parser/parser.cpp:187]: (Style) Member variable not initialized in the constructor 'parser::token' [../ginac/excompiler.h:95]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.h:105]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.h:115]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.h:122]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:313]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:318]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:323]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:328]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:333]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:338]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:343]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:115]: (Style) Found 'mktemp'. You should use 'mkstemp' instead [../ginac/excompiler.cpp:141]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:154]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:170]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:195]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:220]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:245]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:280]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:287]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:294]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:301]: (Style) Function parameter 'filename' is passed by value. It could be passed by reference instead. [../ginac/excompiler.cpp:175]: (Error) Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid. [../ginac/pseries.cpp:432]: (Style) Redundant condition. It is safe to deallocate a NULL pointer [../ginac/archive.cpp:599] -> [../ginac/archive.h:142]: (Style) The function 'archive_node::forget' can be const [../ginac/expairseq.cpp:1291]: (Style) Variable 'erased' is assigned a value that is never used [../ginac/expairseq.cpp:72]: (Style) Member variable not initialized in the constructor 'expairseq::hashmask' [../ginac/expairseq.cpp:374]: (Style) Redundant condition. It is safe to deallocate a NULL pointer [../ginac/matrix.cpp:1447]: (Style) Variable 'check' is assigned a value that is never used [../ginac/relational.cpp:44]: (Style) Member variable not initialized in the constructor 'relational::o' Best regards Ettl Martin -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
Hi, On Thu, May 13, 2010 at 11:49:33PM +0200, Martin Ettl wrote:
i have checked the source of the current git head from ginac with the static code analysis tool cppcheck (http://sourceforge.net/projects/cppcheck/). It found a few uninitialized variables, const correctness issues...
Actually the only relevant warning is:
[../ginac/excompiler.cpp:175]: (Error) Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid.
The rest are not very useful.
[exam_cra.cpp:85]: (Style) Function parameter 'ntimes' is passed by value. It could be passed by reference instead.
Huh? Any decent optimizer will convert that back into pass-by-value (since the value fits into a register).
[../ginac/basic.h:112]: (Style) Member variable not initialized in the constructor 'basic::hashvalue'
gethash() checks object flags to figure out if hashvalue needs to be (re)computed, and (re)calculates it if necessary. Hence initializing it in the constructor (presumably with some dummy value) is not really useful.
[../ginac/expairseq.cpp:1291]: (Style) Variable 'erased' is assigned a value that is never used
That value is used when assertions are enabled. Best regards, Alexei
participants (3)
-
Alexei Sheplyakov
-
Martin Ettl
-
Richard B. Kreckel