debugging kmail crash

Jos van den Oever jos at vandenoever.info
Mon Dec 17 11:49:03 GMT 2018


On Monday, December 17, 2018 10:50:40 AM CET Daniel Vrátil wrote:
> > To avoid heavy swapping I set `ulimit -v5000000` in .bashrc. This is not
> > enough for kmail.
> > Showing a mail on my system requires `limit -v6000000`.
> 
> Wait, are you setting maximum virtual memory to 5.7 MB? I'm surprised
> anything works at all!

The value is in 1024 increments (man bash). On my 8GB machine, -v6000000 is 
5.7GB, so 3/4 the size of the available memory.

> > I set this some years ago and now forgot about it. If the stack trace
> > had shown malloc, I'd probably have figured this out earlier.
> > 
> > To reproduce this issue:
> > 
> > ulimit -v5000000
> > kmail --view /etc/passwd
> > 
> > If the limit is even lower, the error message is clearer:
> > 
> > $ ulimit -v1000000
> > $ kmail --view /etc/passwd
> > org.kde.kcoreaddons: Failed to establish shared memory mapping, will
> > fallback to private memory -- memory usage will increase
> > Unable to allocate shared memory segment for shared data cache
> > "/home/oever/.cache/icon-cache.kcache" of size 10485760
> > terminate called after throwing an instance of 'std::bad_alloc'
> > 
> >    what():  std::bad_alloc
> > 
> > Aborted
> > 
> > Why does kmail need so much memory to show a mail? It might be related
> > to QtWebRender.
> 
> 1) virtual memory != used memory - it includes all code, mmaped files,
> data,... 2) on my system, KMail main window uses ~320MB RAM of actually
> allocated data 3) note that QtWebEngine spanws a some helper processes for
> the actual rendering - those also need some memory and cannot be easily
> tamed

Right, mmapping a file would also need to fit in the limit.
KMail here uses 5676096 kb virtual and 270600 kb resident.
The next largest user of virtual memory is plasmashell with 4541300kb.

> > Gtk Webkit has a feature gigacage that requests a very large virtual
> > memory space. This used to cause crashes for people setting the allowed
> > memory with ulimit. The developers worked around this problem by
> > silently disable gigacage when ulimit restricted the allowed memory.
> > 
> > https://blogs.gnome.org/mcatanzaro/2018/11/02/on-webkit-build-options-also
> > -h ow-to-accidentally-disable-important-security-features/
> 
> I don't know if I want to do this. If a user is knowledgeable enough to use
> ulimit, they should be able to deal with the consequences.

I agree, which is why I'm not creating an issue. I did want to report my 
experiences.

I'm not aware of a way to limit the actually used amount of memory for a 
process. ulimit -m (max resident mem) is not enforced. That would be the real 
solution to the problem of processes that take too much memory and block the 
other desktop applications.

Cheers,
Jos




-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20181217/72ec6789/attachment.sig>


More information about the kde-pim mailing list