dup_d2_single.3dm (8.1 KB)
dup_d0_control.3dm (8.2 KB)
Version: Rhino 8 SR32 (8.32.26160.13001); rhino3dm 8.32.2 (Python)
Not tested on later service releases (SR34/SR35 are available): I don’t have administrator rights on this machine and can’t update Rhino. If this no longer reproduces on a current build, please let me know.
How these keys occur in practice:
a file arrived with two keys whose stored UTF-16 contains NUL characters, Tim U+1765 U+0CC6 \0\0\0 ect\286. That is 9 bytes overwritten inside TimeSubject\286. The chunk CRC is valid, so the damaged bytes were written as-is by whatever saved the file. Neither API can create such a key: RhinoCommon SetString("NulSec\0Tail\7") and rhino3dm both store NulSec, cut off silently at the NUL.
Repro:
attached dup_d2_single.3dm (8 KB, 1 damaged key plus 6 normal ones) and dup_d0_control.3dm (identical, undamaged). Generator, which patches rhino3dm output and recomputes the chunk CRC:
import rhino3dm, struct, zlib
f = rhino3dm.File3dm(); f.Objects.AddPoint(0, 0, 0)
for i in range(6): f.Strings["Sec\\%d" % i] = "v%d" % i
k = "TimeSubject\\286"; f.Strings[k] = "Modelling"; f.Write("dup_d2_single.3dm", 8)
b = bytearray(open("dup_d2_single.3dm", "rb").read()); i = b.find(k.encode("utf-16-le"))
j = i
while not (b[j:j+4] == b"\x00\x80\x00\x40" and j + 12 <= i < j + 12 + struct.unpack_from("<q", b, j+4)[0]): j -= 1
ln = struct.unpack_from("<q", b, j+4)[0]
b[i+7:i+16] = bytes.fromhex("17c60c000000000000")
struct.pack_into("<I", b, j+12+ln-4, zlib.crc32(bytes(b[j+12:j+12+ln-4])) & 0xffffffff)
open("dup_d2_single.3dm", "wb").write(b)
Actual:
| Test | Result |
|---|---|
| Launch Rhino with the file | Panel area shows “‘Right Container’ Container is empty”; Panels.GetPanel returns null |
| Switch to the file from another doc, panel visible | First-chance System.NullReferenceException at Rhino.UI.ObjectProperties.UserStringItem.get_IsFunction(), wrapped in TargetInvocationException (2 of 2). Switch took 19 s against 4 s for the control (1 run each) |
| Same, panel hidden | No exception (1 of 1) |
| Control file, both ways | Panel shows all 8 rows |
GetKey(i) |
Returns the cut-off key Tim\u1765\u0CC6 |
GetValue(i) / GetValue(key) |
"" / null |
Delete(key), Delete(section, entry), SetString(key, null), each with the cut-off key and the full key including NULs |
Count unchanged |
rhino3dm Strings[key] / Strings.Delete(key) |
'' / no effect |
_-Audit3dmFile |
0 errors or warnings |
| Same file with the 9 bytes restored (same length, CRC recomputed) | Panel loads, delete works, save and reopen clean. The NUL is the only trigger. |
Seen once in 2 runs and not confirmed: after the switch Rhino was left with black viewports, no document name in the title, and the _-Open prompt still pending.
Analysis:
- Why the panel dies: keys cross into native code as NUL-terminated strings, so the stored key can’t be addressed.
LoadDocumentStringsbuilds each row fromGetValue(key), which returns null here.UserStringItem.IsFunctionthen dereferences the null value, and the panel never gets built. - No way to remove the entry: there is no
Delete(int), so nothing in Rhino, RhinoCommon or rhino3dm can remove it.
Suggested fixes:
- Panel: build rows from
GetValue(int), guardIsFunctionand the value against null, and catch errors per row so one bad entry can’t break the whole panel. - API: add index-based removal (
StringTable.Delete(int), and the same onFile3dmStringTable), and/or marshal keys with an explicit length. - Reading: detect embedded U+0000 in user-string keys on read (openNURBS) and report it in
Audit3dmFile. - Optional: warn instead of silently cutting the key off when
SetStringreceives a NUL.
Related: RH-97375 (open 8.x, null exception in the document-text grid, possibly the same family).