|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0000239||mercury||Bug||public||2011-11-30 08:44||2011-12-05 14:18|
|Target Version||Fixed in Version|
|Summary||0000239: Aliasing of partially instantiated structures in solutions.* predicates|
|Description||If a partially instantiated structure is fully instantiated and output from the generator predicate of one of the solutions.* predicates, then each result generated will point at the same physical structure (see attached example).|
This is because multi/nondet predicates do not deep copy partially instantiated structures when filling them in, and solutions.builtin_aggregate does not deep copy while generating results (except in the case of accurate garbage collection).
Since changing the former would result in pervasive ABI changes, I believe that changing solutions.builtin_aggregate to always copy generated results is the correct solution (albeit at a performance hit).
|Tags||No tags attached.|
Attached is a proof-of-concept patch against a 11.07 beta (not CVS, sorry) which fixes the bug in asm_fast.gc, hlc.gc, and java. I believe it also fixes the bug in C# grades, but I cannot test this. I am not sure that the bug exists in Erlang grades.
The attached patch is suboptimal in that it will unnecessarily copy the aggregation result as well. I suppose the changes in the patch should instead create a new predicate similar to partial_deep_copy, but perhaps there is a cleaner method.
The "bug" here is just that the current implementation does not support partially instantiated data structures, so if you want to use them you should expect to need some workarounds. I don't want to pay the cost of unnecessary copying to partly support a feature that won't be fully supported anyway.
In this case a workaround is to perform the necessary copying yourself in the closure that is passed to solutions.*.
|2011-11-30 08:44||colanderman||New Issue|
|2011-11-30 08:44||colanderman||File Added: agg_bug.m|
|2011-11-30 08:45||colanderman||File Added: solutions_copy.patch|
|2011-11-30 08:49||colanderman||Note Added: 0000419|
|2011-12-05 14:18||mark||Note Added: 0000431|