qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Lukas Jünger" <lukas.junger@greensocs.com>
Cc: erdnaxe@crans.org, ma.mandourr@gmail.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 0/1] Add missing function names to symbol list
Date: Mon, 18 Oct 2021 12:18:11 +0100	[thread overview]
Message-ID: <875ytu1spc.fsf@linaro.org> (raw)
In-Reply-To: <2cf6222a-7c66-cbbc-a9a2-66c037c62918@greensocs.com>


Lukas Jünger <lukas.junger@greensocs.com> writes:

> On 9/7/21 13:43, Alex Bennée wrote:
>> Lukas Jünger <lukas.junger@greensocs.com> writes:
>>
>>> Hi all,
>>>
>>> I have been trying to use the hwprofile and cache plugin on
>>> qemu-system-riscv64. They failed to load with an undefined
>>> symbol error. It looks like some of the plugin API functions
>>> are missing from the symbol list, so I added them.
>> Heh I had a similar patch in plugins/next but yours includes more
>> symbols so queued to plugins/next, thanks. Not sure how I missed it
>> before - I think we might not have been honouring the symbol list
>> before.
>>
>>> Afterwards
>>> the plugins worked (eventhough the cache plugin is segfaulting
>>> on shutdown, but that is a separate, unrelated issue).
>> Has this been tracked down yet? There is a fix f7e68c9c99 (tcg/plugins:
>> implement a qemu_plugin_user_exit helper) which was for user mode. At
>> the time I didn't think system mode would be affected due to the atexit
>> callback only being called once vCPUs had shutdown.
>
> It seems like there is a race condition with the tcg threads.
> The plugin exit handler is run with atexit(). While the exit callback
> is freeing memory, tcg is still running and memory callbacks write
> to the already freed data structures in the plugin causing the segfault.
> I tested this with the current master branch and this cmdline:

We fixed a bug in linux-user that was leading to the exit callbacks
being called (see qemu_plugin_user_exit).

> bin/qemu-system-riscv64 -machine virt -nographic -bios fw_jump.elf
>     -kernel Image -plugin path/to/libcache.so -d plugin -D log.txt
>
> I wonder if we could somehow wait for the tcg to exit before executing
> plugin exit cb. Do you have an idea?

It should be because I don't see how TCG would still be running when we
run the atexit handler. It literally shouldn't be called until QEMU
itself calls exit which should be well after the TCG has stopped running
(see pause_all_vcpus).

Any chance you could replicate and generate a backtrace that shows this
happening?

-- 
Alex Bennée


  reply	other threads:[~2021-10-18 11:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-05 14:09 [PATCH 0/1] Add missing function names to symbol list Lukas Jünger
2021-09-05 14:09 ` [PATCH 1/1] plugins/: Add missing functions " Lukas Jünger
2021-09-07 11:43 ` [PATCH 0/1] Add missing function names " Alex Bennée
2021-10-18 10:55   ` Lukas Jünger
2021-10-18 11:18     ` Alex Bennée [this message]
2021-10-18 12:16       ` Lukas Jünger
2021-10-18 12:49         ` Alex Bennée

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=875ytu1spc.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=erdnaxe@crans.org \
    --cc=lukas.junger@greensocs.com \
    --cc=ma.mandourr@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).