On Fri, 18 Jul 2025 09:51:11 +0200
Corinna Vinschen via Cygwin <[email protected]> wrote:
> On Jul 18 00:44, Takashi Yano via Cygwin wrote:
> > On Thu, 17 Jul 2025 17:19:49 +0200
> > Corinna Vinschen wrote:
> > > On Jul 17 23:14, Takashi Yano via Cygwin wrote:
> > > > Hi Corinna,
> > > >
> > > > On Wed, 16 Jul 2025 17:36:42 +0200
> > > > Corinna Vinschen wrote:
> > > > > On Jul 16 23:52, Takashi Yano via Cygwin wrote:
> > > > > > Do you have any idea?
> > > > >
> > > > > Locking would be super-simple.
> > > > >
> > > > > But theoretically it should be possible to use a local
> > > > > child_info_spawn
> > > > > variable at this point. The ch_spawn child_info_spawn instance is not
> > > > > copied to the child anyway, so that should be safe. The same goes for
> > > > > posix_spawn() then, btw.
> > > > >
> > > > > I checked the sources and I don't see any dependency to ch_spawn
> > > > > from a spawning process, in contrast to an exec'ing process. That
> > > > > doesn't mean there is none, just that I didn't find any.
> > > >
> > > > Thanks!
> > > > As a starting point, I tried tntroducing locking. It almost works
> > > > as expected, however, sometimes my STC in my first report is hangs
> > > > if N is large e.g. 100. The patch is as attached.
> > > >
> > > > What am I missing?
> > >
> > > I don't know. You're perhaps not releasing the lock in all cases.
> > > But I would have to debug this just like you ¯\_(ツ)_/¯
> > >
> > > Out of curiosity, did you try using a locale child_info_spawn instance
> > > instead? That would be a rather nice solution, but I'm pretty sure
> > > there's some other problem lurking in the dark...
> >
> > I'm not sure what to do with local child_info_spawn.
> > Some of other modules refer to ch_spawn, such as exception.cc and
> > pinfo.cc. Also, has_execed* uses ch_spawn. What should we do for that?
>
> Yes, that's what I meant with my above paragraph, i.e.
>
> > > > > I checked the sources and I don't see any dependency to ch_spawn
> > > > > from a spawning process, in contrast to an exec'ing process. That
> > > > > doesn't mean there is none, just that I didn't find any.
>
> These external dependencies *should* only be of interest when performing
> an execve, but not when performing a spawnve.
So, the previous patch might not correct.
The following makes more sense, I suppose.
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index cb58b6eed..56fca6e45 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -944,6 +944,7 @@ spawnve (int mode, const char *path, const char *const
*argv,
int ret;
syscall_printf ("spawnve (%s, %s, %p)", path, argv[0], envp);
+ child_info_spawn ch_spawn_local;
if (!envp)
envp = empty_env;
@@ -961,7 +962,7 @@ spawnve (int mode, const char *path, const char *const
*argv,
case _P_WAIT:
case _P_DETACH:
case _P_SYSTEM:
- ret = ch_spawn.worker (path, argv, envp, mode);
+ ret = ch_spawn_local.worker (path, argv, envp, mode);
break;
default:
set_errno (EINVAL);
--
Takashi Yano <[email protected]>
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple