all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pip Cet via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Eli Zaretskii <eliz@gnu.org>,
	71744@debbugs.gnu.org, sigve.indregard@pm.me
Subject: bug#71744: 29.4; SIGSEGV during completion-at-point in lsp-mode with corfu and cape
Date: Sat, 17 Aug 2024 07:46:07 +0000	[thread overview]
Message-ID: <878qwvk2x0.fsf@protonmail.com> (raw)
In-Reply-To: <ea999bf1-670d-4f6e-9fbe-f7eee951f2d9@cs.ucla.edu>

"Paul Eggert" <eggert@cs.ucla.edu> writes:
> On 2024-08-16 08:08, Pip Cet wrote:
>> /* Work around GCC bug 54561.  */
>> #if GNUC_PREREQ (4, 3, 0)
>> # pragma GCC diagnostic ignored "-Wclobbered"
>> #endif
>>
>> which means we won't get any warnings at all about such bugs.
>>
>> However, even with that part removed, I don't get a compiler warning
>> about 'c'.
>
> With that part removed I got a warning about 'kb', not 'c'. The 'kb'

Oh, that's interesting! Can you let me know which GCC version that was,
and which compiler flags?

I don't get that diagnostic here.

> warning was a false positive, the 'c' warning a false negative. The most
> likely explanation, I think, is that GCC got confused and put the wrong
> identifier name in its diagnostic. This would help to explain a lot of
> the -Wclobbered false positives we've gotten over the years, which has
> caused us to ignore -Wclobbered.

Hmm. I've looked at the (current) GCC code, and I don't see how it got
confused, but I'll look again :-)

>> What's weird about this is that the store at +5463 that's causing our
>> problem isn't necessary, and neither is the load at +5479. The variable
>> in question, 'kb', is not marked volatile, so it seems strange to me it's
>> stored, then loaded, unnecessarily.
>
> My guess is that GCC internally coalesced the two variables, and got
> confused because one was clobbered and the other was not, and issued a
> warning that it clobbered the variable but mistakenly said 'kb' not 'c'.
> The C standard entitles GCC to clobber 'c' so this isn't wrong code,
> it's just a bad (a *really* bad) diagnostic.

I agree. It is, however, suspiciously badly-optimized code, and it only
happens with -flto here...

Note that, by my reading of the source code, GCC warns only about
variables that it actually clobbered, not variables that might have been
clobbered by another compiler obeying the C standard differently. Maybe
the best way to deal with that is to default to making "clobbered" an
error, not a warning.

>> Paul, do you agree that we should simply mark 'c' as volatile, or do you
>> think this needs further investigation on the GCC side (because of the
>> lack of a -Wclobbered warning being issued, or because of the weird
>> code)?
>
> We definitely should mark 'c' as volatile, or do something equivalent,
> because the Emacs code violates the C standard.
>
> Also, if my hypothesis of the mistaken identifier is correct, we should
> stop ignoring -Wclobbered, and instead pacify GCC without using
> -Wclobbered. That way, when we screw up in setjmp related code, we'll
> get *some* warning that *something* is being clobbered, and can investigate.
>
> To do that, I installed the attached patches into the Emacs master
> branch. While looking into this I noticed several uses of clobbered
> variables (i.e., violations of the C standard) and fixed them. Patches
> 0001-0004 fix these similar bugs elsewhere. Patch 0005 implements your
> suggestion and should fix Bug#71744. Patch 0006 is a minor performance
> improvement over Patch 0005.
>
> Please give these patches a try. Patch 0005 is simple and if it works
> for the original bug reporter we should be able to close the bug report
> as fixed.

Thank you very much! This seems like the best course of action.

Pip






  parent reply	other threads:[~2024-08-17  7:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-23 21:16 bug#71744: 29.4; SIGSEGV during completion-at-point in lsp-mode with corfu and cape Matthew Rothlisberger
2024-06-24 12:28 ` Eli Zaretskii
2024-06-26 23:27   ` Matthew Rothlisberger
2024-06-27 10:05     ` Eli Zaretskii
2024-08-14 13:22 ` Sigve Indregard via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-14 13:57   ` Eli Zaretskii
2024-08-14 15:40     ` Sigve Indregard via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-14 16:03       ` Eli Zaretskii
2024-08-14 16:22         ` Eli Zaretskii
2024-08-14 16:37           ` Sigve Indregard via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-14 17:03           ` Pip Cet via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-15  9:07           ` Pip Cet via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-16 15:08             ` Pip Cet via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-17  4:37               ` Paul Eggert
2024-08-17  6:14                 ` Eli Zaretskii
2024-08-17 18:23                   ` Paul Eggert
2024-08-17  7:46                 ` Pip Cet via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-08-17 18:27                   ` Paul Eggert

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=878qwvk2x0.fsf@protonmail.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=71744@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=pipcet@protonmail.com \
    --cc=sigve.indregard@pm.me \
    /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.