qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* linux-user emulation hangs during fork
@ 2024-06-05  9:14 Andreas Schwab
  2024-06-05 11:10 ` Andreas Schwab
  2024-06-05 23:14 ` Richard Henderson
  0 siblings, 2 replies; 5+ messages in thread
From: Andreas Schwab @ 2024-06-05  9:14 UTC (permalink / raw)
  To: qemu-devel

$ qemu-x86_64 --version
qemu-x86_64 version 9.0.50 (v9.0.0-1211-gd16cab541a)
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
$ cat fork.rb 
begin
  r, w = IO.pipe
  if pid1 = fork
    w.close
    r.read 1
    Process.kill "USR1", pid1
    Process.wait2 pid1
  else
    print "child\n"
    r.close
    if pid2 = fork
      trap("USR1") { print "child: kill\n"; Process.kill "USR2", pid2 }
      w.close
      print "child: wait\n"
      Process.wait2 pid2
    else
      print "grandchild\n"
      w.close
      sleep 0.2
    end
  end
end
$ ruby fork.rb
child
child: wait
grandchild
child: kill
$ qemu-x86_64 /usr/bin/ruby fork.rb
child
child: wait
^Z
[1]+  Stopped                 qemu-x86_64 /usr/bin/ruby fork.rb
$ grep SigB $(for p in $(pidof qemu-x86_64); do echo /proc/$p/status; done | sort)
/proc/3221/status:SigBlk:       0000000000000000
/proc/3224/status:SigBlk:       0000000000000000
/proc/3228/status:SigBlk:       fffffff27ffbfa9f

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: linux-user emulation hangs during fork
  2024-06-05  9:14 linux-user emulation hangs during fork Andreas Schwab
@ 2024-06-05 11:10 ` Andreas Schwab
  2024-06-05 23:14 ` Richard Henderson
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2024-06-05 11:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson

6490d9aa62ef3cbbac2bf584fb0f3e737ab05e44 is the first bad commit
commit 6490d9aa62ef3cbbac2bf584fb0f3e737ab05e44
Author: Richard Henderson <richard.henderson@linaro.org>
Date:   Tue Jan 24 10:10:19 2023 -1000

    linux-user: un-parent OBJECT(cpu) when closing thread
    
    This reinstates commit 52f0c1607671293afcdb2acc2f83e9bccbfa74bb:
    
    While forcing the CPU to unrealize by hand does trigger the clean-up
    code we never fully free resources because refcount never reaches
    zero. This is because QOM automatically added objects without an
    explicit parent to /unattached/, incrementing the refcount.
    
    Instead of manually triggering unrealization just unparent the object
    and let the device machinery deal with that for us.
    
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/866
    Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
    Reviewed-by: Laurent Vivier <laurent@vivier.eu>
    Message-Id: <20220811151413.3350684-2-alex.bennee@linaro.org>
    
    The original patch tickled a problem in target/arm, and was reverted.
    But that problem is fixed as of commit 3b07a936d3bf.
    
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    Message-Id: <20230124201019.3935934-1-richard.henderson@linaro.org>
    Signed-off-by: Laurent Vivier <laurent@vivier.eu>

 linux-user/syscall.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: linux-user emulation hangs during fork
  2024-06-05  9:14 linux-user emulation hangs during fork Andreas Schwab
  2024-06-05 11:10 ` Andreas Schwab
@ 2024-06-05 23:14 ` Richard Henderson
  2024-06-06  8:27   ` Andreas Schwab
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2024-06-05 23:14 UTC (permalink / raw)
  To: Andreas Schwab, qemu-devel

On 6/5/24 02:14, Andreas Schwab wrote:
> $ qemu-x86_64 --version
> qemu-x86_64 version 9.0.50 (v9.0.0-1211-gd16cab541a)
> Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
> $ cat fork.rb
> begin
>    r, w = IO.pipe
>    if pid1 = fork
>      w.close
>      r.read 1
>      Process.kill "USR1", pid1
>      Process.wait2 pid1
>    else
>      print "child\n"
>      r.close
>      if pid2 = fork
>        trap("USR1") { print "child: kill\n"; Process.kill "USR2", pid2 }
>        w.close
>        print "child: wait\n"
>        Process.wait2 pid2
>      else
>        print "grandchild\n"
>        w.close
>        sleep 0.2
>      end
>    end
> end
> $ ruby fork.rb
> child
> child: wait
> grandchild
> child: kill
> $ qemu-x86_64 /usr/bin/ruby fork.rb
> child
> child: wait
> ^Z
> [1]+  Stopped                 qemu-x86_64 /usr/bin/ruby fork.rb
> $ grep SigB $(for p in $(pidof qemu-x86_64); do echo /proc/$p/status; done | sort)
> /proc/3221/status:SigBlk:       0000000000000000
> /proc/3224/status:SigBlk:       0000000000000000
> /proc/3228/status:SigBlk:       fffffff27ffbfa9f
> 

Works for me:

rth@stoup:~/zz$ ~/qemu/bld/qemu-x86_64 `which ruby` fork.rb
child
grandchild
child: wait
child: kill
rth@stoup:~/zz$ ~/qemu/bld/qemu-x86_64 `which ruby` fork.rb
child
grandchild
child: wait
child: kill
rth@stoup:~/zz$ ~/qemu/bld/qemu-x86_64 `which ruby` fork.rb
child
grandchild
child: wait
child: kill
rth@stoup:~/zz$ ~/qemu/bld/qemu-x86_64 `which ruby` fork.rb
child
grandchild
child: wait
child: kill


r~


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: linux-user emulation hangs during fork
  2024-06-05 23:14 ` Richard Henderson
@ 2024-06-06  8:27   ` Andreas Schwab
  2024-06-06 14:27     ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2024-06-06  8:27 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel

Which ruby?

$ ruby --version
ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux-gnu]

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: linux-user emulation hangs during fork
  2024-06-06  8:27   ` Andreas Schwab
@ 2024-06-06 14:27     ` Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2024-06-06 14:27 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: qemu-devel

On 6/6/24 01:27, Andreas Schwab wrote:
> Which ruby?
> 
> $ ruby --version
> ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux-gnu]
> 

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]

That might have been handy to have with your original report.


r~


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-06 14:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05  9:14 linux-user emulation hangs during fork Andreas Schwab
2024-06-05 11:10 ` Andreas Schwab
2024-06-05 23:14 ` Richard Henderson
2024-06-06  8:27   ` Andreas Schwab
2024-06-06 14:27     ` Richard Henderson

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).