This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] libelf: segment fault on x86-64 while file's bss offset have a large number


Apologies for the very late reply. And thanks for your example.
I can replicate your results, and there might indeed be some
problem seeing the file size increase. But I cannot replicate
the segment fault, nor do I see any errors with mmap/mmunmap.

On Fri, Oct 18, 2013 at 07:49:43PM +0800, Hongxu Jia wrote:
> 5) Run test_case with strace, there was mmap/munmap error.
> $ strace ./test_case 
> [...]
> open("test/xB.linkhuge", O_RDWR)        = 3
> fcntl(3, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
> fstat(3, {st_mode=S_IFREG|0755, st_size=1221403, ...}) = 0
> mmap(NULL, 1221403, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x7ff720fe2000
> fstat(3, {st_mode=S_IFREG|0755, st_size=1221403, ...}) = 0
> ftruncate(3, 2097152)                   = 0
> msync(0x7ff720fe2000, 1216568, MS_SYNC) = 0
> munmap(0x7ff720fe2000, 2097152)         = 0
> close(3)                                = 0
> exit_group(0)                           = ?

I see the same. So the file was indeed increased in size by the ftruncate
call. But it looks like mmap, msync and munmap all succeed (return zero)
just fine.

I think the example is too small to show the actual bug/error.

Your analysis seems correct, we mmap the original file size, then we
ftruncate to increase the file size, then msync and munmap with this
new size. Which seems to succeed, so I assume the ftruncate did also
extend the mapped size (but I cannot immediate find whether that is
really true). It does look something is a little odd here. But I cannot
immediately see the crash myself. Do you happen to have more examples
of this failure?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]