Skip to content
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

vis2b: fix possibly leak/corruption #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kmarkus
Copy link
Contributor

@kmarkus kmarkus commented Nov 20, 2020

when sending ubx types via lock free fifos, a copy is made. This copy
considers the array length, but does not follow any pointers in the
data-structure.

When the vis2b block reads into its local instance of gc_pose, two
things happen: firstly, the local gc_pose's pointers are overwritten,
thus the references to that memory are lost. Secondly, when vis2b is
shutdown and tries to free it's rotation and translation buffers, it
will likely crash (because that memory has been freed already (by it's
owner, the upstream block) or is invalid).

The quick solution is to just allocate a pose array without allocating
the contained rotation and translation buffers (and not to free these
either). After a successful read (and only then), these fields will be
set and the nbx can be triggered.

Signed-off-by: Markus Klotzbuecher [email protected]

when sending ubx types via lock free fifos, a copy is made. This copy
considers the array length, but does not follow any pointers in the
data-structure.

When the vis2b block reads into its local instance of gc_pose, two
things happen: firstly, the local gc_pose's pointers are overwritten,
thus the references to that memory are lost. Secondly, when vis2b is
shutdown and tries to free it's rotation and translation buffers, it
will likely crash (because that memory has been freed already (by it's
owner, the upstream block) or is invalid).

The quick solution is to just allocate a pose array without allocating
the contained rotation and translation buffers (and not to free these
either). After a successful read (and only then), these fields will be
set and the nbx can be triggered.

Signed-off-by: Markus Klotzbuecher <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant