dtrace-utils
dtrace-utils copied to clipboard
dtrace: could not enable tracing: BPF program load for '...' failed: No space left on device
A script like x = 1; @ = quantize(x); @ = quantize(x); [....97 similar lines...] @ = quantize(x); fails, printing about 16 Mbyte of BPF verifier log and ending in: dtrace: could not enable tracing: BPF program load for '...' failed: No space left on device
The BPF verifier walks code paths to ensure that BPF code that is run is safe. An action like quantize() must quantize values into one of 127 different bins, representing numerous possible code paths. This taxes the BPF verifier.
While that is in itself a challenge, the problem in this bug is unnecessary. A 16-Mbyte buffer is passed to the kernel, and the error is simply that the buffer we pass is too small.
One can imagine several fixes.
One is not to pass a buffer! The script in question would pass! Never passing a buffer, however, would mean that BPF verifier problems would never be reported.
Another is to pass a larger buffer, perhaps under user control.
A hybrid solution seems to make most sense. Try to load the BPF program without specifying a log buffer. If the load is successful, one is done. If there is a problem, retry the load, this time with a log buffer. If the error is ENOSPC, warn the user that a larger buffer is needed to capture the problem. Otherwise, simply just report the buffer.
Verified as fixed.