Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008115opensim[REGION] Scripting Enginepublic2017-01-05 09:372017-05-27 14:50
ReporterLiam Taylor 
Assigned ToUbitUmarov 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version0.9.0 
Target VersionFixed in Version 
Summary0008115: mixture of bitwise operators and logical expression leads to wrong result
Descriptionterms are evaluated wrongly when bitwise operators are mixed with logical expressions
Steps To Reproducedefault {
    state_entry() {
        integer x = 0;
        integer y = (2 | (x > 0)); // expectation: y == 2
        llOwnerSay("y == " + (string)y); // OpenSimulator result: y == 1
    }
}
Additional Informationobserved in Dreamnation grid
TagsNo tags attached.
Git Revision or version number0.9.1
Run Mode Grid (1 Region per Sim)
Physics EngineODE
EnvironmentMono / Linux64
Mono VersionNone
ViewerFS linux_x64 5.0.1.52150
Attached Files

- Relationships

-  Notes
(0031533)
UbitUmarov (administrator)
2017-01-05 10:44

hi on master 0.91:
default
{
    state_entry()
    {
        llSay(0, "Script running");
        integer x = 1;
         integer y = (2 | (x > 0)); // expectation: y == 2
         llOwnerSay("y == " + (string)y); // OpenSimulator result: y == 1
    }
}
[10:43] Object: Script running
[10:41] Object: y == 3

changing to integer x = 0;
[10:43] Object: Script running
[10:43] Object: y == 2
 as expected
(0031534)
UbitUmarov (administrator)
2017-01-05 10:48

previus test was on windows.
But got the same on osgrid sandbox plaza III on Linux.
(0031536)
Liam Taylor (reporter)
2017-01-05 16:17

Thanks for checking so quickly. Maybe we are on a different version number, I shall confirm with our admins. Something must be different since the faulty result is reproducible on our grid.
(0031537)
UbitUmarov (administrator)
2017-01-05 16:27

Please don't forget to start the region with DeleteScriptsOnStartup = true in opensim.ini the first time after version change. It should be false on next restarts.
You can instead delete the contents of folder of bin/ScriptEngines. This may actually be need on a major version change. But doing this you do loose the scripts state. This can break some SL like commercial products, that depend on that state, something not recommended on opensim.
(0031659)
Ferd Frederix (reporter)
2017-03-29 17:22
edited on: 2017-04-08 23:29

This is expected behavior and not a bug.

You must be thinking that '|' is a logical OR. But a single | is a bitwise OR in LSL, so the LSL above is producing the expected output.

In the first example, where x = 1, the expansion is
2 | 1 = 3, which is correct.

In the second, x = 0
2 | 0 = 2 which is correct


If you change the symbol from '|' to '||' (a LOGICAL OR), the results are as follows:

In the first example, where x = 1, the expansion is
2 || 1 = 1, as Opensim parses the right side first and it to be true. SL does this L-R, and Opensim R-L by design. 1 is the correct answer for Opensim, 2 for SL.

In the second, x = 0
2 || 0 = 2 which is correct, as 0 is false, so it evaluates the 2.


- Issue History
Date Modified Username Field Change
2017-01-05 09:37 Liam Taylor New Issue
2017-01-05 10:44 UbitUmarov Note Added: 0031533
2017-01-05 10:48 UbitUmarov Note Added: 0031534
2017-01-05 16:17 Liam Taylor Note Added: 0031536
2017-01-05 16:27 UbitUmarov Note Added: 0031537
2017-03-29 17:22 Ferd Frederix Note Added: 0031659
2017-04-08 23:19 Ferd Frederix Note Edited: 0031659 View Revisions
2017-04-08 23:29 Ferd Frederix Note Edited: 0031659 View Revisions
2017-05-27 14:50 UbitUmarov Status new => resolved
2017-05-27 14:50 UbitUmarov Resolution open => fixed
2017-05-27 14:50 UbitUmarov Assigned To => UbitUmarov


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker