eth-sri / ELINA

ELINA: ETH LIbrary for Numerical Analysis
http://elina.ethz.ch/
Other
129 stars 53 forks source link

fix memory leaks (found by Valgrind) #73

Closed caballa closed 3 years ago

caballa commented 3 years ago

There are other memory leaks that I didn't have time to look at. All of them are in the zones domain. Sorry that I don't provide a test case but this is what Valgrind says. Hopefully this is enough to give you an idea:

==94482== 11,880 bytes in 297 blocks are definitely lost in loss record 33 of 35
==94482==    at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==94482==    by 0x506E158: elina_linexpr0_alloc (elina_linexpr0.c:139)
==94482==    by 0x6A388D8: elina_linexpr0_add (elina_linexpr0_arith.c:144)
==94482==    by 0x6A3CCD7: elina_texpr0_node_intlinearize (elina_linearize_texpr.c:726)
==94482==    by 0x6A3CCD7: elina_interval_intlinearize_texpr0_rec (elina_linearize_texpr.c:923)
==94482==    by 0x6A3CC73: elina_texpr0_node_intlinearize (elina_linearize_texpr.c:714)
==94482==    by 0x6A3CC73: elina_interval_intlinearize_texpr0_rec (elina_linearize_texpr.c:923)
==94482==    by 0x6A3E67B: elina_intlinearize_elina_tcons0_array (elina_linearize_texpr.c:1597)
==94482==    by 0x6A3E8E5: elina_intlinearize_tcons0_array (elina_linearize_texpr.c:1680)
==94482==    by 0x6A34DB6: elina_generic_meet_intlinearize_tcons_array (elina_generic.c:222)
==94482==    by 0x528FDA8: opt_zones_meet_tcons_array (opt_zones_transfer.c:151)
==94482==    by 0x6A359E4: elina_generic_asssub_texpr_array (elina_generic.c:506)
==94482==    by 0x528FC41: elina_generic_assign_texpr_array (elina_generic.h:217)
==94482==    by 0x528FC41: opt_zones_assign_texpr_array (opt_zones_transfer.c:61)
==94482==    by 0x5073B12: elina_abstract0_asssub_texpr_array (elina_abstract0.c:1106)
==94482== 12,520 bytes in 313 blocks are definitely lost in loss record 34 of 35
==94482==    at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==94482==    by 0x506E158: elina_linexpr0_alloc (elina_linexpr0.c:139)
==94482==    by 0x6A388D8: elina_linexpr0_add (elina_linexpr0_arith.c:144)
==94482==    by 0x6A38BDD: elina_linexpr0_sub (elina_linexpr0_arith.c:211)
==94482==    by 0x6A3D080: elina_texpr0_node_intlinearize (elina_linearize_texpr.c:731)
==94482==    by 0x6A3D080: elina_interval_intlinearize_texpr0_rec (elina_linearize_texpr.c:923)
==94482==    by 0x6A3E67B: elina_intlinearize_elina_tcons0_array (elina_linearize_texpr.c:1597)
==94482==    by 0x6A3E8E5: elina_intlinearize_tcons0_array (elina_linearize_texpr.c:1680)
==94482==    by 0x6A34DB6: elina_generic_meet_intlinearize_tcons_array (elina_generic.c:222)
==94482==    by 0x528FDA8: opt_zones_meet_tcons_array (opt_zones_transfer.c:151)
==94482==    by 0x6A359E4: elina_generic_asssub_texpr_array (elina_generic.c:506)
==94482==    by 0x528FC41: elina_generic_assign_texpr_array (elina_generic.h:217)
==94482==    by 0x528FC41: opt_zones_assign_texpr_array (opt_zones_transfer.c:61)
==94482==    by 0x5073B12: elina_abstract0_asssub_texpr_array (elina_abstract0.c:1106)
==94482== 960 bytes in 40 blocks are definitely lost in loss record 29 of 35
==94482==    at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==94482==    by 0x682A7BD: create_comp_list (comp_list.c:44)
==94482==    by 0x528A9B1: linexpr0_to_comp_list_zones (opt_mat.c:2146)
==94482==    by 0x528B097: opt_zones_mat_add_lincons (opt_mat.c:2247)
==94482==    by 0x528F9CD: opt_zones_meet_lincons_array (opt_zones_transfer.c:116)
==94482==    by 0x507350E: elina_abstract0_meet_lincons_array (elina_abstract0.c:984)
==94482== 288 bytes in 18 blocks are definitely lost in loss record 26 of 35
==94482==    at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==94482==    by 0x682B03D: create_array_comp_list (array_comp_list.c:57)
==94482==    by 0x5285695: opt_zones_mat_alloc (opt_mat.c:202)
==94482==    by 0x528E263: opt_zones_join (opt_zones_nary.c:149)
==94482== 64 bytes in 4 blocks are definitely lost in loss record 18 of 35
==94482==    at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==94482==    by 0x682B03D: create_array_comp_list (array_comp_list.c:57)
==94482==    by 0x5285695: opt_zones_mat_alloc (opt_mat.c:202)
==94482==    by 0x528E4F5: opt_zones_widening (opt_zones_nary.c:218)
==94482==    by 0x50746C8: elina_abstract0_widening (elina_abstract0.c:1360)
==94482== 6 bytes in 1 blocks are definitely lost in loss record 2 of 35
==94482==    at 0x4C33B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==94482==    by 0x682C37C: union_array_comp_list (union.c:232)
==94482==    by 0x5288221: sparse_join_zones_mat (opt_mat.c:1216)
==94482==    by 0x528E319: opt_zones_join (opt_zones_nary.c:156)
GgnDpSngh commented 3 years ago

Hi Jorge,

Thanks a lot for the fixes and the pointers. We will fix the remaining issues found by Valgrind now.

Cheers, Gagandeep Singh

GgnDpSngh commented 3 years ago

Hi Jorge,

I managed to locate all leaks except the last one and have pushed fixes. Please let me know if the leaks are gone.

Cheers, Gagandeep Singh