dtrace-utils icon indicating copy to clipboard operation
dtrace-utils copied to clipboard

dtrace: could not enable tracing: BPF program load for '...' failed: No space left on device

Open euloh opened this issue 4 years ago • 2 comments

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

euloh avatar Jan 08 '21 20:01 euloh

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.

euloh avatar Jan 08 '21 20:01 euloh

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.

euloh avatar Jan 08 '21 20:01 euloh

Verified as fixed.

kvanhees avatar Mar 31 '23 18:03 kvanhees