Bug 272579 - 100% cpu when i open a file 1 byte long
Summary: 100% cpu when i open a file 1 byte long
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 4.0
Platform: Ubuntu Linux
: VHI normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 298904 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-05-05 23:56 UTC by poub67
Modified: 2021-08-12 08:13 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
file with 1 character : é with encoding ISO-8859-15 (1 bytes, text/plain)
2011-05-05 23:56 UTC, poub67
Details

Note You need to log in before you can comment on or make changes to this bug.
Description poub67 2011-05-05 23:56:39 UTC
Created attachment 59668 [details]
file with 1 character : é with encoding ISO-8859-15

Version:           4.0 (using KDE 4.6.2) 
OS:                Linux

kate is configured utf8
i open an ISO-8859-15 file with only one character : é
the system became totally slow with 100% cpu eat
the file is never opened

Reproducible: Always

Steps to Reproduce:
open kwrite or kate
(encoding by default is utf-8)

set encoding to ISO-8859-15
write the character é
save
set encoding to UTF-8   ==>   100% cpu ! 
kill kwrite or kate

open kwrite or kate   ( encoding is by default utf-8 )
open the file     => 100% cpu


Actual Results:  
file is never opened and the system hang

Expected Results:  
file is opened
Comment 1 Milian Wolff 2011-05-06 13:49:18 UTC
confirmed, I get an assert though:

milian@odin:/tmp$ debug kwrite a
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/milian/projects/compiled/kde4/bin/kwrite...done.
Starting program: /home/milian/projects/compiled/kde4/bin/kwrite a
[Thread debugging using libthread_db enabled]
[New Thread 0x7fffe50b0700 (LWP 8624)]
ASSERT: "i >= 0 && i < size()" in file /usr/include/qt4/QtCore/qstring.h, line 701

Program received signal SIGABRT, Aborted.
0x00007ffff38d6d05 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
        in ../nptl/sysdeps/unix/sysv/linux/raise.c
(gdb) bt
#0  0x00007ffff38d6d05 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff38daab6 in abort () at abort.c:92
#2  0x00007ffff49aaad4 in qt_message_output (msgType=<value optimized out>, buf=<value optimized out>) at global/qglobal.cpp:2282
#3  0x00007ffff49aac8f in qt_message(QtMsgType, const char *, typedef __va_list_tag __va_list_tag *) (msgType=QtFatalMsg, msg=0x7ffff4afa0a8 "ASSERT: \"%s\" in file %s, line %d", 
    ap=0x7fffffffc180) at global/qglobal.cpp:2328
#4  0x00007ffff49aae31 in qFatal (msg=<value optimized out>) at global/qglobal.cpp:2511
#5  0x00007fffe663e35c in QString::at (this=0x7fffffffc470, i=0) at /usr/include/qt4/QtCore/qstring.h:701
#6  0x00007fffe663f957 in Kate::TextLoader::readLine (this=0x7fffffffc440, offset=@0x7fffffffc5bc, length=@0x7fffffffc5b8)
    at /home/milian/projects/kde4/kate/part/buffer/katetextloader.h:266
#7  0x00007fffe663cf48 in Kate::TextBuffer::load (this=0xa35610, filename="/tmp/a", encodingErrors=@0xa356d0) at /home/milian/projects/kde4/kate/part/buffer/katetextbuffer.cpp:547
#8  0x00007fffe66d5d67 in KateBuffer::openFile (this=0xa35610, m_file="/tmp/a") at /home/milian/projects/kde4/kate/part/document/katebuffer.cpp:160
#9  0x00007fffe66b6c6a in KateDocument::openFile (this=0xa349e0) at /home/milian/projects/kde4/kate/part/document/katedocument.cpp:1966
#10 0x00007ffff7743ab0 in KParts::ReadOnlyPartPrivate::openLocalFile (this=0xa34c50) at ../../kparts/part.cpp:592
#11 0x00007ffff77440f4 in KParts::ReadOnlyPart::openUrl (this=0xa349e0, url=...) at ../../kparts/part.cpp:556
#12 0x00007ffff7bcca7a in KWrite::loadURL (this=0x780ea0, url=...) at /home/milian/projects/kde4/kate/kwrite/kwritemain.cpp:222
#13 0x00007ffff7bd3f6b in KWriteApp::init (this=0x7fffffffcdc0) at /home/milian/projects/kde4/kate/kwrite/kwriteapp.cpp:136
#14 0x00007ffff7bd360a in KWriteApp::KWriteApp (this=0x7fffffffcdc0, m_args=0x64b780) at /home/milian/projects/kde4/kate/kwrite/kwriteapp.cpp:51
#15 0x00007ffff7bd08a2 in kdemain (argc=2, argv=0x7fffffffd8b8) at /home/milian/projects/kde4/kate/kwrite/kwritemain.cpp:676
#16 0x0000000000400856 in main (argc=2, argv=0x7fffffffd8b8) at /home/milian/projects/.build/kde4/kate/kwrite/kwrite_dummy.cpp:3
Comment 2 Christoph Cullmann 2011-05-08 19:14:50 UTC
Git commit 7d3160df3574196a38197a0e68efc9e8b20695ca by Christoph Cullmann.
Committed on 08/05/2011 at 19:25.
Pushed by cullmann into branch 'master'.

fix crash with latin-15 file that has one byte
encoder somehow doesn't do anything here
now correctly sees the encoding error and falls back to latin-1
BUG: 272579

M  +18   -2    part/buffer/katetextloader.h     
M  +3    -0    part/tests/encoding/CMakeLists.txt     
A  +1    -0    part/tests/encoding/one-char-latin-15.txt         [License: Trivial file]

http://commits.kde.org/kate/7d3160df3574196a38197a0e68efc9e8b20695ca
Comment 3 Dominik Haumann 2012-04-27 17:47:14 UTC
*** Bug 298904 has been marked as a duplicate of this bug. ***
Comment 4 Bug Janitor Service 2021-08-02 11:54:04 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/180
Comment 5 Jan Paul Batrina 2021-08-12 08:13:05 UTC
Git commit 5ce06dacda2f57e03c5d513eba75fadda63505ca by Jan Paul Batrina.
Committed on 02/08/2021 at 11:44.
Pushed by cullmann into branch 'master'.

Do not show encoding error when file only contains BOM

failedToConvertOnce shouldn't be set to true when
the BOM was processed.

After this commit, opening files with the following
hex content should open in the corresponding encodings:
E9		- Latin-1/ISO-8859-15
EF BB BF	- UTF-8
EF BB BF E9 FF	- Latin-1/ISO-8859-15

Then forcing the Latin-1 files above to be opened
as UTF-8 should show the "invalid encoding" error
message properly.
Related: bug 440359

M  +11   -1    src/buffer/katetextloader.h

https://invent.kde.org/frameworks/ktexteditor/commit/5ce06dacda2f57e03c5d513eba75fadda63505ca