AshitaXI / Ashita

Issue tracker and wiki for the Ashita project.
https://ashitaxi.com/
6 stars 1 forks source link

addons threw an exception in event Present #7

Closed Sippius closed 2 years ago

Sippius commented 2 years ago

Ashita Version (Type /ashita in-game to get this.) v4.0.0.2

FFXI Version (Type /version in-game to get this.) 30211005_0 (note that /version did not work in-game, but /ver did)

Windows Version (ie. Start > About Your PC) Windows 10 Pro 21H1

Describe The Bug Please give a clear, full description of the bug.

addons plugin crashing. I have managed to get it to happen relatively consistently with just equipmon loaded. I have had similar issues before equipmon was available so there may be other addons that cause the issue. I have not tried to isolate other addons.

Steps To Reproduce Please give a clear, full list of steps to reproduce the bug, if applicable.

the picture provided was produced by logging in without equipmon loaded (have experienced crash on login with equipmon in default.txt along with other addons), unloading all addons (/addon unloadall), loading equipmon, exiting moghouse, then entering moghouse.. crash occurred when entering moghouse.

Screenshots If applicable, add screenshots to help explain your problem.

image

Additional Information Please include any additional information you feel could help explain the bug/problem and get it resolved

The crash seems to occur most often when zoning, but it has also happened when accessing the auction house. I don't have any details other than I was at the AH when it happened.

atom0s commented 2 years ago

Thanks for the report. :)

I am able to reproduce this and was able to have it happen while developing equipmon. However, I couldn't reproduce it reliably and figured I'd push for testing and see if others could get it to trigger.

It does appear that going in and out of a mog house is triggering it more. The underlying cause is due to, what I believe to be, a bug in sol2. (The Lua binding library being used with Addons.) Ashita v4's addon system is designed with coroutines being a forefront system, and for some reason, sol is losing reference to a coroutines thread state after its been executed properly. The issue is currently happening due to the tasks being queued to refresh the equipment textures:

--[[
* event: packet_out
* desc : Event called when the addon is processing outgoing packets.
--]]
ashita.events.register('packet_out', 'packet_out_cb', function (e)
    -- Update the equipment textures on item related packet updates..
    if (T{ 0x001A, 0x0050, 0x0051, 0x0052, 0x0053, 0x0061, 0x0102, 0x0111 }:hasval(e.id)) then
        ashita.tasks.oncef(1, update_equipment_textures);
        return;
    end
end);

When the internal task wrapper object has completed and is cleaning up, is when sol is losing the reference and dying at random.

I am working on figuring out what specifically may be causing this and trying to work out a workaround.

atom0s commented 2 years ago

I have had similar issues before equipmon was available so there may be other addons that cause the issue. I have not tried to isolate other addons.

If you do have the time to, can you possibly see what other addons you have had this issue pop up with. It may help isolate what may be an underlying problem that is helping cause this.

atom0s commented 2 years ago

Ok I just pushed an update for Addons which should fix this bug/crash. And should effectively fix it for any other addon that may have had the same crash. Issue was with sol2, but was a mistake on my end with how I was spawning new coroutines.

The state being used was not the correct one and was instead inheriting the state from the previous coroutine that invoked the creation of a new one. This led to a race condition where a previous coroutine could end and destroy its state/Lua thread and then cause the child coroutine to have a corrupt state.

Should be fixed and fine, tested for a few mins zoning a bunch and can't get it to crash anymore. Along with a test addon to mimic the problem hasn't crashed either. Will leave this open for a little bit for you to confirm and test and to report any other addons that may be crashing in the same manner.

atom0s commented 2 years ago

Dev tagging; referenced commit that fixes this: https://github.com/AshitaXI/Addons-src/commit/ff646c566c214b6822c7ae1d2868b6688a7f9997

atom0s commented 2 years ago

Going to mark this as closed now, I cannot recreate this issue any longer after the fix I pushed a while back now.