Calling system() in multi-threads.
Corinna Vinschen
corinna-cygwin@cygwin.com
Fri Jul 18 14:25:49 GMT 2025
On Jul 18 22:32, Takashi Yano via Cygwin wrote:
> I embedded debug code into mm/cygheap.cc, that is:
>
> diff --git a/winsup/cygwin/mm/cygheap.cc b/winsup/cygwin/mm/cygheap.cc
> index 338886468..bab4067e0 100644
> --- a/winsup/cygwin/mm/cygheap.cc
> +++ b/winsup/cygwin/mm/cygheap.cc
> @@ -371,7 +371,16 @@ _cmalloc (unsigned size)
> if (cygheap->buckets[b])
> {
> rvc = (_cmalloc_entry *) cygheap->buckets[b];
> - cygheap->buckets[b] = rvc->ptr;
> + __try
> + {
> + cygheap->buckets[b] = rvc->ptr;
> + }
> + __except (NO_ERROR)
> + { /* Shouldl not reach */
> + system_printf("b = %d", b);
> + assert (false);
> + }
> + __endtry
> rvc->b = b;
> }
> else
> diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
> index cb58b6eed..32f6bdead 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);
>
> The result is like this! Why???
>
> 0 [main] sh 617 _cmalloc: b = 1
> assertion "false" failed: file "../../.././winsup/cygwin/mm/cygheap.cc", line 381, function: void* _cmalloc(unsigned int)
I don't know. Looks like rvc points into nirvana. Who's the caller?
what's the value of cygheap->buckets[1]? Is something filling up cygheap
fast, perhaps?
Corinna
More information about the Cygwin
mailing list