crash with Font #951

Closed
opened 2016-12-24 11:32:14 +00:00 by sonoro1234 · 10 comments
sonoro1234 commented 2016-12-24 11:32:14 +00:00 (Migrated from github.com)

Hello Omar,

If I use:

imgui.ImGui_ImplGlfwGL3_Init(self.window, false);
imgui.ImFontAtlas_AddFontFromFileTTF(imgui.igGetIO().Fonts, [[C:\luaGL\ProggyTiny.ttf]], 10, nil, nil)

I am getting crashes so I did gdb with Debug and RelWithDebInfo:

--Debug version

Program: C:\luaGL\luajit.exe
File: C:\luaGL\gitsources\cimgui\imgui\imgui_draw.cpp, Line 1278

Expression: font_offset >= 0

This application has requested the Runtime to terminate it in an unusual way.

--RelWithDebInfo

Program received signal SIGSEGV, Segmentation fault.
SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636
4636        g.FontTexUvWhitePixel = g.Font->ContainerAtlas->TexUvWhitePixel;


Thread 1 (Thread 4812.0xa24):
#0  SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636
#1  0x6bd13a66 in ImGui::NewFrame () at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:2142
#2  0x6bd4066b in ImGui_ImplGlfwGL3_NewFrame ()
    at C:\luaGL\gitsources\cimgui\extras\impl_glfw3\imgui_impl_glfw_gl3.cpp:401
#3  0x66d84bb2 in ?? () from C:\luaGL\lua51.dll

but I am not able to make conclusions.
1278 is ImFontAtlas::Build()

Thanks

Hello Omar, If I use: ```` imgui.ImGui_ImplGlfwGL3_Init(self.window, false); imgui.ImFontAtlas_AddFontFromFileTTF(imgui.igGetIO().Fonts, [[C:\luaGL\ProggyTiny.ttf]], 10, nil, nil) ```` I am getting crashes so I did gdb with Debug and RelWithDebInfo: ```` --Debug version Program: C:\luaGL\luajit.exe File: C:\luaGL\gitsources\cimgui\imgui\imgui_draw.cpp, Line 1278 Expression: font_offset >= 0 This application has requested the Runtime to terminate it in an unusual way. --RelWithDebInfo Program received signal SIGSEGV, Segmentation fault. SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636 4636 g.FontTexUvWhitePixel = g.Font->ContainerAtlas->TexUvWhitePixel; Thread 1 (Thread 4812.0xa24): #0 SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636 #1 0x6bd13a66 in ImGui::NewFrame () at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:2142 #2 0x6bd4066b in ImGui_ImplGlfwGL3_NewFrame () at C:\luaGL\gitsources\cimgui\extras\impl_glfw3\imgui_impl_glfw_gl3.cpp:401 #3 0x66d84bb2 in ?? () from C:\luaGL\lua51.dll ```` but I am not able to make conclusions. 1278 is ImFontAtlas::Build() Thanks
ocornut commented 2016-12-24 12:03:31 +00:00 (Migrated from github.com)

Is your filename correct? I am not sure what \ means in your language but in c++ it would escape the next character.

Do you have asserts enabled? It looks like you are missing some diagnostics checks.

On 24 Dec 2016, at 12:32, Victor Bombi notifications@github.com wrote:

Hello Omar,

If I use:

imgui.ImGui_ImplGlfwGL3_Init(self.window, false);
imgui.ImFontAtlas_AddFontFromFileTTF(imgui.igGetIO().Fonts, C:\luaGL\ProggyTiny.ttf, 10, nil, nil)
I am getting crashes so I did gdb with Debug and RelWithDebInfo:

--Debug version

Program: C:\luaGL\luajit.exe
File: C:\luaGL\gitsources\cimgui\imgui\imgui_draw.cpp, Line 1278

Expression: font_offset >= 0

This application has requested the Runtime to terminate it in an unusual way.

--RelWithDebInfo

Program received signal SIGSEGV, Segmentation fault.
SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636
4636 g.FontTexUvWhitePixel = g.Font->ContainerAtlas->TexUvWhitePixel;

Thread 1 (Thread 4812.0xa24):
#0 SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636
#1 0x6bd13a66 in ImGui::NewFrame () at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:2142
#2 0x6bd4066b in ImGui_ImplGlfwGL3_NewFrame ()
at C:\luaGL\gitsources\cimgui\extras\impl_glfw3\imgui_impl_glfw_gl3.cpp:401
#3 0x66d84bb2 in ?? () from C:\luaGL\lua51.dll
but I am not able to make conclusions.
1278 is ImFontAtlas::Build()

Thanks

