Francesco Biscani <bluesca...@...> writes: > > Hello, > > after upgrading to NLopt 2.2.1 I had a crash in my code. After a bit > of investigation with valgrind, it seems the problem is in > nlopt_minimize_constrained: > > ==21376== Thread 2: > ==21376== Invalid read of size 8 > ==21376== at 0x4C29AA8: memcpy (mc_replace_strmem.c:523) > ==21376== by 0x6D998E1: nlopt_set_xtol_abs (options.c:510) > ==21376== by 0x6D9C59C: nlopt_minimize_econstrained (deprecated.c:122) > ==21376== by 0x6D9C727: nlopt_minimize_constrained (deprecated.c:153) > > What happens is that in my code I set xtol_abs to NULL (which seems to > be allowed by the C API documentation), but it seems to me NLopt 2.2.1 > never checks if the pointer is NULL and performs a memcpy nevertheless > (in options.c:510). Setting xtol_abs to a "real" pointer fixes the > issue for me. Does this sound right? > > Cheers and thanks, > > Francesco. > >
Hey there, I'm not sure why you would have wanted to set xtol_abs to a NULL pointer. From what I've read on the wiki, I assumed you neglect to set it (default) or if you wanted to set it to a constant value for all your parameters you use nlopt_set_xtol_abs1(nl_opt opt, double tol). If you want to set specific tolerances for each variable, then you would use nlopt_set_xtol_abs(nl_opt opt, const double *tol), where tol is an array of doubles of size n (# of x's) that you initialize with tolerances for each corresponding variable prior to calling nlopt_set_xtol_abs(...). I don't think passing a "real" pointer to xtol_abs is doing what you want. If you simply passed a pointer pointing to n doubles of uninitialized data, then I bet the algorithm is using garbage data for your tolerances i.e. totally broken. It depends on what you want your tolerances to be or if you care, but either way I don't think the way you're doing it is correct. Maybe Steven has something else to add? -Adam _______________________________________________ NLopt-discuss mailing list [email protected] http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss
