gphocs-dev / G-PhoCS

G-PhoCS is a software package for inferring ancestral population sizes, population divergence times, and migration rates from individual genome sequences.
33 stars 4 forks source link

suspect usage of "dataSetup.popTree->pops[param]->updateSampleAge" in MCMCControl:427 #23

Open selotape opened 7 years ago

selotape commented 7 years ago

Hi G-PhoCSers,

While using Valgrind (a memory error detector) on G-PhoCS, in an attempt to solve an unrelated problem, I got the following warning -

==6245== Conditional jump or move depends on uninitialised value(s)
==6245==    at 0x421B9B: finalizeNumParameters (MCMCcontrol.c:427)
==6245==    by 0x413186: main (GPhoCS.c:177)

This is due to the conditional usage of dataSetup.popTree->pops[param]->updateSampleAge which apparently is uninitialized.

I don't know whether this usage is intentional or whether the condition should actually beif (updateSampleAge > 0). I just wanted to bring this to your attention.

Thanks, Ron

gphocs-dev commented 7 years ago

Okay. I took a quick look. This is probably not doing any real damage, but I agree that it should be fixed. Because there are already a few working versions out there, I don't want to mess this out, so I'll leave it to Evgeny to fix. Just add the following two lines around line 835 of MCMCcontrol.c:

dataSetup.popTree->pops[pop]->updateSampleAge = 0; dataSetup.popTree->pops[pop]->sampleAge= 0.0;

Thanks for the tip. It's a good reminder to run valgrind every now and then.

--Ilan

On Fri, Apr 14, 2017 at 8:19 PM, Ron notifications@github.com wrote:

Hi G-PhoCSers,

While using Valgrind (a memory error detector) on G-PhoCS, in an attempt to solve an unrelated problem, I got the following warning -

==6245== Conditional jump or move depends on uninitialised value(s) ==6245== at 0x421B9B: finalizeNumParameters (MCMCcontrol.c:427) ==6245== by 0x413186: main (GPhoCS.c:177)

This is due to the conditional usage of dataSetup.popTree->pops[param] ->updateSampleAge which apparently is uninitialized.

I don't know whether this usage is intentional or whether the condition should actually beif (updateSampleAge > 0). I just wanted to bring this to your attention.

Thanks, Ron

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gphocs-dev/G-PhoCS/issues/23, or mute the thread https://github.com/notifications/unsubscribe-auth/AN30LhKzncA-pHezQTQrCyPi9SjhQlmTks5rv6qygaJpZM4M97L8 .