KavrakiLab / vamp

SIMD-Accelerated Sampling-based Motion Planning
Other
108 stars 10 forks source link

Use unaligned store and correct buffer sizes for numpy methods #14

Closed wbthomason closed 2 weeks ago

wbthomason commented 3 weeks ago

Fixes #9.

In cases where a robot's dimension isn't a multiple of the vector width, it was possible to attempt to store a vector with an aligned store instruction (on x86 systems) to an unaligned address when outputting a path to a numpy array, resulting in a segfault. There were also some small errors in the indexing and buffer size, which could also have caused segfaults. We didn't see these errors before because (1) luck with robot state dimensions and (2) the problem does not seem to occur on ARM systems (e.g., Macbooks), which we used to try to reproduce #9.

This PR adds an unaligned store operation to the vector backend and a to_array_unaligned method using this operation to the vector interface to, in cases like this where performance isn't critical, simply use an unaligned store to avoid the segfault. It also fixes the indexing and buffer size issues and some miscellaneous memory-related warnings that cropped up with the new version of g++.

wbthomason commented 2 weeks ago

Merging as I'm fairly confident that this fixes the problem and does not introduce regressions.