-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
wb_supervisor_field_get_sf_node can cause OSError #4535
Comments
Oddly enough, if navigating through the tree directly (i.e. following the sequence as expressed through the PROTO headers (since everything is exposed), it actually works correctly.
If navigating within the PROTO body as you mentioned:
the last line does indeed fail and it triggers this assert, which doesn't appear to have anything to do with anything, since we are not dealing with devices |
Ok, turns out it's complicated and messy, but whether it's wrong or how it could be improved I'm uncertain.
or alternatively like this:
Fundamentally it doesn't matter, they are equivalent but the first shows better that we're dealing with fields internal to a PROTO. The problem stems from the second to last request, not actually the last one, in fact we ask the supervisor for:
But since we're dealing with internal fields, it should've been requested using the As to why it crashes, is because depending on which function we use, the parent node So basically it's a mess, but although messy I'm not entirely certain it's actually broken. Very obscure and easily prone to mistakes absolutely, but I'm not certain it's fundamentally wrong based on what the controller requests relative to the node tree in question. |
I think that since it crashes, that means it's actually broken. It may be that the decision will be that one shouldn't be able to fetch values from such fields, but if so, it should print a warning and return null rather than crashing. Anyway, I've also run into similar bugs where protos are nested inside a hidden MF field rather than a hidden SF field. E.g. a standard |
I doubt that this would've been addressed by #6613. I tried to leave as much of the existing code intact as possible. However, based on the above comments, my guess is that this might've been fixed by #5774. If it wasn't I'd have to do some more detailed debugging to figure stuff out. My guess would be that |
I can reproduce this issue on R2022a, but not R2023b, so it's probably been resolved (maybe by the aforementioned PR). If this pops back up feel free to reopen the issue :D Test files: |
Describe the Bug
Calling
wb_supervisor_field_get_sf_node
(hereafter abbreviated asget_sf_node
) on someSFNode
fields causes "OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF" when called via Pythonctypes
.get_sf_node
usually works fine, including onSFNode
fields within the internal structure of protos. However, I have experienced this problem where there are nested protos, e.g. anUnevenTerrain
proto whose exposedappearance
is aSand
proto.Steps to Reproduce
Create an
UnevenTerrain
proto with aSand
proto in its exposedappearance
field, and give theSand
proto'stextureTransform
ascale
like(3, 3)
. Now usewb_superviser_...
functions to traverse down inside theUnevenTerrain
proto's hidden structure to find its shadow copy of thattextureTransform
.Put briefly: if
ut
is theUnevenTerrain
proto, theSFNode
field that causes the error isut.children[0].children[0].appearance.textureTransform
.Put less briefly: start at the
UnevenTerrain
, useget_proto_field
to get its hiddenchildren
field, useget_mf_node
to get the 0th child in that field (aTransform
node), useget_field
to get that node's ownchildren
field, useget_mf_node
again to get its 0th child (aShape
node), useget_field
again to get itsappearance
field, useget_sf_node
to get its content (a shadowy copy of theSand
proto), useget_field
to get itstextureTransform
field, and callget_sf_node
on thattextureTransform
field.Actual behavior
The python supervisor will crash, saying "OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF".
Expected behavior
This should return a
wbNodeRef
for the hiddenTextureTransform
subnode, just as callingget_sf_node
on other fields within the hidden parts of a proto returnswbNodeRef
s for other proto subnodes. You can see that Webots knows that thisTextureTransform
is there, and that it has the given scale(3, 3)
, by usingexport
from any intervening node in the above path.If, for some reason, Webots really can't return an actual node for nested protos like this, then it should return a null
wbNodeRef
rather than crashing.Discussion
The address mentioned in the error,
0xFFFFFFFFFFFFFFFF
, is an alternative representation of-1
, which itself is the value thatwb_supervisor_node_get_id
returns for all non-exposed proto subnodes. One hypothesis is that, for some reason,get_sf_node
is blindly using such anid
when it shouldn't be. I'm not sure why it does that in this case, but doesn't do it in other cases, but my guess is that it has something to do with the nested protos. I have tested similarly automatedly traversing the internal structure of all protos in a fairly complex world, and this is the only instance that has caused errors. I think this is also the only instance in that world where a proto internally re-uses another proto that was given in one of its exposed fields, so my guess is that has something to do with causing the problem.The text was updated successfully, but these errors were encountered: