Closed kwon-young closed 9 months ago
Thanks for reporting (I don't use the graphical debugger much).
The problem arises because the graphical debugger runs in a separate (pce) thread which is started before clpBNR is initialized. As a result, the required global variable to support the attribute_goals
hook isn't available to support displaying the constrained variable in the graphical debugger window. (This global was introduced in clpBNR 0.11.2 to fix some deficiencies in the top level display with nested constraint values.)
The fix is fairly simple (1 line) but there's no obvious workaround, e.g., "manually" defining the global in the pce thread. Since I just released 0.11.2, I'd prefer not to go through the overhead of a new release just for this bugfix. So short term options for you to consider:
I can provide patch instructions for 0.11.2 so you can fix your copy. Since you do use the graphical debugger, this would would help me with additional testing of that component with clpBNR.
If you can provide me the patch instructions, I can follow them and test them for you.
Sure. If you look at the code structure here on GitHub, you'll find the file prolog/clpBNR/ia_utilities.pl
. The predicate to fix is attribute_hooks
at line 79 which currently reads:
attribute_goals(X) --> % constructs goals to build X
{current_prolog_flag(clpBNR_verbose,Verbose), % details depend on flag clpBNR_verbose
g_read('clpBNR:bindings',Bindings),
domain_goals_(Verbose,Bindings,X,Goals)
},
Goals.
The call to g-read
which reads the global var clpBNR:bindings
should be replaced with:
catch(g_read('clpBNR:bindings',Bindings),error(existence_error(variable, _), _Ctxt),Bindings=any),
You'll have to find where on your installation the clpBNR pack has been installed; FYI, use ?- file_search_path(library,Y).
if you can't find it.
The clpBNR version number is at file prolog/clpBNR.pl
, line 105 if you want to modify that to minimize any future confusion with the version you're using.
Thanks for your assistance.
I have applied your patch and everything seems to work now :) As always, thank you very much for your quick help!
Good news; thanks again for reporting this.
Fixed in 0.11.3.
I am using swi-prolog 9.1.18 built from source with clpBNR 0.11.2 and have found a bug in the swi graphical debugger when attributed variables from clpBNR are shown. The bug is triggered when trying to change the program current frame by clicking on
select parent frame
orselect child frame
or double clicking on a variable. When trying to change the frame, the debugger will simply fail and when trying to portray a variable, the new window will be empty.Here is a minimal reproducer:
After the graphical debugger has launched, trace the program to go down 1 frame while having a clpBNR attributed variable shown and then try to go back up a frame. You should see the exception appear.