From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Can we go GTK-only? Date: Tue, 01 Nov 2016 19:08:51 +0200 Message-ID: <83eg2vnn4s.fsf@gnu.org> References: <24db2975-17ca-ad01-20c8-df12071fa89a@dancol.org> <4615E73A-19E2-4B79-9889-D3FA686DDDE6@raeburn.org> <83bmy0pl8p.fsf@gnu.org> <831sywp7ew.fsf@gnu.org> <83y413nsjm.fsf@gnu.org> <403a4fd8-f9da-82df-956b-a3187de83cf9@cs.ucla.edu> <83lgx3no0k.fsf@gnu.org> <633d43c4-946e-e318-d8de-be1c2fde26f7@dancol.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1478021716 27493 195.159.176.226 (1 Nov 2016 17:35:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 1 Nov 2016 17:35:16 +0000 (UTC) Cc: eggert@cs.ucla.edu, emacs-devel@gnu.org, raeburn@raeburn.org, monnier@iro.umontreal.ca To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 01 18:35:12 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1cxm-00064q-H5 for ged-emacs-devel@m.gmane.org; Tue, 01 Nov 2016 18:35:06 +0100 Original-Received: from localhost ([::1]:49628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1cxp-0004k9-8x for ged-emacs-devel@m.gmane.org; Tue, 01 Nov 2016 13:35:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1cYP-00008Z-Vf for emacs-devel@gnu.org; Tue, 01 Nov 2016 13:08:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1cYM-0002NF-Pk for emacs-devel@gnu.org; Tue, 01 Nov 2016 13:08:53 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1cYM-0002N4-M7; Tue, 01 Nov 2016 13:08:50 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4196 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1c1cYJ-00027L-U7; Tue, 01 Nov 2016 13:08:50 -0400 In-reply-to: <633d43c4-946e-e318-d8de-be1c2fde26f7@dancol.org> (message from Daniel Colascione on Tue, 1 Nov 2016 09:54:51 -0700) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:209066 Archived-At: > Cc: raeburn@raeburn.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org > From: Daniel Colascione > Date: Tue, 1 Nov 2016 09:54:51 -0700 > > >> > gmalloc is only thread-safe if Emacs is built with pthreads. > >> > >> Yes, and that's what one would expect. If you build Emacs in > >> single-threaded mode, malloc won't be thread-safe. But in the normal > >> case nowadays, malloc should be thread-safe. > > > > pthreads is not the only way to have threads. > > On any modern system POSIX system it is. Counterexample, please. You can find them yourself if you are interested. I have more important things to do with my time. > >> > xmalloc calls memory_full, which manipulates global state and calls > >> xsignal, so that is not thread-safe, either. > >> > >> That's fine, so long as xmalloc is called only in the Emacs Lisp thread. > > > > I'd imagine any code that wants to allocate from the heap will call > > xmalloc, as we never call malloc directly in Emacs AFAIK. > > That's because we want xmalloc to handle memory exhaustion in a sane > way. A thread calling system malloc on its own can handle memory > exhaustion a different way. Memory exhaustion being reported in some way > is what really matters. We'd have to write that stuff before this issue can be regarded as solved. > > Like I said: we are barely out of the woods, so allocations from the > > heap in non-main threads should be avoided. > > This restriction makes a big class of programs very difficult to write. That's what I'm saying: that class of programs is not yet feasible for Emacs. In a couple of years, maybe. > Besides, in my Emacs right now, I have in addition to the main thread a > generic glib worker thread, a dconf worker thread, and a gdbus thread. We are not talking about your Emacs or mine. (In my Emacs, those problems cannot happen at all, because as you know on Windows each DLL calls the memory allocator it was linked against, so the tricks Emacs plays with its private malloc are harmless, because no external library will ever call it.) But I was talking about the mainstream Emacs on J.R.Hacker's random machine out there. That is the platform about whose stability I worry.