On 2014-08-11 14:31:08 [-0400], Jérémie Galarneau wrote:
> It seems you don't have the following patch applied:
> 
> commit 6a0b6cd5133db9e3c72914d4e5dd7fc792360934
> Author: Mathieu Desnoyers <[email protected]>
> Date:   Wed Jul 16 10:58:48 2014 -0400
> 
>     Fix: don't perform unaligned integer read/writes
> 
>     Signed-off-by: Mathieu Desnoyers <[email protected]>
> 
> I may be misunderstanding here, but we don't read floats directly in a
> trace. We basically use the ctf_integer_read functions, as you can see
> in _ctf_float_copy() in formats/ctf/types/floats.c
> 
> That patch should ensure the accesses are always aligned (see the use
> of memcpy).
> 
> Have you spotted a place where an unaligned float access is performed?

No, this is all good. I *assumed* that you also do double handling that
way and therefore suggested use an alignment of 8. If you don't then it
is all good.

> > And the second bug I stumbled on is in test_ctf_writer:
> > |…
> > |ok 75 - Flush trace stream with one event
> > |ok 76 - Add a new event class to a stream class after writing an event
> > |ok 77 - Append 100 000 events to a stream
> > |
> > |Program received signal SIGSEGV, Segmentation fault.
> > |0xf7f6f778 in ctf_integer_write (ppos=0x70022328, definition=<optimized 
> > out>) at integer.c:325
> > |325                             
> > bt_bitfield_write_be(mmap_align_addr(pos->base_mma) +
> > |(gdb) bt
> > |#0  0xf7f6f778 in ctf_integer_write (ppos=0x70022328, 
> > definition=<optimized out>) at integer.c:325
> > |#1  0xf7f88014 in bt_ctf_field_integer_serialize (field=0x700cd928, 
> > pos=0x70022328) at event-fields.c:1065
> > |#2  0xf7f88c88 in bt_ctf_field_serialize (field=0x700cd928, 
> > pos=0x70022328) at event-fields.c:660
> > |#3  0xf7f88f10 in bt_ctf_field_structure_serialize (field=0x700cd8c8, 
> > pos=0x70022328) at event-fields.c:1143
> > |#4  0xf7f88c88 in bt_ctf_field_serialize (field=0x700cd8c8, 
> > pos=0x70022328) at event-fields.c:660
> > |#5  0xf7f857bc in bt_ctf_stream_flush (stream=0x70022310) at stream.c:458
> > |#6  0x7000577c in packet_resize_test (stream_class=<optimized out>, 
> > stream=0x70022310, clock=0x70022108) at test_ctf_writer.c:698
> > |#7  0x70002750 in main (argc=<optimized out>, argv=0xffffd6f4) at 
> > test_ctf_writer.c:818
> > |
> > |=> 0xf7f6f778 <+600>:   ldub  [ %l3 + %l1 ], %g4
> > |
> > |l1             0x10002  65538
> > |l3             0xf7bb4000       -138723328
> >
> > and _bt_bitfield_write_le() had __ptr = 0xf7bb4000 and this_unit = 65538
> >
> > |(gdb) print *((struct ctf_stream_pos *)ppos)->base_mma
> > |$3 = {page_aligned_addr = 0xf7bb4000, page_aligned_length = 131072, addr = 
> > 0xf7bb4000, length = 131072}
> >
> > So it looks like it tried to load a byte from 0xf7bb4000 + 0x10002 and
> > this segfaulted. The mapping should be 131072 bytes in size it should
> > fit. This is confirmed by proc, too
> > |f7bb0000-f7bd0000 -w-s 00010000 fe:02 262357 
> > /tmp/ctfwriter_5uYQD4/test_stream_0
> > |Size:                128 kB
> >
> > So everything looks legal…
> >
> 
> Thanks for looking into this! Any idea what could cause this to fail?

Not really. What I learnt is that you extend file's size with fallocate()
and then mmap() it for writing. The area that you write is covered by the
mmap() and file so it should be fine.
I try later to extract a minimal testcase out of it or replace it with
write() and see how that goes.

> Jérémie
 
Sebastian


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to