―
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Is your filename correct? I am not sure what \ means in your language but in c++ it would escape the next character. Do you have asserts enabled? It looks like you are missing some diagnostics checks. > On 24 Dec 2016, at 12:32, Victor Bombi <notifications@github.com> wrote: > > Hello Omar, > > If I use: > > imgui.ImGui_ImplGlfwGL3_Init(self.window, false); > imgui.ImFontAtlas_AddFontFromFileTTF(imgui.igGetIO().Fonts, [[C:\luaGL\ProggyTiny.ttf]], 10, nil, nil) > I am getting crashes so I did gdb with Debug and RelWithDebInfo: > > --Debug version > > Program: C:\luaGL\luajit.exe > File: C:\luaGL\gitsources\cimgui\imgui\imgui_draw.cpp, Line 1278 > > Expression: font_offset >= 0 > > This application has requested the Runtime to terminate it in an unusual way. > > --RelWithDebInfo > > Program received signal SIGSEGV, Segmentation fault. > SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636 > 4636 g.FontTexUvWhitePixel = g.Font->ContainerAtlas->TexUvWhitePixel; > > > Thread 1 (Thread 4812.0xa24): > #0 SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636 > #1 0x6bd13a66 in ImGui::NewFrame () at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:2142 > #2 0x6bd4066b in ImGui_ImplGlfwGL3_NewFrame () > at C:\luaGL\gitsources\cimgui\extras\impl_glfw3\imgui_impl_glfw_gl3.cpp:401 > #3 0x66d84bb2 in ?? () from C:\luaGL\lua51.dll > but I am not able to make conclusions. > 1278 is ImFontAtlas::Build() > > Thanks > > ― > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub, or mute the thread. >
sonoro1234 commented 2016-12-24 12:10:53 +00:00 (Migrated from github.com)

Filename is ok in Lua and ImFontAtlas_AddFontFromFileTTF returns not null.
Are asserts enabled building for Debug?

Filename is ok in Lua and ImFontAtlas_AddFontFromFileTTF returns not null. Are asserts enabled building for Debug?
ocornut commented 2016-12-24 12:56:47 +00:00 (Migrated from github.com)

Assert being enabled or not is up your building configuration and where it goes when calling assert(), unless you have redefined IM_ASSERT in imconfig.h
From your log your should have stopped/crashed on the IM_ASSERT(font_offset >= 0); line and not gone any further than that.

We are calling stbtt_GetFontOffsetForIndex() and it returns an error so either the font data is invalid, either the FontNo is invalid, either there is a bug/issue in stb_truetype.h.
Maybe first try with one of the ttf file provided in extra_fonts/ because those definitively works.

Sent from my fax machine

Assert being enabled or not is up your building configuration and where it goes when calling assert(), unless you have redefined IM_ASSERT in imconfig.h From your log your should have stopped/crashed on the IM_ASSERT(font_offset >= 0); line and not gone any further than that. We are calling stbtt_GetFontOffsetForIndex() and it returns an error so either the font data is invalid, either the FontNo is invalid, either there is a bug/issue in stb_truetype.h. Maybe first try with one of the ttf file provided in extra_fonts/ because those definitively works. Sent from my fax machine
sonoro1234 commented 2016-12-24 13:01:03 +00:00 (Migrated from github.com)

I could check that the pointer in SetCurrentFont is the same returned from ImFontAtlas_AddFontFromFileTTF

I could check that the pointer in SetCurrentFont is the same returned from ImFontAtlas_AddFontFromFileTTF
sonoro1234 commented 2016-12-24 13:02:44 +00:00 (Migrated from github.com)

ProggyTiny.ttf is from extra_fonts

ProggyTiny.ttf is from extra_fonts
sonoro1234 commented 2016-12-24 13:04:14 +00:00 (Migrated from github.com)

Also : there are two gdb traces, one for Debug the other for Release with debug information

Also : there are two gdb traces, one for Debug the other for Release with debug information
ocornut commented 2016-12-24 13:21:44 +00:00 (Migrated from github.com)

Use a debugger to trace thru the code!

Use a debugger to trace thru the code!
sonoro1234 commented 2016-12-24 14:32:53 +00:00 (Migrated from github.com)
(gdb) print cfg
$1 = (ImFontConfig &) @0x5fe4b8: {FontData = 0x3ac0048, FontDataSize = 68677, FontDataOwnedByAtlas = true,
  FontNo = 0, SizePixels = 10, OversampleH = 3, OversampleV = 1, PixelSnapH = false, GlyphExtraSpacing = {
    x = 0, y = 0}, GlyphRanges = 0x0, MergeMode = false, MergeGlyphCenterV = false,
  Name = "ProggyTiny.ttf, 10px", '\000' <repeats 11 times>, DstFont = 0x5fe170}
```` (gdb) print cfg $1 = (ImFontConfig &) @0x5fe4b8: {FontData = 0x3ac0048, FontDataSize = 68677, FontDataOwnedByAtlas = true, FontNo = 0, SizePixels = 10, OversampleH = 3, OversampleV = 1, PixelSnapH = false, GlyphExtraSpacing = { x = 0, y = 0}, GlyphRanges = 0x0, MergeMode = false, MergeGlyphCenterV = false, Name = "ProggyTiny.ttf, 10px", '\000' <repeats 11 times>, DstFont = 0x5fe170} ````
sonoro1234 commented 2016-12-24 14:47:34 +00:00 (Migrated from github.com)

A lot of noise for: Fake ProggyTiny.ttf
It was an html file saved with that name!!
(inspecting the data in the debugger revealed it)
Everything works now
Sorry

A lot of noise for: Fake ProggyTiny.ttf It was an html file saved with that name!! (inspecting the data in the debugger revealed it) Everything works now Sorry
ocornut commented 2016-12-31 09:49:48 +00:00 (Migrated from github.com)

Your assert should really crash/halt your application, this is what asserts are for.
I can silently fail or keep returning error codes but it'll have to fail at some point (main loop needs at least one valid font).

Your assert should really crash/halt your application, this is what asserts are for. I can silently fail or keep returning error codes but it'll have to fail at some point (main loop needs at least one valid font).
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#951
No description provided.