Bug 482367 - kmail / kontact eates all my memory during startup and crashes than.
Summary: kmail / kontact eates all my memory during startup and crashes than.
Status: RESOLVED FIXED
Alias: None
Product: kmail2
Classification: Applications
Component: general (show other bugs)
Version: 6.0.0
Platform: Neon Linux
: NOR crash
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords: qt6
: 483686 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-03-04 10:31 UTC by Hartmut Manz
Modified: 2024-04-02 07:20 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
gdb debug messages (tracebacks) (51.19 KB, text/plain)
2024-03-04 10:31 UTC, Hartmut Manz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hartmut Manz 2024-03-04 10:31:30 UTC
Created attachment 166387 [details]
gdb debug messages (tracebacks)

SUMMARY
***
Since a few days I can not start kmail or kontact anymore. It eats all my memory and crashes than.

I have now tried to run in in debugger and have interruppted the process every 30-60 seconds,
taken a backtrace and continued again.

At the End the kmail porcess eats all my memory (64GB) and swap (another 64GB) and crashed.

The traceback is attached.


STEPS TO REPRODUCE
Not sure, my Mail boxes are large.

OBSERVED RESULT


EXPECTED RESULT


Operating System: KDE neon Testing Edition
KDE Plasma Version: 6.0.0
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.5.0-21-generic (64-bit)
Graphics Platform: X11
Processors: 24 × 13th Gen Intel® Core™ i7-13700
Memory: 62,5 GiB of RAM
Graphics Processor: NVIDIA T1000/PCIe/SSE2
Manufacturer: Thomas-Krenn.AG
Product Name: Business-PC PI1004-FRCIS
System Version: 1.0
Linux/KDE Plasma: 


ADDITIONAL INFORMATION
Comment 1 shivarryn 2024-03-08 14:27:12 UTC
Just a note.

I observe the same problem with the very same backtrace, but on a different scenario.
In my case kmail opens, but when I try to reply to an email, kmail is stuck and memory goes up, until kmail is killed. The compositor window never shows up.

Backtrace is the same: from KMComposerWin::setMessage to MessageComposer::ComposerViewBase::setMessage, then down to  the chain until QTextDocumentLayoutPrivate::layoutBlock, where it seems to loop forever and eat all the memory. It is not clear if it is a kmail or Qt problem. 

It happens replying to almost all my emails, but on a very few emails the problem does not appear. Odd.
Comment 2 Sebastian Turzański 2024-03-11 12:29:05 UTC
I have exactly the same on : 
Opensuse tumbleweed 
Plasma 6.0.1 and KMail 6.0.0 (24.02.0) 
Wayland
Comment 3 Sebastian Turzański 2024-03-13 20:05:30 UTC
I have one more info for troubleshooting.
If the mail is plain text reply works, if it is html then this whole memory eating starts until systme is frozen.
Comment 4 shivarryn 2024-03-13 23:04:03 UTC
(In reply to Sebastian Turzański from comment #3)
> I have one more info for troubleshooting.
> If the mail is plain text reply works, if it is html then this whole memory
> eating starts until systme is frozen.

html is probably involved, but I have some html emails that don't show this problem when replying to.
Comment 5 Sebastian Turzański 2024-03-16 12:17:25 UTC
did you also upgrade from plasma5 to plasma6 with kmail and mailbox created in plasma5 ?
maybe that is the reason as I had been using it in plasma5 and have quite big accounts there and now I tried to use it in plasma6
Comment 6 shivarryn 2024-03-18 07:32:43 UTC
(In reply to Sebastian Turzański from comment #5)
> did you also upgrade from plasma5 to plasma6 with kmail and mailbox created
> in plasma5 ?

Yes.

I'm going to install Arch on a new laptop from scratch, will see if it shows the same problem or not.
Comment 7 shivarryn 2024-03-18 10:22:58 UTC
Issue is also present after a clean install.

Replying as plaintext works, so it is related to html.

If any dev wants to have a look, I can provide a simple test mail privately.
Comment 8 luna 2024-03-18 12:27:36 UTC
*** Bug 483686 has been marked as a duplicate of this bug. ***
Comment 9 shivarryn 2024-03-19 08:49:12 UTC
I played a little more with gdb and discovered the following.

The infinite loop happens in QTextDocumentLayoutPrivate::layoutBlock, in the "while (1)" block at line 3477:
https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/text/qtextdocumentlayout.cpp?h=6.6.2

Here, tl->createLine is called.
From QTextLayout::createLine, on lines 802/803,
https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/text/qtextlayout.cpp?h=6.6.2
I can see that the "from" field is always 0. So, the incoming text is never consumed, and an endless number of 0-length QTextLines are produced. This is where all the memory is consumed.

With the help of gdb, I dumped the problematic html payload which is passed to QTextEdit::setHtml (it is the "reply" formatted html string prepared by kmail in response to the mail we're replying to) and created a test program populating a QTextLine with the same payload. The program worked correctly, so I don't really understand what is going on here. Maybe some layout settings from kmail are not handled correctly by Qt 6 code, who knows.

A dev eye would be really appreciated at this point. At a first glance what kmail is doing seems correct to me.
Comment 10 shivarryn 2024-03-19 08:53:45 UTC
> and created a test program populating a QTextLine with the same payload

s/QTextLine/QTextEdit
Comment 11 luna 2024-03-21 22:54:52 UTC
I just tested on an Fedora Asahi machine with nearly identical config (copied my kmail2rc over from the crashing machine) and I'm able to reply to the same email that triggered the crash. That machine runs Arch, and shivarryn at least also runs Arch. Are the other folks who are having trouble with this also running Arch?
Comment 12 luna 2024-03-22 01:06:45 UTC
(In reply to luna from comment #11)
> I just tested on an Fedora Asahi machine with nearly identical config
> (copied my kmail2rc over from the crashing machine) and I'm able to reply to
> the same email that triggered the crash. That machine runs Arch, and
> shivarryn at least also runs Arch. Are the other folks who are having
> trouble with this also running Arch?

Sorry, disregard that, this Fedora machine isn't on Plasma 6 yet :(
Comment 13 shivarryn 2024-03-31 20:00:55 UTC
Good news!
Problem is gone on my side after Qt 6.6.3 reached Arch.
So yes, it was probably a Qt issue.
If the other reporters can confirm after Qt 6.6.3 reaches your distros, we can close the bug.
Comment 14 luna 2024-03-31 20:01:39 UTC
(In reply to shivarryn from comment #13)
> Good news!
> Problem is gone on my side after Qt 6.6.3 reached Arch.
> So yes, it was probably a Qt issue.
> If the other reporters can confirm after Qt 6.6.3 reaches your distros, we
> can close the bug.

I can also confirm that this is fixed on my Arch machine.
Comment 15 Hartmut Manz 2024-04-02 07:20:56 UTC
(In reply to shivarryn from comment #13)
> Good news!
> Problem is gone on my side after Qt 6.6.3 reached Arch.
> So yes, it was probably a Qt issue.
> If the other reporters can confirm after Qt 6.6.3 reaches your distros, we
> can close the bug.

Also for me on latest NEON update with latest Qt 6.6.3  update the problem is fixed now.
Thank You