secondlife / jira-archive

2 stars 0 forks source link

[BUG-234276] System.NullReferenceException when using some List / List-returning functions #11233

Open sl-service-account opened 1 year ago

sl-service-account commented 1 year ago

What just happened?

Created a UDF in my script and when called it crashed with a System.NullReferenceException run-time error. Weirdly, in trying to isolate where in the UDF it was failing, any debugging llOwnerSay's caused the UDF to correctly function. Commenting the debugging statements back out and the run-time errors returned.

I've attached an extremely cut down version of my code that still reproduces the problem without having to traverse a linkset. Using that cut-down script on my Homestead (running "Second Life Server 2023-07-31.581251") I get the following run-time error:

[19:04:28] Object: Object [script:New Script] Script run-time error System.NullReferenceException: Object reference not set to an instance of an object at ....edefaultstate_entry () [0x00000] in :0 at ...edefaultstate_entryFrame.ResumeVoid () [0x00000] in :0 at LindenLab.SecondLife.UThread.UThread.Run () [0x00000] in :0 at LindenLab.SecondLife.Script.Run (ScriptEvent evt) [0x00000] in :0

Taking and re-rezzing the object with my cut-down script gives the following error:

[19:06:01] Object: Object [script:New Script] Script run-time error System.NullReferenceException: Object reference not set to an instance of an object at ....edefaultstate_entry () [0x00000] in :0 at LindenLab.SecondLife.UserScript.OnStateEntry () [0x00000] in :0 at LindenLab.SecondLife.Script.UserEvent (ScriptEvent e) [0x00000] in :0 at LindenLab.SecondLife.Script.Run (ScriptEvent evt) [0x00000] in :0

