Repository navigation
Report an error when the VT server can't use an object pool - #743
Conversation
There was a problem hiding this comment.
Looks good overall. One thing I would change: I don't think this should Fixes #707, since that issue is specifically about validating invalid IOP values such as an InputBoolean value of 24. That validation is still not added here, so the issue would be closed while the original problem remains.
I'd remove the Fixes #707 reference and keep this PR focused on the VT server error handling fixes. And add the detection of invalid IOP attribute values (specifically an InputBoolean value like 24 in #707) inside another PR
|
Good point, I agree. Missed the checking part. I changed the wording on this. I'll open another PR for the |
|
I checked the standard before starting the I would still like to keep this PR. When a pool fails to parse for any other reason, the server still answers the End of Object Pool with "no error", so the client thinks its pool was accepted. This PR makes it send the error bits and the faulting object ID instead. |
…error-response # Conflicts: # test/vt_server_tests.cpp
|
|
I have a feeling that most VT-s I touched are working at V3 levels. With that being said should we start to add bunch of IF / ELSE for all these things depending on the version? (I.e. refuse the iop becuase we enforce V3 or we let it slip because V4 allows it?) If we're at V3 levels we should enforce V3 compatibility (but that'll be a pain to manage in the long run) I really don't think there's a good solution here. The error reporting is definitely needed though. |
|
I agree, I don't think there is a clean solution for this. Enforcing different behavior based on VT version can be exhausting as there are a lot of other behaviors which are different between versions but it can also build strong foundation. And it will require to keep track of version attribute on most behavior. |
|
I think we should separate VT client and VT server behavior here:
|



Describe your changes
Related to #707 but does not close it. #707 is about catching invalid values like an
InputBooleanwith value24, and that check is not in this PR. This PR fixes the part before it: the server telling the client when a pool is not usable.The server already has everything it needs to report a bad object pool, it just doesn't use it. In
VirtualTerminalServer::update()theFailbranch calledsend_end_of_object_pool_response(true, ...), so a pool which failed to parse went back to the client with byte 2 and byte 7 both zero. In ISO 11783-6 that is the encoding for "pool accepted". So the client connects, gets an empty object tree, and shows nothing. It looks like the VT took the pool, which makes this confusing to debug.While I was there I found a second one which is worse. A pool can parse fine and still have no Working Set object. That branch dereferenced
get_working_set_object()without a check, andget_object_by_id()ends instd::map::operator[], which inserts a nullshared_ptrfor a missing key. So the server segfaults, and a client can do it with a one object pool.Changes:
ObjectPoolErrorBitso the call sites don't pass bare numbers.errorCodesparameter ofsend_end_of_object_pool_response()toobjectPoolErrorCodes. It goes into byte 7, but in the clienterrorCodesmeans byte 2. Same name for two bytes is what made this easy to call wrong.print_objectpool_error()didn't decode byte 2 bit 0, the one bit the server sets now, so it printed the header line and then nothing. Added it.initialize()never setinitialized, so the destructor'sif (initialized)never removed the rx callback. Every destroyed server left a danglingprocess_rx_messageregistration behind. I only hit it because two server tests now share one binary, but it isa use after free in any app which destroys a server.
The first commit is separate.
Containeris allowed as a child of data masks, alarm masks and the version 2 auxiliary objects, but the parser rejected it there, so a conformant pool could fail to load for no reason. Cross-checked withallowed_object_relationships.rsin AgIsoTerminalDesigner.How has this been tested?
Three new tests. Two push a bad pool through the server over VirtualCAN and check the error bits which actually go out on the wire, one for a pool that fails to parse and one for a pool with no working set object. The third covers the
Containerparent types.