Previously the swig-generated code here used an invalid pattern:
{
const char *key_ptr;
size_t key_length_ptr;
arg2 = &key_ptr;
arg3 = &key_length_ptr;
}
// read and write through the pointers in arg2 and arg3
As key_ptr and key_length_ptr were declared in that scope, once we leave the scope their memory is no longer valid. Address Sanitizer detects and reports this, but fortunately, as far as I can tell, under more "regular" compiler settings there is no difference (I diff'd the assembly output and it was identical) and this happens to work fine as the memory is reserved but not used for other purposes.
The second commit here adjusts extconf to only build the libmemcached/ subdirectory of the vendored libmemcached, skipping tests, clients and others. This made building with ASAN work (otherwise it failed linking some of the other subprojects) and should be a bit faster and more resilient anyways.
Previously the swig-generated code here used an invalid pattern:
As
key_ptr
andkey_length_ptr
were declared in that scope, once we leave the scope their memory is no longer valid. Address Sanitizer detects and reports this, but fortunately, as far as I can tell, under more "regular" compiler settings there is no difference (I diff'd the assembly output and it was identical) and this happens to work fine as the memory is reserved but not used for other purposes.The second commit here adjusts extconf to only build the
libmemcached/
subdirectory of the vendored libmemcached, skipping tests, clients and others. This made building with ASAN work (otherwise it failed linking some of the other subprojects) and should be a bit faster and more resilient anyways.