qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Stefan Weil <sw@weilnetz.de>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org,
	Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH] util/oslib-win32: Fix fatal assertion in qemu_try_memalign
Date: Fri, 11 Jun 2021 13:06:28 +0200	[thread overview]
Message-ID: <dd332a3f-888e-a238-9ee1-f1651b630fe4@redhat.com> (raw)
In-Reply-To: <20210611105846.347954-1-sw@weilnetz.de>

On 6/11/21 12:58 PM, Stefan Weil wrote:
> The function is called with alignment == 0 which caused an assertion.
> Use the code from oslib_posix.c to fix that regression (introduced
> by commit ed6f53f9ca9).
> 

Oops.

Can we replace '(introduced by commit ed6f53f9ca9)' by:
Fixes: ed6f53f9ca9 ("util/oslib: Assert qemu_try_memalign() alignment is
a power of 2")

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  util/oslib-win32.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/util/oslib-win32.c b/util/oslib-win32.c
> index ca99356fdf..7b318ea835 100644
> --- a/util/oslib-win32.c
> +++ b/util/oslib-win32.c
> @@ -57,7 +57,11 @@ void *qemu_try_memalign(size_t alignment, size_t size)
>      void *ptr;
>  
>      g_assert(size != 0);
> -    g_assert(is_power_of_2(alignment));
> +    if (alignment < sizeof(void *)) {
> +        alignment = sizeof(void *);
> +    } else {
> +        g_assert(is_power_of_2(alignment));
> +    }
>      ptr = _aligned_malloc(size, alignment);
>      trace_qemu_memalign(alignment, size, ptr);
>      return ptr;
> 



  reply	other threads:[~2021-06-11 11:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11 10:58 [PATCH] util/oslib-win32: Fix fatal assertion in qemu_try_memalign Stefan Weil
2021-06-11 11:06 ` Philippe Mathieu-Daudé [this message]
2021-06-11 11:12   ` Stefan Weil
2021-06-19 15:48 ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dd332a3f-888e-a238-9ee1-f1651b630fe4@redhat.com \
    --to=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).