A scrub only verifies data integrity and checksums. It does not repair corrupted allocation metadata, metaslabs, space maps, or range trees.
The panic you’re seeing (“removing nonexistent segment from range tree”) suggests an inconsistency in ZFS’ internal allocation structures rather than a problem with a specific file. The file error found during the scrub may be completely unrelated.
The fact that recovery mode still works is actually encouraging. Before attempting any further writes, I would try importing the pool read-only:
zpool import -N -o readonly=on
If that succeeds, run:
zpool status -v
zpool events -v
and note your exact OpenZFS version.
I would avoid deleting snapshots, running another scrub, resilvering, or making any other changes until you understand what’s causing the panic. If the issue is a metadata inconsistency, additional writes may make recovery harder.
Which OpenZFS version are you running, and does the pool import successfully in read-only mode?