FS#78032 - [clang] Usage of _GLIBCXX_ASSERTIONS makes clangd extremely unstable

Attached to Project: Arch Linux
Opened by Aaron Barany (akb825) - Wednesday, 29 March 2023, 01:22 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:18 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Evangelos Foutras (foutrelis)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:
The default Arch compile flags enable _GLIBCXX_ASSERTIONS, which causes clangd to be extremely unstable. This in turn makes IDEs (such as Qt Creator) and plugins that rely on clangd have many essential features borderline unusable. This is very common for unmatched parentheses or brackets, which typically happens when writing code while clangd processes the files while in the middle of typing. In practice this causes dozens of crashes each day, and the application using clangd may simply give up and disable many of its features if it detects that it crashed too much.

I rebuilt clang adding the following to CXXFLAGS: "-Wp,-U_GLIBCXX_ASSERTIONS". After applying this modification the consistent crashing no longer occurs. While the ideal solution would be to fix the assertions upstream, these Arch-specific build options result the user experience is significantly inferior to the default build of clang or the builds typically found in other distributions.

To at least have the usability on Arch to be on par with other systems, I request that "-Wp,-U_GLIBCXX_ASSERTIONS" be added to the CXXFLAGS for the clang package to disable these assertions for this package.

Additional info:
* package version: 15.0.7-2

Steps to reproduce:
1. Open a C or C++ file in a program that utilizes clangd, such as Qt Creator.
2. Edit a function with an unterminated open parenthesis. For example, an unclosed assert(
3. Notice that clangd will crash until the parentheses are closed. Many features, including code completion and semantic highlighting, will be unavailable in the meantime. If it crashes enough times in a short period the clangd features will be disabled, using a fallback that only has partial functionality.
This task depends upon

Closed by  Buggy McBugFace (bugbot)
Saturday, 25 November 2023, 20:18 GMT
Reason for closing:  Moved
Additional comments about closing:  https://gitlab.archlinux.org/archlinux/p ackaging/packages/clang/issues/3
Comment by Toolybird (Toolybird) - Wednesday, 29 March 2023, 05:41 GMT
> The default Arch compile flags enable _GLIBCXX_ASSERTIONS

...which was originally "borrowed" from Fedora [1]. FWIW Fedora compile clang with _GLIBCXX_ASSERTIONS enabled. Just sayin..

[1] https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/rawhide/f/buildflags.md
Comment by Aaron Barany (akb825) - Wednesday, 29 March 2023, 18:21 GMT
In the case of Fedora it probably makes sense for a couple of reasons:
1. Fedora is effectively a testing ground for RedHat Enterprise Linux.
2. Applying it by default should help increase safety for any applications that might be security-critical.

I won't argue against the decision for the usage of this flag by default in Arch, it certainly is a bug to trigger the assertions. However, in some cases (either situations like this where the program is extremely unstable, or for performance-critical applications) it may make sense to selectively disable it.

Either way, I have created an upstream bug report: https://github.com/clangd/clangd/issues/1559 Hopefully this will be fixed so disabling assertions won't be needed, but it would at least be very helpful as a stopgap. The constant crashing has been rather disruptive in my own day to day work at least.
Comment by krumelmonster (krumelmonster) - Friday, 22 September 2023, 17:32 GMT
While the upstream bug persists, I want to second akb825s request. QtCreator has been very frustrating to use for months. Now that I've got to the bottom of it I'm building clang myself but it takes many hours.
Comment by Aaron Barany (akb825) - Saturday, 23 September 2023, 00:24 GMT
If you want to avoid rebuilding clang, you can also download the pre-built binary from the clangd releases (https://github.com/clangd/clangd/releases) and change the path to the clangd executable in Qt Creator in the preferences. (C++ section, clangd tab) You also won't have to rebuild clang again the next time the Arch package is updated.

Loading...