orangeduck / tgc

A Tiny Garbage Collector for C
Other
968 stars 64 forks source link

many Conditional jump or move depends on uninitialised value(s) on examples #8

Closed FraMecca closed 7 years ago

FraMecca commented 7 years ago

Hi! I run make check with valgrind checking also for uninitialized values, and I noticed lots of errors. Is there a reason for that? I am trying to run the gc on some of my code and I noticed that some values corrupts and I think that the root cause is this. This is a sample:

==20488== Conditional jump or move depends on uninitialised value(s)
==20488==    at 0x40EA36: tgc_mark_ptr (tgc.c:171)
==20488==    by 0x40EA36: tgc_mark_stack (tgc.c:201)
==20488==    by 0x40E0A1: tgc_mark (tgc.c:230)
==20488==    by 0x40ED77: tgc_run (tgc.c:329)
==20488==    by 0x40ED77: tgc_add (tgc.c:346)
==20488==    by 0x405C8C: mpc_undefined (mpc.c:1688)
==20488==    by 0x405C8C: mpc_new (mpc.c:1696)
==20488==    by 0x40DA75: main_mpc (mpc.c:3979)
==20488==    by 0x400C61: main (mpc.c:4026)
==20488== 
==20488== Use of uninitialised value of size 8
==20488==    at 0x40E9F8: tgc_mark_ptr (tgc.c:172)
==20488==    by 0x40E9F8: tgc_mark_stack (tgc.c:201)
==20488==    by 0x40E0A1: tgc_mark (tgc.c:230)
==20488==    by 0x40ED77: tgc_run (tgc.c:329)
==20488==    by 0x40ED77: tgc_add (tgc.c:346)
==20488==    by 0x405C8C: mpc_undefined (mpc.c:1688)
==20488==    by 0x405C8C: mpc_new (mpc.c:1696)
==20488==    by 0x40DA75: main_mpc (mpc.c:3979)
==20488==    by 0x400C61: main (mpc.c:4026)
==20488== 
==20488== Conditional jump or move depends on uninitialised value(s)
==20488==    at 0x40E9FB: tgc_mark_ptr (tgc.c:172)
==20488==    by 0x40E9FB: tgc_mark_stack (tgc.c:201)
==20488==    by 0x40E0A1: tgc_mark (tgc.c:230)
==20488==    by 0x40ED77: tgc_run (tgc.c:329)
==20488==    by 0x40ED77: tgc_add (tgc.c:346)
==20488==    by 0x405C8C: mpc_undefined (mpc.c:1688)
==20488==    by 0x405C8C: mpc_new (mpc.c:1696)
==20488==    by 0x40DA75: main_mpc (mpc.c:3979)
==20488==    by 0x400C61: main (mpc.c:4026)
==20488== 
==20488== Use of uninitialised value of size 8
==20488==    at 0x40EA70: tgc_mark_ptr (tgc.c:173)
==20488==    by 0x40EA70: tgc_mark_stack (tgc.c:201)
==20488==    by 0x40E0A1: tgc_mark (tgc.c:230)
==20488==    by 0x40ED77: tgc_run (tgc.c:329)
==20488==    by 0x40ED77: tgc_add (tgc.c:346)
==20488==    by 0x405C8C: mpc_undefined (mpc.c:1688)
==20488==    by 0x405C8C: mpc_new (mpc.c:1696)
==20488==    by 0x40DA75: main_mpc (mpc.c:3979)
==20488==    by 0x400C61: main (mpc.c:4026)
orangeduck commented 7 years ago

Hi @FraMecca,

tgc does scan the stack and this can include uninitalised values but it does so safely so I think tgc shouldn't be responsible for corrupting any values. See this entry in the FAQ: https://github.com/orangeduck/tgc#why-do-i-get-uninitialised-values-warnings-with-valgrind