-
Notifications
You must be signed in to change notification settings - Fork 99
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
fix: stardict qstring modification #1708
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4f28548
fix:stardict crash
xiaoyifang 83ab14a
fix:stardict crash
xiaoyifang 973252a
fix:stardict crash
xiaoyifang ce733b9
fix:stardict crash
xiaoyifang c079d0b
fix:stardict crash
xiaoyifang 978c6d7
fix:stardict crash
xiaoyifang 89d8275
fix:stardict crash
xiaoyifang 0b879b8
fix:stardict crash
xiaoyifang 0e342a4
fix:stardict crash
xiaoyifang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference is pretty subtle.
std::string(toUtf8().data())
will seek for the null byte againstd::string(toUtf8().data(),toUtf8().size())
will use the articleText's actual lengthMaybe there should be a comment that clarify
articleText
may contain null byte, and we want to cut off earlier?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the original code is
return (articleText.toUtf8().data());
I changed it intoreturn articleText.toStdString()
,crash still reported on this line.So I split it into two lines.
I guess
articleText.toUtf8()
will generate a temporary string . when chained with.data()
. sometimes the temporary variable has no longer existed. and a crash will throw.From real environment test ,the crash has more probability to happen when in multithread cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the old code is
return (articleText.toUtf8.data());
,toStdString()
is my first attempt.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://bugreports.qt.io/browse/QTBUG-63274
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any relation?
https://doc.qt.io/qt-6/qstring.html#details:~:text=Note%3A%20Due,for%20more%20information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also can not be sure.
But Qt+MSVC +QString are more likely to have issue as the https://bugreports.qt.io/browse/QTBUG-63274 implies
Maybe some link option in CMAKE , /MD /MT etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be the correct way to set /MD /MT
https://github.com/qt/qtbase/blob/02cb165ef8050230b477358e4136e9f0acd83eb6/cmake/QtPublicTargetHelpers.cmake#L395-L397
However, CMake's doc says
So, I suppose it is set correctly by CMake already.
https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should cmake_policy be set?
https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html#:~:text=Note%20This%20property%20has%20effect%20only%20when%20policy%20CMP0091%20is%20set%20to%20NEW%20prior%20to%20the%20first%20project()%20or%20enable_language()%20command%20that%20enables%20a%20language%20using%20a%20compiler%20targeting%20the%20MSVC%20ABI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
cmake_minimum_required
will set policy version, and we currently set it aggressively high 😅.https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html#policy-settings
goldendict-ng/CMakeLists.txt
Line 1 in 3ef35da
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think searching in the
build.ninja
file in the build folder can confirm if /MD /MT is set.On my machine, /MDd is automatically set.