Repository navigation
utf8: point the non-UTF-8 guard at the offending byte - #4246
Merged
Merged
Conversation
The guard in string_to_client_encoding has fired about ten times per
server run since 17.11 -- the counter caps at ten, so the real rate is
unknown -- and not one line has been usable. It printed sixteen bytes
from the head of the buffer, and the head of a broken string is intact:
Первые байты: 0d 0a 4f 6e 6c 69 6e 65 3a 20 31 30 32 0d 0a 0d
That is "\r\nOnline: 102\r\n\r", the login banner plus the start of the
codepage prompt, both pure ASCII. The bad byte is somewhere further on
and the dump never reached it.
Added utf8::find_invalid, which returns the offset of the first
ill-formed byte (is_valid is now one line over it), and rebuilt the
diagnostic around that offset: the byte number, the buffer length, the
bytes on both sides with the offender starred, and the descriptor's
state and codepage -- without the last two there is no telling output
before login from output to a player in the game.
Nothing about what is sent to the client changes; this is the diagnostic
only. The three byte signatures seen on the live server (a fresh
connection, text already converted to CP1251, and the tail of an ANSI
sequence) suggest more than one cause, which is why the next step is a
line that says where to look rather than a guess at a fix.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что видно в логе
Предохранитель в
string_to_client_encoding(из #3681) срабатывает на боевом с 17.11 — примерно по десятку строк за запуск сервера, и это нижняя оценка: счётчик печатает первые десять и дальше каждую десятитысячную, так что настоящий поток неизвестен. Полезной ни одна строка не оказалась:Это
"\r\nOnline: 102\r\n\r"— приветствие при подключении и начало приглашения выбрать кодировку, чистая латиница. Начало у битой строки целое, испорченный байт лежит дальше, и дамп до него не доходил.Три разные подписи за неделю, то есть причина не одна:
0d 0a 4f 6e 6c 69 6e 65 3a ...0d 0a e5 f2 20 e7 e4 e5 f1 fc 2e0d 0a 33 30 6d 20 2d 2030m -, хвост ANSI-последовательностиВторая подпись — самая интересная: на вход предохранителю должен приходить нативный UTF-8, а приходит уже готовый CP1251. Но по шестнадцати байтам от начала дальше не продвинуться.
Правка
Добавлен
utf8::find_invalid— смещение первого ill-formed байта (is_validтеперь строка над ним) — и строка перестроена вокруг этого смещения:Номер байта, длина буфера, байты с двух сторон (испорченный помечен звёздочкой), состояние дескриптора и кодировка. Без последних двух нельзя отличить вывод до входа в игру от вывода играющему — а подписи говорят, что это разные случаи.
На то, что уходит клиенту, правка не влияет: меняется только диагностика. Починки тут нет намеренно — сначала строка, которая скажет, куда смотреть.
Проверка
build_nounity(-Dunity=off), 933 теста, 930 прошли, 3 отключены штатно. ДобавленUtf8.FindInvalidPointsAtTheOffendingByte: смещение на чистой строке, на одиночном байте, на обрезанном хвосте (случай с боевого) и на первой из двух поломок.🤖 Generated with Claude Code