← 输入框|github.com|刷新
Skip to content

Robust UTF8 conversion - #4

Closed
r8zr wants to merge 2 commits into
solvespace:masterfrom
r8zr:master
Closed

r8zr wants to merge 2 commits into
solvespace:masterfrom
r8zr:master

Conversation

@r8zr

@r8zr r8zr commented May 16, 2016

Copy link
Copy Markdown

Old UTF8 conversion works wrong with degree symbol that is showing while using angle constraint.
Calculating of bytes offset was wrong and then we stuck in loop trying to read some thrash in memory.

@whitequark

Copy link
Copy Markdown
Contributor

What exactly was wrong with it? The old code I took from glib (g_unichar_to_utf), I doubt there's a bug in it.

@r8zr

r8zr commented May 17, 2016 •

Copy link
Copy Markdown
Author

i've tried to add "Constraint angle" into my sketch, and after clicking on the button i've got next error (see attachment).
untitled

I've tried to debug it, and found that a problem is actually with a degree symbol (°) that is using in label of "Constraint angle". Then in char32_t utf8_iterator::operator*() i've found that this line
this->n = (const char*) (it + 1);
return thrash instead of end of line, so we will stuck in a loop in double ssglStrWidth(const std::string &str, double h) method. So looks like calculating of offset to the next character is working wrong here.
My converting routine should work perfect with all UTF8 characters. The problem could be only with JIS encoding, but as i understand SolveSpace doesn't support it at all, so working with JIS we will have a problem in any case.

@whitequark

Copy link
Copy Markdown
Contributor

Well, the existing routine should work perfect with all UTF-8 characters as well. Let me try to reproduce this.

@whitequark

Copy link
Copy Markdown
Contributor

Ok, so I've just created such a constraint using the e129755 build from Appveyor on Windows XP SP3:
2233

What configuration are you using exactly?

@r8zr

r8zr commented May 17, 2016

Copy link
Copy Markdown
Author

Intel Core 2 Quad Q6600, Windows 7 Ultimate SP1 x86, Visual Studio Ultimate 2013 Version 12.0.40629.00 Update 5

@whitequark

Copy link
Copy Markdown
Contributor

Ok, I'll install that. Did you build it in the default configuration, or did you change some CMake parameters?

@r8zr

r8zr commented May 17, 2016

Copy link
Copy Markdown
Author

Default
untitled
untitled

@whitequark

Copy link
Copy Markdown
Contributor

I just rebuilt using your exact VS version and OS. I cannot reproduce your crash. Does the binary from https://ci.appveyor.com/project/whitequark/solvespace/build/2.1.7/artifacts crash as well?

@r8zr

r8zr commented May 19, 2016

Copy link
Copy Markdown
Author

Sorry for delay here.. So, looks like problem is gone after cloning a repo in new location and rebuilding. Still don't know why it was crashing. Sorry for false alarm and wasting your time!

@r8zr r8zr closed this May 19, 2016
@whitequark

Copy link
Copy Markdown
Contributor

I suspect the UTF-8 in the source got broken somehow; the UTF-8 iterator is optimized for speed, not robustness, and it's all but supposed to crash that way.

This isn't really important because all input data (except that read from savefiles) is already sanitized at boundary, and savefiles will be sanitized soon since I have to rewrite the serialization code anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants