Immediate-Mode-UI / Immediate-Mode-UI/Nuklear

Crash: tooltips cause an infinite loop

Open
#660 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
11.4k
Forks
686
Avg merge
4d 1h
Merged PRs (30d)
3

Description

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:
- Have some widgets that show tooltips when hovered over.
- Don't call nk_convert every single frame (as per the documentation's recommendation, I am only drawing frames where something changes, so I'm not calling nk_convert every frame).
- Move your mouse between two widgets that show a tooltip on hover. In my program, the easiest way to trigger the crash is to switch between the Project and Chain pages in the bottom left.

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](https://github.com/user-attachments/files/16164671/MinDAWBroken.zip)

Contributor guide

Open the contributing guide

Research direction

Start by building and running the attached MinDAWBroken.zip program, then reproduce the freeze by moving the mouse between the Project and Chain pages or other tooltip widgets without calling nk_convert every frame. Trace nk_convert and nk_foreach when the loop begins, using the reporter's patched nk_convert as a comparison. Done means tooltip transitions no longer cause an infinite loop, CPU spike, or growing memory use.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.