{"record":{"id":"96e8a1e7b34b349c","repo":"niri-wm/niri","slug":"unknown-data-type-in-dequeue-buffer-and-clear","errorCode":null,"errorMessage":"unknown data type in dequeue_buffer_and_clear","messagePattern":"unknown data type in dequeue_buffer_and_clear","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/screencasting/pw_utils.rs","lineNumber":1367,"sourceCode":"        unsafe {\n            let spa_buffer = (*buffer).buffer;\n\n            if self.cursor_mode == CursorMode::Metadata {\n                add_invisible_cursor(spa_buffer);\n            }\n\n            let fd = (*(*spa_buffer).datas).fd;\n\n            let res = match (*(*(*buffer).buffer).datas).type_ {\n                x if x == DataType::DmaBuf.as_raw() => {\n                    let dmabuf = self.inner.borrow().dmabufs[&fd].clone();\n                    clear_dmabuf(renderer, dmabuf).map(|x| (x, SharingBuf::Dma))\n                }\n                x if x == DataType::MemFd.as_raw() => {\n                    let shmbuf = self.inner.borrow().shmbufs[&fd].clone();\n                    clear_shmbuf(&shmbuf).map(|()| (SyncPoint::signaled(), SharingBuf::Shm(shmbuf)))\n                }\n                _ => Err(anyhow::anyhow!(\n                    \"unknown data type in dequeue_buffer_and_clear\"\n                )),\n            };\n\n            match res {\n                Ok((sync_point, buf)) => {\n                    mark_buffer_as_good(pw_buffer, &mut self.sequence_counter, buf);\n                    trace!(\"queueing clear buffer with seq={}\", self.sequence_counter);\n                    self.queue_after_sync(pw_buffer, sync_point);\n                    true\n                }\n                Err(err) => {\n                    warn!(\"error clearing buffer: {err:?}\");\n                    return_unused_buffer(&self.stream, pw_buffer);\n                    false\n                }\n            }\n        }","sourceCodeStart":1349,"sourceCodeEnd":1385,"githubUrl":"https://github.com/niri-wm/niri/blob/62c230a662ac913a54fc49c86fda0406da3f3ba9/src/screencasting/pw_utils.rs#L1349-L1385","documentation":"dequeue_buffer_and_clear mirrors dequeue_buffer_and_render: it dispatches on the buffer's DataType to clear either a DMA-BUF or a MemFd SHM buffer. An unrecognized raw DataType falls into the catch-all and errors, meaning the buffer cannot be cleared and would be returned to the stream in an inconsistent state.","triggerScenarios":"A queued stream buffer carrying a DataType raw value outside the handled Dma/MemFd set when the buffer is dequeued for clearing before reuse.","commonSituations":"Pipewire negotiating a buffer type this build does not handle; internal state corruption where a buffer was registered without a proper DataType; partially supported datatype added in a newer pipewire version.","solutions":["Add a handler arm for the unknown DataType or normalize buffer registration to only Dma/MemFd","Log the offending raw DataType value at registration time to catch it in add_buffer","Verify pipewire version compatibility with the supported DataType set"],"exampleFix":"// before\n_ => Err(anyhow::anyhow!(\"unknown data type in dequeue_buffer_and_clear\")),\n// after\n_ => {\n    warn!(\"unknown data type {x}; treating as already clear\");\n    Ok((SyncPoint::signaled(), SharingBuf::Shm(shmbuf_default)))\n}","handlingStrategy":"type-guard","validationCode":"if supported_data_type(buf.data_type).is_none() {\n    // destroy/requeue the buffer; it can never be cleared or rendered\n}","typeGuard":"fn clearable(raw: u32) -> bool {\n    raw == DataType::Dma.as_raw() || raw == DataType::MemFd.as_raw()\n}","tryCatchPattern":"match dequeue_buffer_and_clear(...) {\n    Err(e) if e.to_string().contains(\"unknown data type\") => {\n        // treat buffer as unusable: drop and let the stream reallocate\n    }\n    other => other?,\n}","preventionTips":["Only register buffers whose DataType is in the supported set","Add a registration-time assertion/logging for unrecognized DataType raw values","Share one exhaustive match helper between render and clear paths"],"tags":["pipewire","screencast","data-type"],"backgroundTag":"invalid-enum-value","analyzedSha":"62c230a662ac913a54fc49c86fda0406da3f3ba9","analyzedAt":"2026-09-19T19:48:44.526Z","contentChangedAt":"2026-09-19T19:48:44.526Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}