all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "serge.tupchii" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 45122@debbugs.gnu.org
Subject: bug#45122: [PATCH] 27.1; 28.0.50; Fix crash (segfault) in etags on generating  tags for Erlang files
Date: Tue, 08 Dec 2020 11:34:25 +0000	[thread overview]
Message-ID: <flEE-rGLSc9Ds9oTMxnJ9n2dDZZyljfKrCyko2eJbieceh7uK7R8WiBCCl972MlgD_ZjnZb2p3mYUQH7ujoXeaqPugvChoog-NJuoRElhPM=@protonmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1669 bytes --]

Hi,

This is a trivial patch to fix segfault occurring when generating tags for Erlang source files.


Steps to reproduce:

 1. $ wget https://erlang.org/download/otp_src_23.1.tar.gz  (~85 Mb)
 2. $ tar -xf otp_src_23.1.tar.gz
 3. $ etags otp_src_23.1/lib/*/src/*.erl
   Segmentation fault (core dumped)

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9, cairo version 1.14.6)
 of 2020-11-30 built on sergey-Latitude-5480
Repository revision: 31dcc70e555482fee59df2d8aa1939360d8f8c69
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 16.04.7 LTS

Note: this bug is also present in Emacs 27 release

GDB backtrace:
(gdb) bt
#0  0x00007ffff7b5b48d in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000000000040a7bd in mempcpy (__len=12, __src=<optimized out>, __dest=0x0)
    at /usr/include/x86_64-linux-gnu/bits/string3.h:67
#2  memcpyz (len=<optimized out>, src=<optimized out>, dest=0x0) at etags.c:149
#3  Erlang_functions (inf=0x6280a0) at etags.c:6082
#4  0x000000000040c003 in find_entries (inf=inf@entry=0x6280a0) at etags.c:1901
#5  0x000000000040c75e in process_file (fh=fh@entry=0x6280a0,
    fn=fn@entry=0x7fffffff644c "otp_src_23.1/lib/asn1/src/asn1ct_check.erl", lang=lang@entry=0x0)
    at etags.c:1722
#6  0x000000000040c9e0 in process_file_name (
    file=0x7fffffff644c "otp_src_23.1/lib/asn1/src/asn1ct_check.erl", lang=0x0) at etags.c:1668
#7  0x0000000000401c0c in main (argc=<optimized out>, argv=<optimized out>) at etags.c:1313


The attached patch fixes the above issue.

Thanks and kind regards,
Serge

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-crash-segfault-in-etags-on-generating-tags-for-E.patch --]
[-- Type: text/x-patch; name=0001-Fix-crash-segfault-in-etags-on-generating-tags-for-E.patch, Size: 738 bytes --]

From 366f5570f44a74f60dcf6f0b0cc5c5878a48e2d4 Mon Sep 17 00:00:00 2001
From: Serge Tupchii <serge.tupchii@protonmail.com>
Date: Tue, 8 Dec 2020 11:25:01 +0200
Subject: [PATCH] Fix crash (segfault) in etags on generating tags for Erlang
 files

* lib-src/etags.c: Set allocated and lastlen to zero, after freeing last ptr
  in Erlang_functions to prevent dereferencing NULL pointer
---
 lib-src/etags.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib-src/etags.c b/lib-src/etags.c
index 4315771a49..a1c6837e88 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -6063,6 +6063,7 @@ Erlang_functions (FILE *inf)
 	    {
 	      free (last);
 	      last = NULL;
+	      allocated = lastlen = 0;
 	    }
 	}
       else
-- 
2.29.0


             reply	other threads:[~2020-12-08 11:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 11:34 serge.tupchii via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2020-12-08 20:22 ` bug#45122: [PATCH] 27.1; 28.0.50; Fix crash (segfault) in etags on generating tags for Erlang files Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='flEE-rGLSc9Ds9oTMxnJ9n2dDZZyljfKrCyko2eJbieceh7uK7R8WiBCCl972MlgD_ZjnZb2p3mYUQH7ujoXeaqPugvChoog-NJuoRElhPM=@protonmail.com' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=45122@debbugs.gnu.org \
    --cc=serge.tupchii@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.