279 bug in move assignment of matrices#286
Conversation
anyzelman
left a comment
There was a problem hiding this comment.
Hi @byjtew @aleksamilisavljevic could you have a look at the rfc? The first is easy, the second is a little bit tricky to think about-- is the suggestion ok or am i missing something?
|
Concept release notes: Aleksa uncovered a bug where move-assigning matrices could result in container IDs not explicitly being removed. Since IDs are created on the basis of unique keys and the unique keys are derived from pointers, the following could (and did) happen: on creating a new matrix, a new ID is requested based on the same pointer the retained ID was also created with. This was detected by the internal mechanism keeping track of IDs, and resulted in an exception. This MR fixes the bug by removing the ID once the container with the original pointer is destroyed via a move. Even if a subsequent allocation then happens to return the same pointer, the internal state is now clean and a new ID is successfully derived. The MR also strengthens the The MR also includes a hotfix for an issue detected by our internal CI: on defining full debug tracing ( Finally, this MR and now again fully related with the issue at hand, improves on Thanks to Aleksa Milisavljevic @aleksamilisavljevic for detecting and fixing this bug! |
…nly when compiling with full tracing (i.e. _DEBUG) defined
…aks and never-freed IDs
|
GitHub CI OK, manual unit tests with LPF and with |
Prior to this MR, the implementation guarantees retention of IDs when subject to copy-assignment. However, under move-assignment, the moved-to container relinquishes its resources, taking over the resources of the moved-from container instead. This implies that the moved-to container takes over the ID of the moved-from container (while the ID, and general state, of the moved-from container becomes undefined). This issue was previously detected and fixed for ALP/GraphBLAS matrices in #279 / #286, which also introduces a unit test for preventing regressions. This MR introduces a unit test for move-assignment of vectors, which confirmed that ALP prior to this MR had invalid behaviour re IDs when move-assigning vectors, as issue #168 indeed suspected. This MR fixes those issues, and includes two minor additional code style fixes.
Prior to this MR, the implementation guarantees retention of IDs when subject to copy-assignment. However, under move-assignment, the moved-to container relinquishes its resources, taking over the resources of the moved-from container instead. This implies that the moved-to container takes over the ID of the moved-from container (while the ID, and general state, of the moved-from container becomes undefined). This issue was previously detected and fixed for ALP/GraphBLAS matrices in #279 / #286, which also introduces a unit test for preventing regressions. This MR introduces a unit test for move-assignment of vectors, which confirmed that ALP prior to this MR had invalid behaviour re IDs when move-assigning vectors, as issue #168 indeed suspected. This MR fixes those issues, and includes two minor additional code style fixes.
Closes #279