-
Notifications
You must be signed in to change notification settings - Fork 178
VERIFY3_IMPL implementation is not robust #459
Comments
@avg-I yes this is definitely something of a known issue and I completely agree it can be confusing. The code was originally written this way for two reasons.
As long as we address these two concerns we could restructure this code. |
@behlendorf is the stack depth really of so much concern in this context? |
@avg-I unfortunately it is. Let's say we add 2 64-bit values to the macro, that can increase each stack frame where the macro is used by 16 bytes. We've observed that a worst case of roughly 50 stack frames isn't impossible in some of the deeper call paths coupled with entering direct memory reclaim. The works out to a rough worst case swag of an extra 800 bytes on the stack since we need to plan for the worst case. Most Linux kernels only have 8K stacks (~7K really) to work so this is 10% of the stack. And because ZFS can from a platform with bigger stacks we've already gone through a lot of effect to slim them down to stay under the limit. But there are call paths where we're still close. The good news is that about a year ago the upstream kernel changed the default stack size to 16K. But it will take some time before that changes works it way down in to all the distributions. |
I think that in most cases one of the values is a constant, so the estimate could be cut in half. |
It's definitely a high estimate but we are worried about the absolute worst case. We also need debug builds to be safe too so ASSERTs count! We could try explore this. I just wanted to be upfront about the not so obvious risks. |
The implementation in debug.h has an obvious C macro problem: it might evaluate its arguments more than once and that could lead to wrong values being printed if the arguments are not invariant or not idempotent.
Fortunately, this is only a problem with reporting. But that can be quite confusing when debugging a problem. For example in this issue you can see
which would imply that zero was not equal to zero.
I think that the macro should follow the pattern employed in zfs/assert.h
The text was updated successfully, but these errors were encountered: