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

ImFont::RenderText() issue #6132

Closed
tksuoran opened this issue Jan 31, 2023 · 7 comments
Closed

ImFont::RenderText() issue #6132

tksuoran opened this issue Jan 31, 2023 · 7 comments

Comments

@tksuoran
Copy link

Version/Branch of Dear ImGui:

Version: 1.89.3
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: custom / erhe
Compiler: VS 2022 17.4.4
Operating System: Windows 10

My Issue/Question:

I encountered IM_ASSERT_PARANOID() failure in ImDrawList::PrimReserve() due to negative arguments being passed from ImFont::RenderText(). This was caused by s pointing to one past text_end. text_begin pointed to Material and text_end looked valid. I am not sure exactly what path resulted in s pointing to text_end + 1. I have not been able to repro, so this may be some corner case that is not easy to hit.

@ocornut
Copy link
Owner

ocornut commented Jan 31, 2023

Intuitively I imagine ccf94e2 could be at fault because it is a very-recent change that align with some of the elements of that issues. If you repro more details would be useful.

Or: was text-wrapping active? that's to rule out whole chunks of code including bits that have changed.

@ocornut ocornut changed the title ImFont::RenderText() issue ImFont::RenderText() issue Jan 31, 2023
@ocornut ocornut added the bug label Jan 31, 2023
@tksuoran
Copy link
Author

I can now repro. This happens with TreeNodeEx() that gets completely clipped / scrolled so that it is not visible, with flags ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick |ImGuiTreeNodeFlags_SpanFullWidth, word_wrap_enabled == false.

Perhaps // Fast-forward to first visible line is at fault, when there is no line at all that is visible? That code section has s = line_end + 1.

@tksuoran
Copy link
Author

Indeed the code path in my previous comment is executed and that is how s gets text_end + 1 value.

@tksuoran
Copy link
Author

+		this	0x000001e03dc44f80 {IndexAdvanceX={Size=256 Capacity=256 Data=0x000001e0313a0bf0 {6.00000000} } FallbackAdvanceX=...}	const ImFont *
+		clip_rect	{x=1.00000000 y=699.000000 z=168.000000 ...}	const ImVec4 &
		col	2634022911	unsigned int
		col_untinted	3435973836	const unsigned int
		cpu_fine_clip	false	bool
+		draw_list	0x000001e0046c8e78 {CmdBuffer={Size=1 Capacity=8 Data=0x000001e01ef86e30 {ClipRect={x=1.00000000 y=699.000000 ...} ...} } ...}	ImDrawList *
		idx_count_max	-6	const int
		idx_expected_size	15	const int
+		idx_write	0xcccccccccccccccc {???}	unsigned short *
		line_height	17.0000000	const float
+		pos	{x=44.0000000 y=681.000000 }	const ImVec2 &
+		s	0x00007ff67604a8b1 ""	const char *
		scale	1.00000000	const float
		size	17.0000000	float
		start_x	44.0000000	const float
+		text_begin	0x00007ff67604a8a8 "Material"	const char *
+		text_end	0x00007ff67604a8b0 ""	const char *
		vtx_count_max	-4	const int
		vtx_index	3435973836	unsigned int
+		vtx_write	0xcccccccccccccccc {pos={x=??? y=??? } uv={x=??? y=??? } col=??? }	ImDrawVert *
		word_wrap_enabled	false	const bool
+		word_wrap_eol	0xcccccccccccccccc <Error reading characters of string.>	const char *
		wrap_width	0.00000000	float
		x	44.0000000	float
		y	698.000000	float

@ocornut
Copy link
Owner

ocornut commented Jan 31, 2023

Thank you, I can repro with #define IMGUI_DEBUG_PARANOID. Now going to lunch but going to look into this afterwards.

@ocornut
Copy link
Owner

ocornut commented Jan 31, 2023

Broken by 3482d4e (#5720, #5919)

ocornut added a commit that referenced this issue Jan 31, 2023
@ocornut
Copy link
Owner

ocornut commented Jan 31, 2023

Pushed fix 867bdbe

Interestingly, it would trigger with IMGUI_DEBUG_PARANOID defined, but without it would work as the count is cancelled at the end of the function (but it would run some extra code unnecessarily).

Thank you!

@ocornut ocornut closed this as completed Jan 31, 2023
kjblanchard pushed a commit to kjblanchard/imgui that referenced this issue May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants