Comment 20 for bug 849414

Revision history for this message
James Hunt (jamesodhunt) wrote :

Looking at ply_event_loop_process_pending_events(), what stands out is the call to alloca(3) which is used to allocated a fixed size chunk of storage (and have it automatically freed on function exit). Use of alloca() is not recommended for a number of reasons. Note too that the result of the call to alloca() is not checked.

The man page for alloca(3) claims that this function allocates storage on the stack. However, I think the plymouth build is using gcc's internal implementation of alloca() which *doesn't* use the stack - it uses malloc(3) (some levels down). Presumably the reason for using alloca() was performance, but since the gcc implementation uses malloc(), that isn't really a gain now. Note that gccs internal implementation could be inlined (hence wouldn't appear on the stack trace), and also calls abort() on error (which will generate a SIGSEGV as is being seen by users).

 I've spun up a modified version of plymouth using a static array (since there doesn't appear to be any advantage in using dynamic memory allocation in this case AFAIKS). The updated packages are in my ikb ppa if anyone is feeling brave:

  https://launchpad.net/~jamesodhunt/+archive/ikb/

If this does fix the problem we still need to understand what is consuming all the memory. Maybe a bug with the alloca() implementation in the gcc-4.6?