Rezzing the object on my Mainland parcel (running "Second Life RC BlueSteel 2023-08-02.581292") also fails (so doesn't appear to be a Homestead issue):

[19:08:14] Object: Object [script:New Script] Script run-time error System.NullReferenceException: Object reference not set to an instance of an object at LSL .state_entry () at LSL state_entryFrame.ResumeVoid () at UThread.Run () at Script.Run (ScriptEvent evt)

What were you doing when it happened?

Developing a script. The UDF that failed traverses the linkset looking for particular named objects & descriptions in order to return a specially ordered list of link numbers

What were you expecting to happen instead?

For the UDF to return the list and not crash with a run-time error.

Other information

Whilst my object is a linkset, the attached repro script can just be put into a single prim. Whilst my original script relied on the description field, it doesn't matter for the repro script (but if you like, just set the description to a number)

If you uncomment the commented out "llOwnerSay" in the repro script, you'll find no run-time error occurs.

Attachments

Original Jira Fields | Field | Value | | ------------- | ------------- | | Issue | BUG-234276 | | Summary | System.NullReferenceException when using some List / List-returning functions | | Type | Bug | | Priority | Unset | | Status | Accepted | | Resolution | Triaged | | Created at | 2023-08-18T03:36:23Z | | Updated at | 2023-08-23T15:02:46Z | ``` { 'Build Id': 'unset', 'Business Unit': ['Platform'], 'Date of First Response': '2023-08-18T14:45:30.665-0500', "Is there anything you'd like to add?": "Whilst my object is a linkset, the attached repro script fails if just put into a single prim. Whilst my original script relied on the description field, it doesn't matter for the repro script (but if you like, just set the description to a number)", 'ReOpened Count': 0.0, 'Severity': 'Unset', 'System': 'SL Simulator', 'Target Viewer Version': 'viewer-development', 'What just happened?': 'Created a UDF in my script and when called it crashed with a System.NullReferenceException run-time error. Weirdly, in trying to isolate where in the UDF it was failing, any debugging llOwnerSay\'s caused the UDF to correctly function. Commenting the debugging statements back out and the run-time errors returned.\r\n\r\nI\'ve attached an extremely cut down version of my code that still reproduces the problem. Using that cut-down script on my Homestead (running "Second Life Server 2023-07-31.581251") I get the following run-time error:\r\n\r\n[19:04:28] Object: Object [script:New Script] Script run-time error\r\nSystem.NullReferenceException: Object reference not set to an instance of an object\r\n at ....edefaultstate_entry () [0x00000] in :0 \r\n at ...edefaultstate_entryFrame.ResumeVoid () [0x00000] in :0 \r\n at LindenLab.SecondLife.UThread.UThread.Run () [0x00000] in :0 \r\n at LindenLab.SecondLife.Script.Run (ScriptEvent evt) [0x00000] in :0 \r\n\r\nTaking and re-rezzing the object with my cut-down script gives the following error:\r\n\r\n[19:06:01] Object: Object [script:New Script] Script run-time error\r\nSystem.NullReferenceException: Object reference not set to an instance of an object\r\n at ....edefaultstate_entry () [0x00000] in :0 \r\n at LindenLab.SecondLife.UserScript.OnStateEntry () [0x00000] in :0 \r\n at LindenLab.SecondLife.Script.UserEvent (ScriptEvent e) [0x00000] in :0 \r\n at LindenLab.SecondLife.Script.Run (ScriptEvent evt) [0x00000] in :0 \r\n\r\nRezzing the object on my Mainland parcel (running "Second Life RC BlueSteel 2023-08-02.581292") also fails (so doesn\'t appear to be a Homestead issue):\r\n\r\n[19:08:14] Object: Object [script:New Script] Script run-time error\r\nSystem.NullReferenceException: Object reference not set to an instance of an object\r\n at LSL .state_entry () \r\n at LSL state_entryFrame.ResumeVoid () \r\n at UThread.Run () \r\n at Script.Run (ScriptEvent evt) \r\n ', 'What were you doing when it happened?': 'Developing a script. The UDF that failed treverses the linkset looking for particular named objects & descriptions in order to return a specially ordered list of link numbers', 'What were you expecting to happen instead?': 'For the UDF to return the list and not crash with a run-time error.', 'Where': 'http://maps.secondlife.com/secondlife/Elf/129/128/1002\r\nhttp://maps.secondlife.com/secondlife/Reverie/78/136/64', } ```
sl-service-account commented 1 year ago

Maestro Linden commented at 2023-08-18T19:45:31Z, updated at 2023-08-18T19:45:56Z

This is an interesting case - different from the known BUG-11377 case that generates System.NullReferenceException. I can reproduce the issue.

If I add a llOwnerSay("still alive"); line prior to the one with the llList2ListSlice() call, the "still alive" chat appears properly - it seems that the script hits the exception on the llList2ListSlice() line.

When I change my debug message to llOwnerSay("global:"+llList2CSV(global)); , the output is this, with no script error:

global:1, 0 global:1 The output in the first line, with global = [1, 0], matches my expectations. Frustratingly (like your other debug attempt with list local), adding the llOwnerSay() line causes the exception to disappear.

Likewise, this version of the script, with global set directly to the result from the earlier functions, completes successfully with output "global:1":

list global;

default
{
    state_entry()
    {
        global = [1,0];
        global = llList2ListSlice(llListSortStrided(global, 2, 1, TRUE), 0, -1, 2, 0);
        llOwnerSay("global:"+llList2CSV(global));
    }
}

Somehow the list gets in a strange transitory state in which reading it prior to the llList2ListSlice() line via llList2CSV() resolves.

sl-service-account commented 1 year ago

Lucia Nightfire commented at 2023-08-19T01:42:34Z

Related to https://jira.secondlife.com/browse/BUG-233548 ?

sl-service-account commented 1 year ago

loganpryor commented at 2023-08-19T22:13:48Z

I tried the code in BUG-233548 and that works fine for me on "Second Life Server 2023-07-31.581251" – maybe that bug is fixed?

sl-service-account commented 1 year ago

loganpryor commented at 2023-08-19T22:50:08Z, updated at 2023-08-19T22:54:35Z

Seem to be 2 workarounds:

sl-service-account commented 1 year ago

loganpryor commented at 2023-08-21T18:01:07Z

Having made further changes to my script, even the llList2CSV doesn't fix the problem any more. Seems only unstacking works