Baggins

Baggins

1M Downloads

Exception during quality sort when looting a quest item with bags open

glajchs opened this issue ยท 7 comments

commented

Sometimes I get an exception when my bags are open, and it took a few days to realize that it's happening when:

  1. I'm looting
  2. I receive a new stack of a quest item.

I tried putting a print statement at 1417 to see what the "sorttype" is. During normal operation (bag opening) it prints about 30 of "quality" types. When I get the error upon looting, it prints 3 "quality" types then throws the stack trace.

Below is the full trace.

Message: Interface\AddOns\Baggins\Baggins.lua:1417: invalid order function for sorting
Time: Sun Jul 11 14:03:02 2021
Count: 4
Stack: Interface\AddOns\Baggins\Baggins.lua:1417: invalid order function for sorting
[string "=[C]"]: ?
[string "=[C]"]: ?
[string "@interface\AddOns\Baggins\Baggins.lua"]:1417: in function SortItemList' [string "@Interface\AddOns\Baggins\Baggins.lua"]:1210: in function UpdateSectionContents'
[string "@interface\AddOns\Baggins\Baggins.lua"]:1126: in function UpdateSection' [string "@Interface\AddOns\Baggins\Baggins.lua"]:1101: in function ReallyUpdateBags'
[string "@interface\AddOns\Baggins\Baggins.lua"]:746: in function `?'
[string "@interface\AddOns\Baggins\Baggins.lua"]:161: in function <Interface\AddOns\Baggins\Baggins.lua:153>

Locals:

commented

I have a similar error, but in my case the sorttype is ilvl. Going through the codepath, I don't think that it happens because the sort function returns a non-boolean, but that for some values, it returns true for both (a, b) and (b, a). Any idea how to debug that?

Also, this only happens when "new items first" is enabled.

commented

Got a similar Error in Baggins WOTLK. this is what Bugsack caught.

12x Interface\AddOns\Baggins\Baggins-v4.6.1.lua:1453: invalid order function for sorting
[string "=[C]"]: ?
[string "@interface\AddOns\Baggins\Baggins-v4.6.1.lua"]:1453: in function SortItemList' [string "@Interface\AddOns\Baggins\Baggins-v4.6.1.lua"]:1210: in function UpdateSectionContents'
[string "@interface\AddOns\Baggins\Baggins-v4.6.1.lua"]:1131: in function UpdateSection' [string "@Interface\AddOns\Baggins\Baggins-v4.6.1.lua"]:1106: in function ReallyUpdateBags'
[string "@interface\AddOns\Baggins\Baggins-v4.6.1.lua"]:751: in function `?'
[string "@interface\AddOns\Baggins\Baggins-v4.6.1.lua"]:171: in function <Interface\AddOns\Baggins\Baggins.lua:163>

Locals:
(*temporary) =

{
1 =
{
}
2 =
{
}
3 =
{
}
4 =
{
}
5 =
{
}
6 =
{
}
7 =
{
}
8 =
{
}
9 =
{
}
10 =
{
}
11 =
{
}
}
(*temporary) = defined @interface\AddOns\Baggins\Baggins.lua:1324
(*temporary) =
{
slotcount = 1
slots =
{
}
itemid = 11018
}
(*temporary) =
{
slotcount = 1
slots =
{
}
itemid = 17009
}
(*temporary) = nil

commented

Honestly I know it is an issue with the compare functions failing for a certain comparison but I don't know how to fix it.

commented

If you want to prepare a debug version of Baggins that logs the sort type, config settings and results of the sort function during the (last failing) tsort call, I'd be willing to see if I can reproduce the error and send you the logs. ๐Ÿ™‚

commented

As far as I can tell the flow of code is something like this:
Baggins:SortItemList(itemlist, sorttype) > QualityComp(a, b) > getCompInfo(link) > GetItemInfo
In the end we use the third parameter of GetItemInfo which is:
itemQuality
number : Enum.ItemQuality - The quality of the item, e.g. 2 for Uncommon and 3 for Rare quality items.
this gives us a number to compair against in QualityComp which provides the true/false for the table.sort function

order function(QualityComp) receives two arguments and must return true if the first argument should come first in the sorted array

where link is GetInventoryItemLink for the item maybe running:
select(3, GetItemInfo(link)) might give us some info? maybe the item quality parameter is not returning a value?

or

A check here if quala or qualb exists or not and print its value, might need a if not quala/qualb then return false.

Not sure how much coding you know or how much you are willing to test but I had to write it out so I can keep track and thats where I am at so far.

Basically the error is in QualityComp somewhere.

commented

If it only happens with multiple stacks of quest items we might be looking at an error here. The code seems to already have checks in place to avoid issues but maybe we are having an issue with one of the variables linka,linkb,baga,slota,bagb,slotb .

commented

I don't know lua super well specifically, but I code professionally so I'm not flying completely blind. I'm in kara now but hopefully I can get some time to try a few things in that area of the code later tonight.