Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed SIGSEGV caused by wrong initialization order #2664

Closed
wants to merge 2 commits into from
Closed

fixed SIGSEGV caused by wrong initialization order #2664

wants to merge 2 commits into from

Conversation

moodyhunter
Copy link

@moodyhunter moodyhunter commented Apr 13, 2021

Your checklist for this pull request

Detailed description

For the ImportsWidget class, its importsModel and importsProxyModel are initialized before the constructor, whilst the imports variable is initialized after them using default initlization order. (See https://en.cppreference.com/w/cpp/language/constructor (Initialization order section))

This leads to undefined behaviour when taking the address of imports to construct the ones before imports itself is constructed.

This PR changed the order that they three appears in the class member variable declaration, making imports the first one of the three to construct, which fixed a possible segmentation fault on my machine.

The same for RelocsWidget

Update:

My SIGSEGV back trace:

image

Test plan (required)

Compile and run.

Closing issues

Currently none.

@karliss
Copy link
Member

karliss commented Apr 13, 2021

These same issue is handled by 561a191 in #2662

@moodyhunter
Copy link
Author

moodyhunter commented Apr 13, 2021

@karliss Thanks for the clarify.

However, I find the Qt5 build is also affected, (e.g. the recent versions in ArchLinux packages).

Should this fix be backported?

@moodyhunter moodyhunter reopened this Apr 13, 2021
@karliss
Copy link
Member

karliss commented Apr 14, 2021

Yes, I confirmed that it also affects Archlinux version of QT with KDE patches. Not surprising that changes done at some point after 5.15.2 release are also included Qt 6.

I am not sure what you meant by "Should this fix be backported?". Qt6 branch isn't for replacing Qt5 with Qt6 it's for adding support compiling with both, using the same code as much as possible. So no backporting will be required it will be required.

@moodyhunter
Copy link
Author

I wonder if we can apply this patch to the existing Qt5 version so that ArchLinux users will not experience a crash during startup.

@karliss karliss mentioned this pull request Apr 19, 2021
3 tasks
@lenerd
Copy link

lenerd commented Apr 22, 2021

Applying this patch to the current 2.0.1 release fixes the segfault for me (also Arch Linux). Thanks!

Will there be a new release soon that contains a fix, or do we have to wait until the whole QT6 support is ready?

@karliss
Copy link
Member

karliss commented Apr 22, 2021

Yes there will be 2.0.2 soon that's why the milestone is there. It's mostly a matter of finishing code reviews. As was said multiple times "More Qt6 support" PR isn't "all the QT6 support". I doubt full Qt6 support will be finished earlier than 2.2 or 2.3. I want the #2662 to be included in 2.0.2 because it includes at least one more change that causes a more subtle bug with Qt6 and possibly current or future Qt 5.15.2 patches.

@lenerd
Copy link

lenerd commented Apr 22, 2021

@karliss Ah, ok. Thanks for your work on this!

@karliss
Copy link
Member

karliss commented Apr 25, 2021

Cutter 2.0.2 has been released including a different implementation of this fix.

@karliss karliss closed this Apr 25, 2021
@moodyhunter
Copy link
Author

Thanks!

@moodyhunter moodyhunter deleted the patch-1 branch April 26, 2021 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants