Closed letsfindaway closed 3 months ago
From a cursory grep
on UBApplication::app()
it seems like the result is most of the time assumed to be non-nullptr without checking.
In the one case where it is checked, returning a nullptr would disable logging to a file, which doesn't look like it's the problem.
If you've checked and it solves #1004, great. From a theoretic point of view (I don't have this issue), this doesn't seem related.
Of course, the issue remains that UBApplication::app()
is uninitialised memory. Since everything depends on the app, perhaps just aborting the program might be the safest route. The logging could get a check like UBApplication::isInitialized
(using dynamic_cast
like here) to make it clear that it could be called during initialisation.
From a cursory
grep
onUBApplication::app()
it seems like the result is most of the time assumed to be non-nullptr without checking. In the one case where it is checked, returning a nullptr would disable logging to a file, which doesn't look like it's the problem. If you've checked and it solves #1004, great. From a theoretic point of view (I don't have this issue), this doesn't seem related.
It is related in the following way:
UBApplication
is instantiated.SingleApplication
and this again from QApplication
these constructors are executed first.QApplication
a debug message is generated stating "Qt: Session management error: None of the authentication protocols specified are supported". For me this error message occurs since this patch for CVE-2024-36041) was applied to my Plasma5 desktop. This message is what triggers the problem.ub_message_output()
.UBApplication::app()->isVerbose()
.UBApplication
's constructor is still not completed, the mIsVerbose
variable is not initialized and this function returns an arbitrary value from uninitialized memory.true
. Therefore UBSettings::userDataDirectory()
is called to determine the log file directory.dataDirPath
is empty.QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
.setOrganizationName
and setApplicationName
are still not executed, the name of the executable is used to construct the path. In my case this path ends with an all lowercase openboard
.dataDirPath
, which is never changed later.getAppSettings()
uses a wrong file name for the settings for the same reason.Of course, the issue remains that
UBApplication::app()
is uninitialised memory. Since everything depends on the app, perhaps just aborting the program might be the safest route. The logging could get a check likeUBApplication::isInitialized
(usingdynamic_cast
like here) to make it clear that it could be called during initialisation.
I was thinking about better checks for nullptr
but then did not do it for the following reasons:
qApp
is initialized, it always points to an instance of UBApplication
and the dynamic_cast
is always successful.qApp
is completely uninitialized, it contains nullptr
. Here a static_cast
and a dynamic_cast
return the same value, i.e. also a nullptr
. But this is only in the few lines from the beginning of main()
to the construction of the UBApplication
object and there is no usage of qApp
.UBApplication::app()
is called while the object is being constructed. This is never done directly in any code of OpenBoard. The only way I can think for such a call is the indirect invocation from ub_message_output()
as explained above. And here the result of the cast is checked.So I don't think that any further check is necessary.
Thanks for detailing the causal relationship. I agree, this is the best course of action.
This shows how "set at first use" is flawed, but I can't think of anything better.
This PR fixes some strange problems we recently had with OpenBoard using the wrong user data directory. Especially it helps (or even solves?) the problems described in
1004