On 01/07/2014 03:37 PM, Laszlo Ersek wrote:
> comments below
> 
> On 01/05/14 08:27, Qiao Nuohan wrote:
>> functions are used to write page to vmcore. vmcore is written page by page.
>> page desc is used to store the information of a page, including a page's 
>> size,
>> offset, compression format, etc.
>>
>> +    uint64_t pfn_start, pfn_end, pfn;
>> +    unsigned char buf[s->page_size];
> 
> Whoa, a VLA! :) I believe it's *very* non-idiomatic in the qemu source.
> Please consider allocating it dynamically. (Of course others might point
> out that I'm wrong.)
Worse, a stack allocation greater than the size of a stack frame.  Any
time you have a function taking more than a page size of local storage,
you risk nasty behavior on some platforms (Windows in particular is
notorious for giving you only a single guard page, and if you overflow
the stack by more than the guard page, your program is unceremoniously
terminated with no message, compared to the usual desirable behavior of
getting a SIGSEGV that your program can at least react to in order to
diagnose that you had a stack overflow).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to