Hello,
The following commands makes CLIPS to crash.
$ ./clips -f globalbind.bat
CLIPS (6.4.2 5/7/24)
CLIPS> (defglobal ?foo = (create$ 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0))
CLIPS> (defglobal ?bar = (create$ 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0))
CLIPS>
(deffunction test (?foo ?bar)
(loop-for-count 10 do
(bind ?foo ?foo)
(bind ?bar ?bar)
)
(printout t "FOO " ?foo crlf)
(printout t "BAR " ?bar crlf)
)
CLIPS>
(test ?foo ?bar)
[PRNTUTIL3]
*** CLIPS SYSTEM ERROR ***
ID = EVALUATN7
CLIPS data structures are in an inconsistent or corrupted state.
This error may have occurred from errors in user defined code.
The patch attached seems to fix this problem.
Thanks.
The posted comment is erroneous because the asterisks are missing.
Please refer the attached file.
The revised patch is attached because the elder patch fails CLIPS test_suite.
A fix has been checked into the svn repository. The issue occurs when setting the current value of a defglobal to its current value. This can cause the value to be prematurely released. The bug can occur outside the body of a deffunction, so the proposed patch won't fix the issue for all cases.
Thanks Gary,
but I think an additional modification is necessary(see attached patch)
because the following program results an endless looping.
Nice catch. I checked in an update.
Thanks Gary,
The endless looping is resolved. But the globalbind.bat fails again.
I think the equality checking once you have added is still necessary
(but after NormalizeMultifield(), but before displaying watch info)
to avoid premature release.
I checked in a fix. I forgot to test the original issue. There are multiple ways to generate a bug with this issue and just modifying QSetDefglobalValue won't fix all of them. Here's an example which globalbind-3.patch will still generate an error:
What I did to resolve the issue is modify the routines which return the value of the global variable to return a copy of the multifield value instead of the value stored directly in the global. This preserves the multifield until garbage collection kicks in at the appropriate time.
It all works fine. Thanks.