[PATCH] tests/functional/x86_64: Disable memlock test for asan builds

Peter Maydell posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260309104545.1550888-1-peter.maydell@linaro.org
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>
tests/functional/x86_64/meson.build | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
[PATCH] tests/functional/x86_64: Disable memlock test for asan builds
Posted by Peter Maydell 1 month ago
The address-sanitizer intercepts mlock() and makes it a no-op,
because it interacts badly with the sanitizer's own use of large
amounts of memory.  This means that our 'memlock' test will always
fail, because it checks via /proc for whether the QEMU process really
locked some pages.  Don't add the test when QEMU is built with asan.

Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 tests/functional/x86_64/meson.build | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/meson.build
index 05e4914c77..1ed10ad6c2 100644
--- a/tests/functional/x86_64/meson.build
+++ b/tests/functional/x86_64/meson.build
@@ -14,13 +14,20 @@ tests_x86_64_system_quick = [
   'cpu_model_versions',
   'cpu_queries',
   'mem_addr_space',
-  'memlock',
   'migration',
   'pc_cpu_hotplug_props',
   'virtio_version',
   'vmstate',
 ]
 
+# The address-sanitizer makes mlock() a no-op because it
+# interacts badly with the sanitizer; this means the memlock
+# test (which checks via /proc for whether pages were locked)
+# will always fail on a sanitizer build, so don't run it.
+if not get_option('asan')
+  tests_x86_64_system_quick += [ 'memlock' ]
+endif
+
 tests_x86_64_system_thorough = [
   'acpi_bits',
   'hotplug_blk',
-- 
2.43.0
Re: [PATCH] tests/functional/x86_64: Disable memlock test for asan builds
Posted by Thomas Huth 1 month ago
On 09/03/2026 11.45, Peter Maydell wrote:
> The address-sanitizer intercepts mlock() and makes it a no-op,
> because it interacts badly with the sanitizer's own use of large
> amounts of memory.  This means that our 'memlock' test will always
> fail, because it checks via /proc for whether the QEMU process really
> locked some pages.  Don't add the test when QEMU is built with asan.
> 
> Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   tests/functional/x86_64/meson.build | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/meson.build
> index 05e4914c77..1ed10ad6c2 100644
> --- a/tests/functional/x86_64/meson.build
> +++ b/tests/functional/x86_64/meson.build
> @@ -14,13 +14,20 @@ tests_x86_64_system_quick = [
>     'cpu_model_versions',
>     'cpu_queries',
>     'mem_addr_space',
> -  'memlock',
>     'migration',
>     'pc_cpu_hotplug_props',
>     'virtio_version',
>     'vmstate',
>   ]
>   
> +# The address-sanitizer makes mlock() a no-op because it
> +# interacts badly with the sanitizer; this means the memlock
> +# test (which checks via /proc for whether pages were locked)
> +# will always fail on a sanitizer build, so don't run it.
> +if not get_option('asan')
> +  tests_x86_64_system_quick += [ 'memlock' ]
> +endif
> +
>   tests_x86_64_system_thorough = [
>     'acpi_bits',
>     'hotplug_blk',

Reviewed-by: Thomas Huth <thuth@redhat.com>
Re: [PATCH] tests/functional/x86_64: Disable memlock test for asan builds
Posted by Pierrick Bouvier 1 month ago
On 3/9/26 4:39 AM, Thomas Huth wrote:
> On 09/03/2026 11.45, Peter Maydell wrote:
>> The address-sanitizer intercepts mlock() and makes it a no-op,
>> because it interacts badly with the sanitizer's own use of large
>> amounts of memory.  This means that our 'memlock' test will always
>> fail, because it checks via /proc for whether the QEMU process really
>> locked some pages.  Don't add the test when QEMU is built with asan.
>>
>> Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>    tests/functional/x86_64/meson.build | 9 ++++++++-
>>    1 file changed, 8 insertions(+), 1 deletion(-)
>>

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>