[systemd-devel] [PATCH] journalctl: Fix --list-boots and --boot

Jan Janssen medhefgo at web.de
Sun Aug 31 06:41:28 PDT 2014



On 2014-08-31 15:32, Zbigniew Jędrzejewski-Szmek wrote:
> On Sun, Aug 31, 2014 at 10:47:25AM +0200, Jan Janssen wrote:
>>
>>
>> On 2014-08-30 23:46, Zbigniew Jędrzejewski-Szmek wrote:
>>> On Fri, Aug 29, 2014 at 06:11:35PM +0200, Jan Janssen wrote:
>>>> For some reason, sd_journal_query_unique() and sd_journal_add_match() 
don't
>>>> work as they used to. There's a chance boots will be skipped; in my
>>>> case only 60 of 393 boots show up. Therefore, do 
sd_journal_query_unique() first
>>>> and then iterate over those to query their timespec.
>>> We should fix the underlying problem, since query_unique and add_match 
weren't
>>> supposed to change at all. Looking at the journal client code has been on 
my
>>> TODO list for a long while...
>>
>> You're probably right, but at the same time I wonder if interleaving
>> query_unique and normal journal matching should be allowed/supported
>> in the first place...
> Manual page says "Note that these functions currently are not
> influenced by matches set with sd_journal_add_match() but this
> might change in a later version of this software." so it should
> do something meaningful.
>
> Zbyszek

Hence why I would argue to do these queries sequentially, like in this 
patch. It certainly doesn't add any extra complexity, but would future proof 
things if they are changed (intentionally).

But either way, I identified the offending commit:
ae97089d49d1795a35a443b7b830ee666028e733 is the first bad commit
commit ae97089d49d1795a35a443b7b830ee666028e733
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Dec 28 19:33:23 2013 -0500

    journal: fix access to munmapped memory in sd_journal_enumerate_unique
    
    sd_j_e_u needs to keep a reference to an object while comparing it
    with possibly duplicate objects in other files. Because the size of
    mmap cache is limited, with enough files and object to compare to,
    at some point the object being compared would be munmapped, resulting
    in a segmentation fault.
    
    Fix this issue by turning keep_always into a reference count that can
    be increased and decreased. Other callers which set keep_always=true
    are unmodified: their references are never released but are ignored
    when the whole file is closed, which happens at some point. keep_always
    is increased in sd_j_e_u and later on released.

:040000 040000 cd360868b7f8c20a484f7267f0be20983255bbfe 
136b75a43d8d0200c8f2bae955314b12701ccb55 M      src

Jan


More information about the systemd-devel mailing list