From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: MPS make-thread Date: Sat, 22 Jun 2024 22:17:03 +0300 Message-ID: <86sex4g53k.fsf@gnu.org> References: <87v823xvq1.fsf@localhost> <87tthm3gq2.fsf@gmail.com> <87sex6ags5.fsf@localhost> <87msne3flr.fsf@gmail.com> <87frt63dvt.fsf@gmail.com> <86o77ulgk8.fsf@gnu.org> <87zfre1p3r.fsf@gmail.com> <87zfreo5u6.fsf@localhost> <87plsa1n8k.fsf@gmail.com> <87wmmio3vq.fsf@localhost> <87jzii1hbs.fsf_-_@gmail.com> <8734p61evv.fsf@gmail.com> <87cyoa3w5d.fsf@localhost> <87le2whkt2.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7501"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, eller.helmut@gmail.com, emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 22 21:17:23 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sL6Ek-0001kv-C9 for ged-emacs-devel@m.gmane-mx.org; Sat, 22 Jun 2024 21:17:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sL6EX-0004Un-TE; Sat, 22 Jun 2024 15:17:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sL6EV-0004UT-JN for emacs-devel@gnu.org; Sat, 22 Jun 2024 15:17:07 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sL6EV-0005I2-6n; Sat, 22 Jun 2024 15:17:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=fTKQ1q4OCvXb+lkPKOpo6fRWeauaojGy1hG/qMZCi8o=; b=pzTfAm3C6QVGOZHK/Hkb WH40SeAgol/uiOkCA/jMGjsX53rqjQ+itfp8WeyTd/I3OKbuFvZSqGmE7h/sFL79PA2NH5iwIE/Yg nnaDuNVTn1yvCphGYVa4syvL3JLH/60itTgHxwNoq2vFeV61xYoA1eaCEduBbwSB3qFm+R0gBiMLD rnM68iSwwqfZ1mbOjEPUXgSlH0z2WcjW2EbkAusAvg0R0z9e9v8o2xipYLH1tvZZumKv8GzLc0/XI fsIRjl1b5w90FC88waxYwWlEDVff4YMerzEfbc7goernxk5Rurkmc9rgmVOgaAgh0WmZ2LpnevHg1 VcefBZVzmXdisA==; In-Reply-To: <87le2whkt2.fsf@localhost> (message from Ihor Radchenko on Sat, 22 Jun 2024 18:52:25 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:320486 Archived-At: > From: Ihor Radchenko > Cc: Helmut Eller , Eli Zaretskii , > emacs-devel@gnu.org > Date: Sat, 22 Jun 2024 18:52:25 +0000 > > Gerd Möllmann writes: > > >> thix.c:67: Emacs fatal error: assertion failed: SigCheck Thread: thread > >> Fatal error 6: Aborted > > > > Any chance to make this reproducible? Maybe by adding calls to > > (igc--collect) in various places? I don't know what you are doing... > > (progn > (defvar *baz* nil) > (defun bar (len) > (let ((data (make-list len nil))) > (setq *baz* (lambda () (bar len) data)))) > (defun foo () > (bar 1000) > (dotimes (_ 10000) > (funcall *baz*))) > (thread-join (make-thread (lambda () (igc--collect)))) > (foo)) I get a crash only after running this several times. It looks like this: ss.c:66: Emacs fatal error: assertion failed: warmest < stackCold lockw3.c:98: Emacs fatal error: assertion failed: lock->claims == 0 Thread 11 received signal SIGTRAP, Trace/breakpoint trap. [Switching to Thread 9512.0x10a08] 0x774996c3 in KERNELBASE!DebugBreak () from C:\WINDOWS\SysWOW64\KernelBase.dll (gdb) thread apply all bt Thread 11 (Thread 9512.0x10a08): #0 0x774996c3 in KERNELBASE!DebugBreak () from C:\WINDOWS\SysWOW64\KernelBase.dll #1 0x002e457c in emacs_abort () at w32fns.c:11279 #2 0x00194ca0 in terminate_due_to_signal (sig=sig@entry=22, backtrace_limit=backtrace_limit@entry=2147483647) at emacs.c:481 #3 0x002c2ebc in igc_assert_fail (file=0x7b304d <__mon_yday+4429> "lockw3.c", line=98, msg=0x7b9a5c <__mon_yday+31580> "lock->claims == 0") at igc.c:181 #4 0x0039c18d in mps_lib_assert_fail (condition=0x7b9a5c <__mon_yday+31580> "lock->claims == 0", line=98, file=0x7b304d <__mon_yday+4429> "lockw3.c") at mpsliban.c:87 #5 LockClaim (lock=0xa5560c8) at lockw3.c:98 #6 0x0039c2e5 in ArenaEnterLock (arena=arena@entry=0x7100000, recursive=recursive@entry=0) at global.c:576 #7 0x003c9cdd in ArenaEnter (arena=0x7100000) at global.c:553 #8 mps_ap_fill (p_o=p_o@entry=0x1fc5f838, mps_ap=mps_ap@entry=0xa605bc4, size=size@entry=24) at mpsi.c:1094 #9 0x002c2036 in alloc_impl (size=24, size@entry=16, type=type@entry=IGC_OBJ_STRING, ap=0xa605bc4) at igc.c:3218 #10 0x002c48f3 in alloc (type=IGC_OBJ_STRING, size=16) at igc.c:3236 #11 igc_make_string (nchars=nchars@entry=3, nbytes=nbytes@entry=3, unibyte=unibyte@entry=false, clear=clear@entry=false) at igc.c:3344 #12 0x002c496d in igc_make_multibyte_string (nchars=nchars@entry=3, nbytes=nbytes@entry=3, clear=clear@entry=false) at igc.c:3354 #13 0x00209f39 in make_clear_multibyte_string (clearit=false, nbytes=3, nchars=3) at alloc.c:2635 #14 make_clear_string (length=length@entry=3, clearit=clearit@entry=false) at alloc.c:2612 #15 0x00209f97 in make_clear_string (clearit=, length=) at alloc.c:2621 #16 make_uninit_string (length=3) at alloc.c:2623 #17 make_uninit_string (length=3) at alloc.c:2621 #18 make_unibyte_string (contents=contents@entry=0x82f3a0 "d:/", length=length@entry=3) at alloc.c:2538 #19 0x0020a058 in make_string (contents=contents@entry=0x82f3a0 "d:/", nbytes=3) at alloc.c:2526 #20 0x001d9f2b in build_string (str=0x82f3a0 "d:/") at lisp.h:4687 #21 Fexpand_file_name (name=0x14800eb4, default_directory=default_directory@entry=0x0) at fileio.c:1070 #22 0x001e1316 in Fdo_auto_save (no_message=, no_message@entry=0x18, current_only=current_only@entry=0x0) at lisp.h:1191 #23 0x00194ada in shut_down_emacs (sig=sig@entry=22, stuff=stuff@entry=0x0) at lisp.h:1191 #24 0x00194d06 in terminate_due_to_signal (sig=sig@entry=22, backtrace_limit=backtrace_limit@entry=2147483647) at lisp.h:1191 #25 0x002c2ebc in igc_assert_fail (file=0x7b8b1f <__mon_yday+27679> "ss.c", line=66, msg=0x7b8b3d <__mon_yday+27709> "warmest < stackCold") at igc.c:181 #26 0x0039571d in mps_lib_assert_fail (condition=0x7b8b3d <__mon_yday+27709> "warmest < stackCold", line=66, file=0x7b8b1f <__mon_yday+27679> "ss.c") at mpsliban.c:87 #27 StackScan (ss=0x1fc5fb70, stackCold=0x1edeff28, scan_area=0x2c11f9 , closure=0x0) at ss.c:66 #28 0x003c7494 in RootScan (ss=ss@entry=0x1fc5fb70, root=root@entry=0xa60e83c) at root.c:577 #29 0x003c7d1d in traceScanRootRes (ts=ts@entry=1, rank=rank@entry=0, arena=arena@entry=0x7100000, root=root@entry=0xa60e83c) at trace.c:528 #30 0x003c8118 in traceScanRoot (root=0xa60e83c, arena=0x7100000, rank=0, ts=1) at trace.c:545 #31 rootFlip (p=, root=0xa60e83c) at trace.c:580 #32 RootsIterate (p=, f=, arena=0x7100008) at root.c:665 #33 traceFlip (trace=0x7100498) at trace.c:652 #34 TraceStart (trace=0x7100498, mortality=0.78544231075332438, finishingTime=189006713) at trace.c:1694 #35 0x003c89ab in TraceStartCollectAll (traceReturn=traceReturn@entry=0x1fc5fca8, arena=arena@entry=0x7100000, why=why@entry=4) at trace.c:1794 #36 0x003c9788 in ArenaStartCollect (globals=globals@entry=0x7100008, why=why@entry=4) at traceanc.c:634 #37 0x003c97e4 in ArenaCollect (globals=globals@entry=0x7100008, why=why@entry=4) at traceanc.c:652 #38 0x003c9886 in mps_arena_collect (arena=0x7100000) at mpsi.c:313 #39 0x002c4582 in igc_collect () at igc.c:3150 #40 0x002c4599 in Figc__collect () at igc.c:3159 #41 0x00239c8a in eval_sub (form=0xe58609b) at eval.c:2613 #42 0x00239fa3 in Fprogn (body=0x0) at eval.c:448 We must do something about these assertions: when there's an assertion violation caused by a thread which was started by MPS, we cannot call shut_down_emacs in that thread's context, for obvious reasons. We must instead set some flag which will cause the main thread or one of the other Lisp threads call shut_down_emacs. The MPS documentation says: Warning: The installed assertion handler must not call any function in MPS, and it must not access memory managed by the MPS. But our handler, igc_assert_fail, does exactly what they say not to do. And what does "warmest < stackCold" mean, in human-understandable terms, anyway?