[RFC] Return error instead of aborting when receiving an unexpected answer
Needs RevisionPublic

Authored by fifr on Feb 13 2020, 8:32 PM.

Details

Reviewers
dfaure
meven
Group Reviewers
Frameworks
Summary

If SlaveBase::waitForAnswer receives an unexpected subcommand it aborts by calling qFatal. However, an unexpected subcommand could be received due to external causes, hence the error should be handled properly instead of abort.

BUG: 416895
FIXED-IN: 5.68

Diff Detail

Repository
R241 KIO
Lint
Lint Skipped
Unit
Unit Tests Skipped
fifr created this revision.Feb 13 2020, 8:32 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptFeb 13 2020, 8:32 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
fifr requested review of this revision.Feb 13 2020, 8:32 PM
fifr retitled this revision from Return error instead of aborting when receiving an unexpected answer to [RFC] Return error instead of aborting when receiving an unexpected answer.
fifr added a reviewer: kiokiio.
nicolasfella edited reviewers, added: Frameworks, dfaure, meven; removed: kiokiio.Feb 13 2020, 8:38 PM
broulik added inline comments.
src/core/slavebase.cpp
1100

Should at least be qWarning imho

dfaure requested changes to this revision.Apr 14 2020, 8:44 PM

I don't understand what these "external causes" might be.

The bug report doesn't say more other than "happens after a suspend".
This needs further debugging IMHO.

This revision now requires changes to proceed.Apr 14 2020, 8:44 PM
fifr added a comment.Apr 15 2020, 7:02 AM

Well, the main problem for me is that I do not know what waitForAnswer is supposed to to and in which situation it is supposed to be called. The assumptions that I made are the following:

  • it is called to receive an answer after some kind of command (that should trigger the answer from peer) has been invoked
  • this answer is potentially received from an external source, e.g. a network connection (it's some KIO code in the end ...)
  • the validity of this answer has not been verified before, i.e. it could be possible that the incoming data is wrong (e.g. transmission error of any kind)

Therefore, the call to isSubCommand is basically (part of) the verification that the incoming data is correct.

The real question, that I simply cannot answer, is whether it should be logically impossible that isSubCommand returns false in this case. Only then aborting with qFatal would be justified (in my opinion), otherwise the case that isSubCommand returns false should be handled properly, not just aborting.

My problem is that I do not understand the underlying architecture of the code at all. So I hoped that someone who knows the code could comment on whether it is logically possible (given that for whatever reason invalid data has been received by the call to d->appConnection.read(&cmd, data) a few lines above) that isSubCommand fails or not. For me this judgement is impossible. Even if I could reproduce the error reliably (should be possible at least on my system, but whole architecture seems to be very complex so that I do not even know where to start) I would not know whether the problem is here in this code (isSubCommand could fail) or somewhere else (isSubCommand must not fail), because I do not know how it is supposed to be.

After all, I would be very happy to assist and provide further information, I just do not know what to do.

Btw: I've been using this patch for several weeks now and the problem vanished completely.