Description of problem:
Coverity reports STACK_USE error at qemu-kvm-x86.c:1546
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. make -C redhat rh-test-patch then
2. make -C redhat rh-brew-covscan then
3. review patch results.
A Coverity error appears, looking like this:
Error: STACK_USE: [#def12]
Local variable "copy" uses 57376 bytes of stack space,
which exceeds the maximum single use of 10000 bytes.
No Coverity error.
The line in question was introduced by commit 3e7e951d way back in 2007. I believe a newer version of Coverity was recently installed, and that is why this error hasn't been reported before.
The actual line reported by Coverity may be different than 1546. The error occurs in routine kvm_arch_init_vcpu(CPUState *cenv). The code leading up to and including the line with the error looks like:
int kvm_arch_init_vcpu(CPUState *cenv)
struct kvm_cpuid_entry2 cpuid_ent;
struct kvm_cpuid_entry2 *c;
struct kvm_cpuid_entry2 *pv_ent;
int cpuid_nent = 0;
---> CPUState copy;
The 10000 bytes limit seems arbitrary, what's the reason for that limit?
Using 57k of the stack in a single function is not nice, but that's code in the initialization path which runs only once for each VCPU, so I don't see any potential for trouble.
Does anybody have any argument for treating this as a real bug and not closing this BZ as NOTABUG?
(In reply to Eduardo Habkost from comment #2)
> The 10000 bytes limit seems arbitrary, what's the reason for that limit?
> Using 57k of the stack in a single function is not nice, but that's code in
> the initialization path which runs only once for each VCPU, so I don't see
> any potential for trouble.
> Does anybody have any argument for treating this as a real bug and not
> closing this BZ as NOTABUG?
Any function that uses more than 4k of stack risks missing the guard page that the OS uses to auto-grow the stack, which can lead to all sorts of obscure behavior. It would be nice if upstream qemu could take a leaf from libvirt and be fixed to compile with -Wframe-larger-than=4096.