-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Crash when trying to use automatic line wrapping: #793
Comments
Those are two different things you are discussing. The first one is an assert that checks that you didn't alter the text buffer in the text edit custom callback without maintaining its length. Have you read the comment next to it?
The second, can you double-check that |
Both appears to be bug in your code not in imgui.. |
I wonder if
PS: If you are going to display big chunk of text here using |
and
outputs:
|
OK so |
OK in
Assuming your lib/compiler version of vsnprintf if one that ever returns -1. |
IGNORE THIS: I put a breakpoint in ImFormatStringV and it is not being called for the string that crashes. I get a bunch that work, but the crash happens (it's a clang address santizier check fail, technically) before the breakpoint is hit. Address sanitization CAN give false positives... It's crashing before it gets to TextV, as well. I'm on clang 3.8 on os x. |
This is odd -- I send the string "no jobs" through, and it works. Then I send the "keyboard mouse text" line through and it works. Then I send the really long one through, the "strlen of thing I'm sending to imgui: 3706" is expected, but then the next breakpoint says the string is "no jobs" but the length is 3706. And then it crashes (I trimmed the crash report, but you can see it beginning)
|
You said:
but it already says that: https://github.com/ocornut/imgui/blob/master/imgui.cpp#L954 https://github.com/ocornut/imgui/blob/master/imgui.cpp#L961 |
Sorry the other way around, add the -1 |
Yes, but it must be fixed for the other path. I'm finding it hard to read or grasp the explanation or content of most of your posts above.. e.g.
|
adding the -1 in those two places didn't seem to change anything.
|
Hmm... if you have a predictable repro, could you trace into it and figure out at which point With this code-path it will use So GImGui->TempBuffer[3072] is valid, GImGui->TempBuffer[3073] not valid. I can't find to find a repro so far. :( The -1 fix is most definitively a correct fix that needs to be pushed, I'm very surprised this doesn't fix it for you. |
You're building with clang and -fsanitize=address set? |
I'm building with visuals and adding asserts. |
This probably isn't the most useful format, but this is a decimal ascii dump of the string. I have to go to sleep for the hour before I need to wake up, and I'll look at this more this afternoon/evening pacific time. Thanks for all your help. I really hope this isn't some sort of weird clang address sanitization bug... [deleted ridiculousness] |
err, how about fopen("dump.txt", "wb") fwrite() fclose()? |
So when I'm looking at it later, what is Hrmm, I wonder if trailing \n's cause problems? |
OK I think I know what it is, your vsnprintf() behave differently than MSVCRT one. |
|
C libraries can't agree on a behavior for vsnprintf(), great.. try:
|
It is mildly annoying because glibc and msvcrt behave differently, and there's actually genuine use for both behaviors. Right now with the way we are using it with the glibc behavior it is doing a little unnecessary work (we wouldn't mind if it stopped counting). I'll push a fix. In your situation you should still use Thanks for the help. Safe sleep! |
…f vsnprintf() that do not return -1 (#793)
http://demin.ws/blog/english/2013/01/28/use-snprintf-on-different-platforms/ Yikes:
|
I had some code that printed text in a window and it was sometimes too long, so I thought I'd change it to use line wrapping. I tried changing from text colored to text wrapped, and it crashed. So I saw that in the header file it said text wrapped was just a helper around a couple other calls, so I added those other calls aroudn my textcolored instead. Still crashed. I then upgraded to latest version, and it still crashes.
In the very bottom of this listing, you can see my code -- I pointed out which line I had before that worked and the line directly above and below it that are causing the crash.
Happy to provide any more data.
The text was updated successfully, but these errors were encountered: