nlopt
nlopt copied to clipboard
[COBYLA/BOBYQA] Address sanitizer issue
When compiling with gcc with address sanitizer checks, as soon as one starts using either the COBYLA or BOBYQA solver, many warnings of this sort occur:
src/algs/cobyla/cobyla.c:568:31: runtime error: store to address 0x5120000bbcd0 with insufficient space for an object of type 'double'
I tried investigating a bit but I am out of my depth here. It might be that
w = (double*) malloc(U(n*(3*n+2*m+11)+4*m+6)*sizeof(*w));
does not affect enough memory as the documentation above says only (bold formatting is my own doing):
The arguments W and IACT provide real and int arrays that are used as working space. Their lengths must be at least N*(3N+2M+11)+4*M+6 and M+1 respectively.
But I tried much higher memory allocation and it did not help.
Or it might be a problem in the later for loops which access w but it is very hard to track.
Any ideas?
An alternative would be to follow up on #501 and switch to PRIMA for more modern, less buggy implementations of Powell's algorithms, especially since the project is now built via CMake.
For reference, I spotted these asan warnings while adapting nlopt sources to make them compatible with CRAN rules for R users (#608).