Calling system() in multi-threads.

Takashi Yano takashi.yano@nifty.ne.jp
Fri Jul 18 15:04:56 GMT 2025


On 2025年7月18日 16:25:49 +0200
Corinna Vinschen wrote:
> 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
> > 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? 

 0 [main] sh 403 _cmalloc: b = 0
 164 [main] sh 403 _cmalloc: cygheap->buckets[b] = 0x63005C003A0043
 0 [main] sh 405 _cmalloc: b = 0
 0 [main] sh 408 _cmalloc: b = 0
 164 [main] sh 405 _cmalloc: cygheap->buckets[b] = 0x6
 0 [main] sh 407 _cmalloc: b = 0
 166 [main] sh 408 _cmalloc: cygheap->buckets[b] = 0x6
 218 [main] sh 407 _cmalloc: cygheap->buckets[b] = 0x6
 0 [main] sh 404 _cmalloc: b = 0
 167 [main] sh 404 _cmalloc: cygheap->buckets[b] = 0x6
 0 [main] sh 409 _cmalloc: b = 0
 131 [main] sh 409 _cmalloc: cygheap->buckets[b] = 0x6
 1 [main] sh 406 _cmalloc: b = 0
 172 [main] sh 406 _cmalloc: cygheap->buckets[b] = 0x6
cygheap->buckets[b] seems to be broken.
403:
... (infinite loop for ritrieving stacktrace) ...
#2 0x00007fff8bd36ad8 in _cmalloc (size=<optimized out>) at ../../.././winsup/cygwin/mm/cygheap.cc:382
#3 0x00007fff8bd37418 in cmalloc (fn=0x0, n=9, x=HEAP_STR) at ../../.././winsup/cygwin/mm/cygheap.cc:476
#4 cmalloc (n=9, x=HEAP_STR) at ../../.././winsup/cygwin/mm/cygheap.cc:483
#5 crealloc (fn=0x7fff8beb5984 <P+1444> "crealloc", n=9, s=<optimized out>) at ../../.././winsup/cygwin/mm/cygheap.cc:496
#6 crealloc_abort (s=<optimized out>, n=9) at ../../.././winsup/cygwin/mm/cygheap.cc:514
#7 0x00007fff8bc55fd6 in path_conv::set_posix (path_copy=0x1210720 "/dev/tty", this=0x7ffffc800) at ../../.././winsup/cygwin/path.cc:451
#8 path_conv::set_posix (path_copy=0x1210720 "/dev/tty", this=0x7ffffc800) at ../../.././winsup/cygwin/path.cc:446
#9 path_conv::check (this=this@entry=0x7ffffc800, src=<optimized out>, src@entry=0x0, opt=6817, suffixes=0x7fff8bf2d1c0 <stat_suffixes>) at ../../.././winsup/cygwin/path.cc:1310
#10 0x00007fff8bc1959c in path_conv::path_conv (suffixes=<optimized out>, opt=6817, src=0x0, this=0x7ffffc800) at /home/yano/newlib-cygwin/winsup/cygwin/local_includes/path.h:312
#11 build_fh_name (name=name@entry=0x10049d830 "/dev/tty", opt=opt@entry=6657, si=<optimized out>) at ../../.././winsup/cygwin/dtable.cc:439
#12 0x00007fff8bc92f7a in open (unix_path=0x10049d830 "/dev/tty", flags=16386) at ../../.././winsup/cygwin/syscalls.cc:1488
#13 0x00007fff8bd5a1c4 in _sigfe () at sigfe.s:35
#14 0x000000010040dee5 in check_dev_tty ()
#15 0x00000001004948f1 in main ()
405:
... (infinite loop for ritrieving stacktrace) ...
#2 0x00007fff8bd36ad8 in _cmalloc (size=<optimized out>) at ../../.././winsup/cygwin/mm/cygheap.cc:382
#3 0x00007fff8bd37418 in cmalloc (fn=0x0, n=9, x=HEAP_STR) at ../../.././winsup/cygwin/mm/cygheap.cc:476
#4 cmalloc (n=9, x=HEAP_STR) at ../../.././winsup/cygwin/mm/cygheap.cc:483
#5 crealloc (fn=0x7fff8beb5984 <P+1444> "crealloc", n=9, s=<optimized out>) at ../../.././winsup/cygwin/mm/cygheap.cc:496
#6 crealloc_abort (s=<optimized out>, n=9) at ../../.././winsup/cygwin/mm/cygheap.cc:514
#7 0x00007fff8bc55fd6 in path_conv::set_posix (path_copy=0x1390720 "/dev/tty", this=0x7ffffc800) at ../../.././winsup/cygwin/path.cc:451
#8 path_conv::set_posix (path_copy=0x1390720 "/dev/tty", this=0x7ffffc800) at ../../.././winsup/cygwin/path.cc:446
#9 path_conv::check (this=this@entry=0x7ffffc800, src=<optimized out>, src@entry=0x0, opt=6817, suffixes=0x7fff8bf2d1c0 <stat_suffixes>) at ../../.././winsup/cygwin/path.cc:1310
#10 0x00007fff8bc1959c in path_conv::path_conv (suffixes=<optimized out>, opt=6817, src=0x0, this=0x7ffffc800) at /home/yano/newlib-cygwin/winsup/cygwin/local_includes/path.h:312
#11 build_fh_name (name=name@entry=0x10049d830 "/dev/tty", opt=opt@entry=6657, si=<optimized out>) at ../../.././winsup/cygwin/dtable.cc:439
#12 0x00007fff8bc92f7a in open (unix_path=0x10049d830 "/dev/tty", flags=16386) at ../../.././winsup/cygwin/syscalls.cc:1488
#13 0x00007fff8bd5a1c4 in _sigfe () at sigfe.s:35
#14 0x000000010040dee5 in check_dev_tty ()
#15 0x00000001004948f1 in main ()
-- 
Takashi Yano <takashi.yano@nifty.ne.jp>


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /