From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.devel Subject: Re: changed dlopen flags in dynlib.c, gccemacs crash Date: Thu, 09 Dec 2021 20:47:57 +0000 Message-ID: References: <83tufjw848.fsf@gnu.org> <83lf0uuqaq.fsf@gnu.org> <834k7iugit.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15808"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: silent2600@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 09 21:48:41 2021 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 1mvQLH-0003xw-Ug for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Dec 2021 21:48:39 +0100 Original-Received: from localhost ([::1]:41924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mvQLG-00059l-Ig for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Dec 2021 15:48:38 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvQKm-0004VQ-JL for emacs-devel@gnu.org; Thu, 09 Dec 2021 15:48:08 -0500 Original-Received: from mx.sdf.org ([205.166.94.24]:53278) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvQKg-0001Td-HQ; Thu, 09 Dec 2021 15:48:08 -0500 Original-Received: from ma.sdf.org (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 1B9KlvLa021378 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Thu, 9 Dec 2021 20:47:58 GMT In-Reply-To: <834k7iugit.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 09 Dec 2021 14:08:58 +0200") Received-SPF: pass client-ip=205.166.94.24; envelope-from=akrl@sdf.org; helo=mx.sdf.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.devel:281546 Archived-At: Eli Zaretskii writes: >> From: Andrea Corallo >> Cc: hx , emacs-devel@gnu.org >> Date: Thu, 09 Dec 2021 10:53:57 +0000 >> >> > Andrea, any better ideas? I don't understand the reason for the >> > crash, as we seem to have defenses against this in Fnative_elisp_load, >> > so I'm probably missing something. >> >> Hello all, >> >> I'm no expert on 'dlopen' so I'm not sure about the impact of using >> RTLD_GLOBAL. But should be noted that .eln files do share a number of >> symbol names, I'm wondering if this could be somehow problematic when >> using RTLD_GLOBAL, that's my suspect here. > > Assuming the RTLD_GLOBAL flag was added. Yep > But still, the crash is because we assume a Lisp object is a cons cell > and take its CDR. So evidently it isn't a cons cell (probably nil), > and I don't understand how that could be caused, not even if > RTLD_GLOBAL was used. I'm just speculating *but*: `comp--register-lambda' it's called directly from the eln synthetized code that is run when the .eln is loaded. The arguments of `comp--register-lambda' are immediates that are set into the eln not long before, and this process (in 'load_comp_unit') indeed requires symbol resolution (through our `dynlib_sym'). My guess is that something goes wrong in that area (but as mentioned I've no proof of that). Andrea