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

ITunesXMLImporterTest: Fix sporadic crash due to a not initalized reference. #11666

Merged
merged 5 commits into from
Aug 11, 2023

Conversation

daschuer
Copy link
Member

@daschuer daschuer commented Jun 18, 2023

Use a function call with a null check instead.

The failing test has happened on Launchpad:
https://launchpadlibrarian.net/672913729/buildlog_ubuntu-focal-amd64.mixxx_2.4~beta~22~ge7bb02f7a5-1~focal_BUILDING.txt.gz

…erence.

Use a function call with a null check instead.
@daschuer
Copy link
Member Author

daschuer commented Jun 20, 2023

Finally rebased and all green. Sorry for the noise.
We should merge this soon, because our beta ppa keeps failing.

@ronso0
Copy link
Member

ronso0 commented Jun 20, 2023

because our beta ppa keeps failing

Just the Focal amd64 build fails, so to have a package ASAP for this, too, how about disabling the test just for this build? (if that's possible) To not merge this in a rush..

@Swiftb0y
Copy link
Member

humbly requesting @fwcd opinion on this refactoring.

Copy link
Member

@fwcd fwcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some quick notes from glancing over the changes, I'll see if I can do a more thorough review over the next few days

src/library/itunes/itunesimporter.h Show resolved Hide resolved
src/library/itunes/itunesfeature.h Outdated Show resolved Hide resolved
src/library/itunes/itunesfeature.h Show resolved Hide resolved
@fwcd
Copy link
Member

fwcd commented Jun 20, 2023

I haven't dug into the test log, so I am not sure if I understand the problem this fixes yet, but if there is some unsafe reference in there, could we perhaps fix the bug in isolation before refactoring it?

@daschuer
Copy link
Member Author

because our beta ppa keeps failing

Just the Focal amd64 build fails, so to have a package ASAP for this, too, how about disabling the test just for this build? (if that's possible) To not merge this in a rush..

OK, I went a head and disabled the test in a18b0b9 as a direct 2.4 commit.

Now all PPA builds are succeeding: https://launchpadlibrarian.net/673323201/buildlog_ubuntu-focal-amd64.mixxx_2.4~beta~26~ga18b0b9269-1~focal_BUILDING.txt.gz

@daschuer daschuer changed the base branch from main to 2.4 June 21, 2023 08:17
Co-authored-by: FW <30873659+fwcd@users.noreply.github.com>
@daschuer
Copy link
Member Author

if there is some unsafe reference in there, could we perhaps fix the bug in isolation before refactoring it?

OK, due to disabling the test the pressure is gone and we may go for a refactoring.

The original root cause for the crash was that the const std::atomic<bool>& m_cancelImport; had random values.
During the fix I have read the suggestion for refactoring and tried to follow it make m_cancelImport a value type in ITunesImport. This however did not work good, because it is used in ImporterImpl keeping the cyclic dependency.
In addition the cyclic dependency is used anyway in TreeItem::newRoot(m_pParentFeature);

IMHO this solution is now on a pragmatic middle ground with a function call utilizing the already existing pointer after a null check.

@fwcd
Copy link
Member

fwcd commented Jun 21, 2023

the const std::atomic<bool>& m_cancelImport; had random values.

How does this happen? Do members in C++ not initialize (deterministically) before methods can be called or does the test framework do some magic there that breaks this?

std::atomic<bool> cancelImport;

My understanding was that this would (safely) initialize cancelImport to false.

@daschuer
Copy link
Member Author

I have also no explanation why it is not initialized during tests.

@daschuer daschuer added this to the 2.4.0 milestone Aug 5, 2023
src/library/itunes/itunesfeature.h Show resolved Hide resolved
src/library/itunes/itunesfeature.h Outdated Show resolved Hide resolved
src/library/itunes/itunesimporter.cpp Outdated Show resolved Hide resolved
src/library/itunes/itunesimporter.h Show resolved Hide resolved
@Swiftb0y
Copy link
Member

I have also no explanation why it is not initialized during tests.

Apparently thats legal, even though many compilers still initialized it. https://stackoverflow.com/questions/36320008/whats-the-default-value-for-a-stdatomic

@daschuer
Copy link
Member Author

Done

Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Should be good now after the build issues are fixed.

daschuer and others added 2 commits August 11, 2023 08:08
Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
@Swiftb0y Swiftb0y merged commit ff0b8c3 into mixxxdj:2.4 Aug 11, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants