Skip to content

Fixed debugger crash when trying to represent angles in tables in E2 - #2078

Merged
thegrb93 merged 5 commits into
wiremod:masterfrom
Alexandre425:debugger_angle_fix
Aug 18, 2020
Merged

Fixed debugger crash when trying to represent angles in tables in E2#2078
thegrb93 merged 5 commits into
wiremod:masterfrom
Alexandre425:debugger_angle_fix

Conversation

@Alexandre425

@Alexandre425 Alexandre425 commented Aug 12, 2020

Copy link
Copy Markdown
Contributor

If an angle is put into a table and the E2 chip is debugged, the debugger crashes with the following error:

[wire] entities/gmod_wire_expression2/core/table.lua:93: bad argument #2 to '?' (number expected, got nil)
  1. unknown - [C]:-1
   2. temp - entities/gmod_wire_expression2/core/table.lua:84
    3. unknown - entities/gmod_wire_expression2/core/table.lua:117
     4. updateForPlayer - addons/wire/lua/weapons/gmod_tool/stools/wire_debugger.lua:299
      5. unknown - addons/wire/lua/weapons/gmod_tool/stools/wire_debugger.lua:329

Timer Failed! [Wire_DebuggerThink][@addons/wire/lua/weapons/gmod_tool/stools/wire_debugger.lua (line 333)]

This can be easily confirmed with the following E2:

@name test
@outputs T:table
if (first() | dupefinished())
{
    T = table()
    T["a", angle] = ang()
}

In lua/wire/server/debuggerlib.lua, the angle's values are accessed by .p .y .r. They're not assigned as such, as in lua/entities/gmod_wire_expression2/core/angle.lua the function ang places the pitch yaw and roll in the table's numerical indices (1, 2 and 3).

Angles and vectors are formatted in the same way, so some redundant angle checks were removed, and formatPort.VECTOR is used for both angles and vectors when formatting the values in tables and arrays

@Alexandre425

Copy link
Copy Markdown
Contributor Author

Travis Cl raises the following error:
lua/wire/server/debuggerlib.lua:78:67: expected ')' near '!'
in the following line:
elseif(type(Element) == "PhysObj" and e2_tostring_bone(Element) != "(null)") then --Bone
Naturally != isn't valid in vanilla lua, but it is in Glua

@thegrb93

Copy link
Copy Markdown
Contributor

Ya, I think it's part of the code convention to not use glua syntax

@Alexandre425

Alexandre425 commented Aug 12, 2020

Copy link
Copy Markdown
Contributor Author

Ya, I think it's part of the code convention to not use glua syntax

Roger that, the error was in old code I didn't touch however

@bigdogmat

bigdogmat commented Aug 12, 2020

Copy link
Copy Markdown
Member

That's weird that it errors because the isangle check should've only went through for actual angle objects. Can you run isangle({1,2,3}) and see if it prints true or false.

Edit: Actually where in the stack trace does it point to the code you changed?

@Alexandre425

Alexandre425 commented Aug 12, 2020

Copy link
Copy Markdown
Contributor Author

That's weird that it errors because the isangle check should've only went through for actual angle objects. Can you run isangle({1,2,3}) and see if it prints true or false.

It prints false.

Edit: Actually where in the stack trace does it point to the code you changed?

table.lua 84 is this line:
ret = ret .. formatPort[longtype]( v, orientvertical )
This calls the function I changed.

@bigdogmat

Copy link
Copy Markdown
Member

Ah I see it now, my branches line numbers didn't match your trace.

@thegrb93

Copy link
Copy Markdown
Contributor

The debugger tool doesn't have any errors when I look at angles in tables.

@thegrb93

thegrb93 commented Aug 17, 2020

Copy link
Copy Markdown
Contributor

Tested with

@outputs A:array

A = array(ang(24,24,24))

@thegrb93

Copy link
Copy Markdown
Contributor

Nvm got it to happen with

@outputs A:table

A = table()
A["Test",angle] = ang(24,24,24)

@thegrb93

Copy link
Copy Markdown
Contributor

Can you remove the other changes except for line 16?

@thegrb93 thegrb93 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

@Alexandre425

Copy link
Copy Markdown
Contributor Author

Can you remove the other changes except for line 16?

Changed as requested

@thegrb93

Copy link
Copy Markdown
Contributor

Ok. I'll test it in a few hours.

@thegrb93
thegrb93 merged commit 8318ab4 into wiremod:master Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants