Hi,
I just wanted to update the IMD KIM interface to the latest API (1.2.2) version
but I got a segmentation fault in the process.
This is the valgrind output:
==8622== Invalid read of size 1
==8622== at 0x4C2D144: strcmp (mc_replace_strmem.c:725)
==8622== by 0x548DE3B: KIMBaseElement::equiv(KIM_IOline&, bool)(KIM_API.cpp:529)
==8622== by 0x548FD52: KIM_API_model::is_it_match(KIM_API_model&, KIM_IOline*, int, bool, bool) (KIM_API.cpp:1118)
==8622== by 0x5497C94: KIM_API_model::is_it_match(KIM_API_model&, KIM_API_model&) (KIM_API.cpp:1195)
==8622== by 0x5499E89: KIM_API_model::string_init(char const*, char const*) (KIM_API.cpp:1624)
==8622== by 0x549B6D3: KIM_API_string_init (KIM_API_C.cpp:71)
==8622== by 0x416D1B: init_kim_info (imd_forces_kim.c:100)
==8622== by 0x40A8D6: setup_potentials (imd_potential.c:107)
==8622== by 0x416801: main (imd.c:90)
==8622== Address 0x0 is not stack'd, malloc'd or (recently) free'd
The relevant code from the imd_forces_kim is the following:
void init_kim_info()
{
char *test_descriptor_string = NULL;
void *pkim;
int kimerror;
real rc = 0.0;
/* initialize the variables in the kim struct */
init_kim_object(&kim);
/* set up a bogus kim descriptor file */
write_descriptor(&test_descriptor_string);
/* get KIM API object representing the KIM Model only */
kimerror = KIM_API_string_init(&pkim, test_descriptor_string, kim_model_name);
I have verified that both test_descriptor_string and kim_model_name are properly initialized.
With an earlier version of the API I did not have any problems with this code.
I currently do not have the time to debug the entire API, maybe someone can point me into
the right direction.
Best regards,
Daniel