Concurrency scenarios that involve deep reflection of import namespaces
with deep maps and slices can create problems during reflection of a Get
result that ultimately create two problems:
Concurrent modification of a map, or concurrent iteration and
modification of a map. We do not perform any locking on this data, and,
given that the result should be read-only at this point, there should
not need to be.
The above alludes to the fact that the current result reflection is
actually modifying the result value in-place when it comes to maps and
slices. This method is assuming that the data in the result is actually
a copy of any underlying import data, which is actually not the case -
in addition to the nuances of Go map and slice internals, the return
data could contain direct pointers to namespaces or other internal
structures that would not be expecting to be altered by a process
working on the result of a call.
This updates the internal reflectMap and reflectSlice methods to ensure
that results of data transformation are being written to new maps and
slices, instead of the existing ones. This corrects both issues - map
writes are no longer happening concurrently to the same map, and
original values are not being modified.
Concurrency scenarios that involve deep reflection of import namespaces with deep maps and slices can create problems during reflection of a Get result that ultimately create two problems:
Concurrent modification of a map, or concurrent iteration and modification of a map. We do not perform any locking on this data, and, given that the result should be read-only at this point, there should not need to be.
The above alludes to the fact that the current result reflection is actually modifying the result value in-place when it comes to maps and slices. This method is assuming that the data in the result is actually a copy of any underlying import data, which is actually not the case - in addition to the nuances of Go map and slice internals, the return data could contain direct pointers to namespaces or other internal structures that would not be expecting to be altered by a process working on the result of a call.
This updates the internal reflectMap and reflectSlice methods to ensure that results of data transformation are being written to new maps and slices, instead of the existing ones. This corrects both issues - map writes are no longer happening concurrently to the same map, and original values are not being modified.