[valgrind] [Bug 373192] Calling posix_spawn completely broken

2016-12-09 Thread bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=373192

--- Comment #9 from megahal...@gmail.com ---
(In reply to Philippe Waroquiers from comment #8)
> Created attachment 102691 [details]
> tentative patch (ugly, only for amd64) patch to better support clone(vfork)
> and stack
> 
> Can you please try the attached patch ? (patch on latest SVN version)
> 
> It seems to improve the clone test case provided in bug 342040,
> and I suspect fc25 posix_spawn might fail for similar reason, i.e.
> that the parent has prepared a stack for the child, but the child was just
> using the copy of the parent stack.

Yes as far as I can see it works fine with this patch.

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 373192] Calling posix_spawn completely broken

2016-12-08 Thread Philippe Waroquiers
https://bugs.kde.org/show_bug.cgi?id=373192

--- Comment #8 from Philippe Waroquiers  ---
Created attachment 102691
  --> https://bugs.kde.org/attachment.cgi?id=102691=edit
tentative patch (ugly, only for amd64) patch to better support clone(vfork) and
stack

Can you please try the attached patch ? (patch on latest SVN version)

It seems to improve the clone test case provided in bug 342040,
and I suspect fc25 posix_spawn might fail for similar reason, i.e.
that the parent has prepared a stack for the child, but the child was just
using the copy of the parent stack.

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 373192] Calling posix_spawn completely broken

2016-12-07 Thread Philippe Waroquiers
https://bugs.kde.org/show_bug.cgi?id=373192

--- Comment #7 from Philippe Waroquiers  ---
(In reply to megahallon from comment #0)
> Executing the program below with valgrind 3.12 built from sources on Fedora
> 25 gives the following output:
> 
> pid 21786 child 21787 r 0
> pid 21787 child 83036382 r 0

As far as I can see, the above happens because Valgrind transforms a
  clone (SIGCHLD | CLONE_VFORK | CLONE_VM)
into a simple
  clone(SIGCHLD)
but wrongly assumes that both parent and child will check for clone
return code, and executes 'their' part of the code.

I have not (yet) understood where/how Valgrind gives the 
guest thread function pointer for a 'thread clone'.
If/when I understand that, it might be possible to ensure that the cloned
child 'jumps' to the correct function for a vfork clone transformed
into a 'normal fork'.

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 373192] Calling posix_spawn completely broken

2016-12-07 Thread Philippe Waroquiers
https://bugs.kde.org/show_bug.cgi?id=373192

--- Comment #6 from Philippe Waroquiers  ---
(In reply to megahallon from comment #5)
> Also, as has been noted in bug 342040, it seems the clone call is not
> handled correctly when looking with strace:
> 
> strace valgrind ~/spawn|& grep clone
> =>
> clone(child_stack=NULL, flags=SIGCHLD)
> 
> strace ~/spawn|& grep clone
> =>
> clone(child_stack=0x7f13dd5d6ff0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD)

This is normal. Valgrind transforms a vfork into a fork, as it does
not support vfork semantic.
See the following code in e.g. syswrap-amd64-linux.c:
   case VKI_CLONE_VFORK | VKI_CLONE_VM: /* vfork */
  /* FALLTHROUGH - assume vfork == fork */
  cloneflags &= ~(VKI_CLONE_VFORK | VKI_CLONE_VM);

   case 0: /* plain fork */
  ...

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 373192] Calling posix_spawn completely broken

2016-12-06 Thread bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=373192

--- Comment #5 from megahal...@gmail.com ---
Also, as has been noted in bug 342040, it seems the clone call is not handled
correctly when looking with strace:

strace valgrind ~/spawn|& grep clone
=>
clone(child_stack=NULL, flags=SIGCHLD)

strace ~/spawn|& grep clone
=>
clone(child_stack=0x7f13dd5d6ff0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD)

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 373192] Calling posix_spawn completely broken

2016-12-06 Thread bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=373192

--- Comment #4 from megahal...@gmail.com ---
Created attachment 102644
  --> https://bugs.kde.org/attachment.cgi?id=102644=edit
Trace with fc24

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 373192] Calling posix_spawn completely broken

2016-12-06 Thread bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=373192

--- Comment #3 from megahal...@gmail.com ---
Created attachment 102643
  --> https://bugs.kde.org/attachment.cgi?id=102643=edit
Trace with fc25

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 373192] Calling posix_spawn completely broken

2016-12-03 Thread Philippe Waroquiers
https://bugs.kde.org/show_bug.cgi?id=373192

Philippe Waroquiers  changed:

   What|Removed |Added

 CC||philippe.waroquiers@skynet.
   ||be

--- Comment #2 from Philippe Waroquiers  ---
Looking at the differences between 2.23 and 2.24, I suspect the problem
is created because 2.24 is implementing posix_spawn(p) using
clone (CLONE_VM| CLONE_VFORK), while 2.23 uses fork or vfork.
Valgrind does not implement vfork, it just considers vfork is a fork,
hoping for the best.

It looks like the new glibc posix_spawn implementation depends more
on the precise semantic of vfork (or more exactly, of clone(CLONE_VM|
CLONE_VFORK),
such as sharing address space and/or having the calling thread suspended
waiting for the child to exec or exit.
If the dependency is only on the 'being suspended" aspect, that might 
be relatively easy to fix.

Hwoever, from the trace, it looks like both the parent and the child
have executed the fprintf. Not very clear how that can happen.

Can you run with --trace-syscalls=yes --trace-children=yes --time-stamp=yes
and attach the resulting trace ?


Thanks

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 373192] Calling posix_spawn completely broken

2016-12-02 Thread bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=373192

--- Comment #1 from megahal...@gmail.com ---
The same example worked on fedora 24 (glibc 2.23, linux 4.7.9), fedora 25 uses
glibc 2.24 and linux 4.8.8.

-- 
You are receiving this mail because:
You are watching all bug changes.