From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Henrik Grimler Newsgroups: gmane.emacs.bugs Subject: bug#47596: File descriptor error when exiting emacs on android 11 Date: Sun, 04 Apr 2021 21:20:35 +0200 Message-ID: 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="27489"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.4 To: 47596@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 04 21:21:19 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lT8JC-0006vy-Oq for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 04 Apr 2021 21:21:18 +0200 Original-Received: from localhost ([::1]:51896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lT8JB-0003Qm-M6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 04 Apr 2021 15:21:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lT8Iw-0003QK-SW for bug-gnu-emacs@gnu.org; Sun, 04 Apr 2021 15:21:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53153) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lT8Iw-0005UX-LP for bug-gnu-emacs@gnu.org; Sun, 04 Apr 2021 15:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lT8Iw-0000Hv-HY for bug-gnu-emacs@gnu.org; Sun, 04 Apr 2021 15:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Henrik Grimler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Apr 2021 19:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47596 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16175640541066 (code B ref -1); Sun, 04 Apr 2021 19:21:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Apr 2021 19:20:54 +0000 Original-Received: from localhost ([127.0.0.1]:36466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lT8In-0000H8-Va for submit@debbugs.gnu.org; Sun, 04 Apr 2021 15:20:54 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:53452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lT8Il-0000Gz-9R for submit@debbugs.gnu.org; Sun, 04 Apr 2021 15:20:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lT8Ik-0003Nz-4W for bug-gnu-emacs@gnu.org; Sun, 04 Apr 2021 15:20:50 -0400 Original-Received: from h04mx15.reliablemail.org ([185.76.67.208]:42905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lT8Id-0005L0-NO for bug-gnu-emacs@gnu.org; Sun, 04 Apr 2021 15:20:47 -0400 X-Halon-Out: d5984a93-957a-11eb-a4a4-354a41e2f763 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=grimler.se; s=default; h=Content-Transfer-Encoding:MIME-Version:Content-Type:Date:To: From:Subject:Message-ID:Sender:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RL0Wblv9r5SsLDik2j0DfmoFF0tDZIERpeGJOaevJK4=; b=o2rxHZgGR5q29trje7Z5rMsn/a 9rMydmAQwyOu+VQqsazZrw6XkelAln+OC8BXL9N6TD9U2E3e1mb2N8IKLInujQJKE/cQBhnF5vjRY xQiZkhJqbAA6Snh3FEjqAPUGqLw/pdkJdclX9x7VvvNJ2QjBIBpecXTu57ByzN0bKQOUtz565yhDb d7F5ZcYdKjbs+L43fn6SWejP5H06ZJM3q7Juv9mg3pyp0BmwejJvl2KVINjfrN2RrX7ijZOTYwtKc hwOxCYhkD7lcka1REjzEx2HabLCUxkSA0mWZ69BkLYsGHUruSdl9A8GQzs6mscIxxYMeMI7v4aszz n8FGBMKA==; X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpsrv07.misshosting.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - grimler.se X-Get-Message-Sender-Via: cpsrv07.misshosting.com: authenticated_id: henrik@grimler.se X-Authenticated-Sender: cpsrv07.misshosting.com: henrik@grimler.se Received-SPF: pass client-ip=185.76.67.208; envelope-from=henrik@grimler.se; helo=h04mx15.reliablemail.org X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HAS_X_OUTGOING_SPAM_STAT=1.998, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:203555 Archived-At: Hi, Android 10 introduced a new "file descriptor sanitizer" (fdsan, see [1] for docs) which detects issues when opening and closing files across multiple threads. On android 10 warnings were given, while on android 11 programs are killed instantly if issues are detected.  Starting and then exiting emacs, or simply just running for example `emacs --version`, gives an error. `gdb --args emacs --version` gives this backtrace: ``` Starting program: /data/data/com.termux/files/usr/bin/emacs --version GNU Emacs 27.2 Copyright (C) 2021 Free Software Foundation, Inc. GNU Emacs comes with ABSOLUTELY NO WARRANTY. You may redistribute copies of GNU Emacs under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING. fdsan: attempted to close file descriptor 2, expected to be unowned, actually owned by FILE* 0xb6c8800c Program received signal SIGABRT, Aborted. 0xb63789e8 in fdsan_error(char const*, ...) () from /apex/com.android.runtime/lib/bionic/libc.so (gdb) bt full #0 0xb63789e8 in fdsan_error(char const*, ...) () from /apex/com.android.runtime/lib/bionic/libc.so No symbol table info available. #1 0xb63786fe in android_fdsan_close_with_tag () from /apex/com.android.runtime/lib/bionic/libc.so No symbol table info available. #2 0xb63b83c0 in __sclose () from /apex/com.android.runtime/lib/bionic/libc.so No symbol table info available. #3 0xb63b8f24 in __FILE_close(__sFILE*) () from /apex/com.android.runtime/lib/bionic/libc.so No symbol table info available. #4 0x7f7e6a76 in close_stream (stream=0xb63cde44 <__sF+168>) at /home/builder/.termux-build/emacs/src/lib/close-stream.c:61 some_pending = false prev_fail = false fclose_fail = 243 #5 0x7f68a872 in close_output_streams () at /home/builder/.termux-build/emacs/src/src/sysdep.c:2840 err = false #6 0xb63c10d6 in __cxa_finalize () from /apex/com.android.runtime/lib/bionic/libc.so No symbol table info available. #7 0xb63bc7b8 in exit () from /apex/com.android.runtime/lib/bionic/libc.so No symbol table info available. #8 0x7f655d92 in main (argc=2, argv=0xbefff504) at /home/builder/.termux-build/emacs/src/src/emacs.c:1132 version = 0xb5e68133 "27.2" copyright = 0xb5e68138 "Copyright (C) 2021 Free Software Foundation, Inc." stack_bottom_variable = 0x7f655a61
do_initial_setlocale = false no_loadup = false junk = 0x0 dname_arg = 0x0 ch_to_dir = 0x0 original_pwd = 0x0 dump_mode = 0x0 skip_args = 1 temacs = 0x0 attempt_load_pdump = true sockfd = -1225460908 module_assertions = 244 ``` The emacs here was a debug build from the 27.2 tag, configured with: 'configure --disable-dependency-tracking --prefix=/data/data/com.termux/files/usr --libdir=/data/data/com.termux/files/usr/lib --sbindir=/data/data/com.termux/files/usr/bin --disable-rpath --disable-rpath-hack --host=arm-linux-androideabi --disable-autodepend --with-gif=no --with-gnutls --with-jpeg=no --without-gconf --without-gsettings --without-lcms2 --without-x --with-png=no --with-tiff=no --with-xml2 --with-xpm=no --without-dbus --without-selinux --with-modules --with-pdumper=yes --with- dumping=none --enable-checking=yes,glyphs --enable-check-lisp-object-type emacs_cv_sanitize_address=yes emacs_cv_prog_cc_no_pie=no ac_cv_lib_elf_elf_begin=no gl_cv_func_dup2_works=no ac_cv_func_setrlimit=no emacs_cv_func__setjmp=no emacs_cv_func_sigsetjmp=no --disable-nls --enable-shared --enable-static --libexecdir=/data/data/com.termux/files/usr/libexec 'CFLAGS= -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb -fstack-protector-strong -g3 -O0 -Wall -gdwarf-4' 'CPPFLAGS= -D_FORTIFY_SOURCE=2 -D__USE_FORTIFY_LEVEL=2 -I/data/data/com.termux/files/usr/include' 'LDFLAGS=-L/data/data/com.termux/files/usr/lib -Wl,-rpath=/data/data/com.termux/files/usr/lib -march=armv7-a -fopenmp -static-openmp -Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,relro,-z,now'' Debugging these issues are very tedious in my experience so far (probably easier for actual android apps). I will try to boil down the relevant emacs code into a smaller program that still reproduces the error. Based on the backtrace it seem to be how stderr is opened (and closed) that is problematic somehow. Please let me know if you have any insights, or if I can provide additional useful information. Best regards, Henrik Grimler [1] https://android.googlesource.com/platform/bionic/+/master/docs/fdsan.md