Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mudlet freeze calling display() on adjustable container #4607

Closed
Kebap opened this issue Jan 10, 2021 · 13 comments · Fixed by #4773
Closed

Mudlet freeze calling display() on adjustable container #4607

Kebap opened this issue Jan 10, 2021 · 13 comments · Fixed by #4773
Labels
bug high Lua only Issues with this label can be fixed by solely modifying lua code

Comments

@Kebap
Copy link
Contributor

Kebap commented Jan 10, 2021

Brief summary of issue

Mudlet freezes a few seconds after typing the wrong command

Steps to reproduce the issue

Discord user chad explains:

  1. so if i make an adjustable container, called testContainer
    testContainer = Adjustable.Container:new({name = "ARS main window"})
  2. and I do lua testContainer in my cmd prompt
  3. it freezes mudlet and then gives me a memory error

Error output

[ERROR:] Objekt:<run lua code> Funktion:<Alias4>
        <not enough memory>

Extra information, such as Mudlet version, operating system and ideas for how to solve / implement:

that's not just on my shit laptop, or just 1 profile.
that's on my laptop and PC (16gb ram)
on new profiles, old profiles
Mudlet 4.10.1

@Kebap Kebap added the bug label Jan 10, 2021
@SlySven
Copy link
Member

SlySven commented Jan 11, 2021

That behaviour sound consistent with an infinite recursion happening in the Lua code somehow...

@vadi2 vadi2 changed the title Mudlet freeze upon reviewing adjustable Mudlet freeze calling display() on adjustable container Jan 11, 2021
@vadi2 vadi2 added the high label Jan 11, 2021
@vadi2
Copy link
Member

vadi2 commented Jan 11, 2021

Labelling as high because it's poor behaviour, we expect Mudlet to do better here.

@SlySven
Copy link
Member

SlySven commented Jan 11, 2021

Would it be fair to mark this as likely to be a lua only issue?

@vadi2 vadi2 added the Lua only Issues with this label can be fixed by solely modifying lua code label Jan 11, 2021
@Edru2
Copy link
Member

Edru2 commented Jan 11, 2021

That behaviour sound consistent with an infinite recursion happening in the Lua code somehow...

Yes that is the reason. As Geyser always keeps a reference of the parent in container (myGeyserElement.container).
This is a known issue with display and is also the reason that the creator of Geyser made the Geyser.display function (11 years ago 👀 ).

function Geyser.display (table)

So instead of using display a workaround would be to use Geyser.display.

@vadi2
Copy link
Member

vadi2 commented Jan 11, 2021

Can we identify a Geyser object if one is given? Could make display() call that function in that case automatically.

@Kebap
Copy link
Contributor Author

Kebap commented Jan 14, 2021

Maybe we can help display to never run into these infinite loops again?
For example, keep a list of all tables displayed already, and not display a full second version of one again.

@Edru2
Copy link
Member

Edru2 commented Feb 5, 2021

After diggin a bit I found out that prettywrite has a failsafe against infinite loops in it but it fails for Geyser in some instances (I'm not sure why)
for example:

test = {}
test[1] = test
display(test)

Won't cause an infinite loop.

I tried to comment out

and that seems to work but I'm not sure if that could cause other issues and why it was there in the first place.

@vadi2
Copy link
Member

vadi2 commented Feb 6, 2021

This is the reason: lunarmodules/Penlight#38

@vadi2
Copy link
Member

vadi2 commented Feb 6, 2021

Unrelated, it looks like there's an improvement for consistent key order we could take advantage of: lunarmodules/Penlight#293

@Edru2
Copy link
Member

Edru2 commented Feb 9, 2021

After digging further I noticed that the issue mainly occurs if nested Labels are used (Adjustable Container right click menu uses a nested Label)
I personally still think that commenting

out is a viable solution to the issue.

I tested https://github.com/kikito/inspect.lua which does more or less the same as prettywrite and they solve this issue the same way (as of it would be if the tables[t] part was commented out) but with the difference that every duplicated table gets an id instead of a generic <cycle>

I also found a similar issue using the second nestable labels example from the Geyser Wiki (the one with 'mainlabel') https://wiki.mudlet.org/index.php?title=Manual:Geyser#Demo -> hover over the 'Hover there part' and then use lua display(Geyser) still causes an stackoverflow error (not occurring if using inspect)

Maybe switching from prettywrite to inspect is something to think about.

@vadi2
Copy link
Member

vadi2 commented Feb 9, 2021

We don't have a particular reason to stick to one - if the other is better, let's go for it. How do the two compare, could you post before/afters?

@demonnic
Copy link
Member

demonnic commented Feb 9, 2021

regarding consistent key order, could just change the use of pairs to spairs and it should handle all that. That's essentially all that code snippet linked does, we've just abstracted it for use anywhere as spairs.

@Edru2
Copy link
Member

Edru2 commented Feb 11, 2021

We don't have a particular reason to stick to one - if the other is better, let's go for it. How do the two compare, could you post before/afters?

It is pretty much doing the same but I don't know if it is 'better' at least it doesn't crash in Geyser (which makes it better in my opinion) ;)
I'll open a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug high Lua only Issues with this label can be fixed by solely modifying lua code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants