all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 61960@debbugs.gnu.org
Subject: bug#61960: 30.0.50; Unexec build reliably crashes during loadup
Date: Fri, 21 Jul 2023 19:09:04 +0300	[thread overview]
Message-ID: <26a72dd4ef44849cbf2ed99f61199779e411136f.camel@yandex.ru> (raw)
In-Reply-To: <cada50ac5139899d75e71a59922bc168a1451612.camel@yandex.ru>

Okay, so I've spent today a lot of time debugging this problem, and out
of interesting things I found so far the following:

1. Problem seems like some discrepancy between _heapinfo and an abase
whose index points at _heapinfo
2. Given two Emacs executions, one which buggy and one isn't, I found
that "good execution" returns from `aligned_alloc` the same result it
gotten from `_malloc_internal_nolock`, whereas in "bad execution" it's
different.
   The reason for this is that inside `aligned_alloc()` "good
execution" *never* goes into `if (adj != 0)` condition. The function
has 3 places where `malloc` is called (which is not actually a malloc()
but instead a wrapper `gmalloc` eventually calling into
`_malloc_internal_nolock()`), one of which is inside the mentioned
condition. The latter one changes `malloc` result, while 2 others do
not.

In the lieu of that it is possible that this conditional branch simply
was never tested. I decided to check how it works in a usual Emacs
build, and I found out that it doesn't even have `gmalloc.c` source
compiled in 🤷‍♂️

-----------------------

That makes me wonder if keeping this whole customized allocation engine
even makes sense. It is not used in the actual Emacs, only in `temacs`
— but why? Is it to make `temacs` faster? I would imagine in the
"compilation usecase" where `temacs` is used, shaving off a few seconds
is not worth that complexity (not to mention I am not sure how well
this code may compete with specialized allocator projects like
"jemalloc", which also do allocation caching). This code is
incomprehensible. It does funny stuff like redefining system functions,
like `malloc` to its wrappers, so even just reading it is hard. And
I've spent hours watching simultaneously two `temacs` executions, "bad"
and "good" one, recorded with `rr record`, using reverse-execution and
watchpoints and still not sure how close I am to solving the case. 

So, I would be glad to hear what people think about the purpose of this
gmalloc being in the project.






  reply	other threads:[~2023-07-21 16:09 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-04 14:55 bug#61960: 30.0.50; Unexec build reliably crashes during loadup Eli Zaretskii
2023-03-04 19:50 ` Konstantin Kharlamov
2023-03-04 19:51   ` Konstantin Kharlamov
2023-03-04 20:05     ` Konstantin Kharlamov
2023-03-04 20:26       ` Konstantin Kharlamov
2023-03-05  5:52       ` Eli Zaretskii
     [not found]     ` <xjf4jr0xkar.fsf@ma.sdf.org>
2023-03-04 21:56       ` Konstantin Kharlamov
2023-03-04 22:00         ` Konstantin Kharlamov
2023-03-04 22:08           ` Konstantin Kharlamov
2023-03-04 23:38             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-05  5:59             ` Eli Zaretskii
     [not found]           ` <xjf7cvtx0q0.fsf@ma.sdf.org>
2023-03-06 18:29             ` Eli Zaretskii
2023-03-07 14:59               ` Andrea Corallo
2023-03-07 15:33                 ` Eli Zaretskii
2023-03-11  7:22                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]                     ` <xjfpm9es4qe.fsf@ma.sdf.org>
2023-03-12 23:49                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]                         ` <xjf3566s29a.fsf@ma.sdf.org>
2023-03-15 13:56                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-15 14:26                             ` Eli Zaretskii
2023-03-16  0:30                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-16  6:25                                 ` Eli Zaretskii
     [not found]                             ` <xjfv8j2qe69.fsf@ma.sdf.org>
2023-03-16  0:33                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-16  6:26                                 ` Eli Zaretskii
2023-03-05  5:46   ` Eli Zaretskii
2023-07-02  1:50   ` Konstantin Kharlamov
2023-07-02  2:27     ` Konstantin Kharlamov
2023-07-02  5:52     ` Eli Zaretskii
2023-07-02 11:32       ` Konstantin Kharlamov
2023-07-02 11:54         ` Konstantin Kharlamov
2023-07-02 14:10         ` Konstantin Kharlamov
2023-07-21 16:09           ` Konstantin Kharlamov [this message]
2023-07-21 16:30             ` Eli Zaretskii

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=26a72dd4ef44849cbf2ed99f61199779e411136f.camel@yandex.ru \
    --to=hi-angel@yandex.ru \
    --cc=61960@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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.