Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
Other
9.06k stars 542 forks source link

Crash: tooltips cause an infinite loop #660

Open Adamskye opened 1 month ago

Adamskye commented 1 month ago

I have attached a copy of a program I am working on in its very early stages which suffers from this issue.

In the experimentation I've done with the program I've attached, the requirements for this crash to occur are as follows:

The crash occurs in nk_convert and seems to be because nk_foreach enters an infinite loop. This causes the program to freeze, CPU usage to spike to 100% and memory usage to slowly climb.

In my program, I have patched nk_convert so that it detects when an infinite loop is starting, prints a message, then breaks from nk_foreach. While this ideally shouldn't be needed, it is better than redrawing every frame or abandoning the use of tooltips entirely.

I've noticed that somebody else has had this issue several years ago (#168) although my problem is due to tooltips and the cause of the infinite loop seems different to how he described ('next' is not set to 0). I also can provide a program that has the issue so it should hopefully be easier to diagnose.

MinDAWBroken.zip

Adamskye commented 1 month ago

There's another thing I forgot to add. I don't know if this is relevant or not, but whenever I am moving my mouse between widgets that open tooltips, the command buffer is resizing itself a lot. Perhaps it's being corrupted in the process of being resized? I'll test with nk_init_fixed and see what happens.

RobLoach commented 1 month ago

I believe there can only be one tooltip shown at a time, since they use the same popup identifier. Is there a way you could put some guardrails in place?