[systemd-devel] [PATCH] journal: Don't hold pointers to journal while remapping

Marti Raudsepp marti at juffo.org
Fri Mar 9 06:45:36 PST 2012


Hi!

I was trying out the journal and the journalctl utility sometimes
crashed on me. After some debugging, I tracked it down to the fact
that next_with_matches() holds the "c" object pointer through the
journal_file_next_entry_for_data() call -- which apparently may re-map
the journal file, invalidating the pointer.

The attached patch fixes this crash for me, but being unfamiliar with
the code, I don't know if I'm doing the right thing.

This patch is also available from my github repository:
git://github.com/intgr/systemd.git
https://github.com/intgr/systemd

Regards,
Marti

For the record, here's the original stack trace at the time of remapping:

#0 journal_file_move_to (f=0xbd7210, wt=3, offset=6414200, size=480,
ret=0x7fff1d5cdec0) at src/journal/journal-file.c:330
#1 journal_file_move_to_object (f=0xbd7210, type=3, offset=6414200,
ret=0x7fff1d5cdf28) at src/journal/journal-file.c:414
#2 generic_array_get (f=0xbd7210, first=69328, i=2546,
ret=0x7fff1d5ce0a0, offset=0x7fff1d5ce098) at
src/journal/journal-file.c:1101
#3 generic_array_get_plus_one (f=0xbd7210, extra=67744, first=69328,
i=5705, ret=0x7fff1d5ce0a0, offset=0x7fff1d5ce098) at
src/journal/journal-file.c:1147
#4 journal_file_next_entry_for_data (f=0xbd7210, o=0x7f7cc1c36d28,
p=6413608, data_offset=66600, direction=DIRECTION_DOWN,
ret=0x7fff1d5ce0a0, offset=0x7fff1d5ce098) at
src/journal/journal-file.c:1626
#5 next_with_matches (j=0xbc0010, f=0xbd7210,
direction=DIRECTION_DOWN, ret=0x7fff1d5ce120, offset=0x7fff1d5ce128)
at src/journal/sd-journal.c:533
#6 next_beyond_location (j=0xbc0010, f=0xbd7210,
direction=DIRECTION_DOWN, ret=0x7fff1d5ce170, offset=0x7fff1d5ce178)
at src/journal/sd-journal.c:595
#7 real_journal_next (j=0xbc0010, direction=DIRECTION_DOWN) at
src/journal/sd-journal.c:651
#8 sd_journal_next (j=0xbc0010) at src/journal/sd-journal.c:686
#9 main (argc=5, argv=0x7fff1d5ce308) at src/journal/journalctl.c:263
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-journal-Don-t-hold-pointers-to-journal-while-remappi.patch
Type: text/x-patch
Size: 1897 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20120309/124204ef/attachment.bin>


More information about the systemd-devel mailing list