This bug has been present since 3.0.0. It affects the WiredTiger storage engine, but not the ephemeralForTest and mmapv1 storage engines.
838 long long avgObjSize = collection->dataSize(txn) / collection->numRecords(txn);
collection->numRecords() can return 0.