一键导入
fix-julia-nullptr-check
Julia C API bindings must check for nullptr return — silent failure otherwise
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Julia C API bindings must check for nullptr return — silent failure otherwise
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | fix-julia-nullptr-check |
| description | Julia C API bindings must check for nullptr return — silent failure otherwise |
| source | auto-skill |
| extracted_at | 2026-06-07T01:46:20.559Z |
The C API wrappers in insight_julia_capi.cpp catch exceptions and return
nullptr on error. But the Julia bindings in Insight.jl don't check for
C_NULL — they just wrap the nullptr in an InsightArray and return it.
This causes silent failures: the function appears to succeed but returns a broken array that segfaults or produces garbage on use.
Symptom: No error message, just wrong results or segfaults later.
// C API — catches exception, returns nullptr
Array *insight_jl_reshape(const Array *x, const int64_t *dims, int32_t ndim) {
try {
Shape shape(std::vector<int64_t>(dims, dims + ndim));
return new Array(x->reshape(shape));
} catch (...) {
return nullptr;
}
}
# ❌ WRONG — no nullptr check
function reshape(x::InsightArray, dims::Vector{Int64})::InsightArray
ptr = ccall((:insight_jl_reshape, LIB_INSIGHT), Ptr{Cvoid},
(Ptr{Cvoid}, Ptr{Int64}, Int32),
x, dims, Int32(length(dims)))
arr = InsightArray(ptr)
finalizer(_free, arr)
return arr
end
# ✅ CORRECT — check for nullptr
function reshape(x::InsightArray, dims::Vector{Int64})::InsightArray
ptr = ccall((:insight_jl_reshape, LIB_INSIGHT), Ptr{Cvoid},
(Ptr{Cvoid}, Ptr{Int64}, Int32),
x, dims, Int32(length(dims)))
if ptr == C_NULL
error("reshape failed: invalid dimensions")
end
arr = InsightArray(ptr)
finalizer(_free, arr)
return arr
end
# Error case should throw, not silently fail
try
Insight.reshape(a, Int64[-1, -1])
check("reshape_err_multi_neg1", false) # should not reach here
catch
check("reshape_err_multi_neg1", true)
end
bindings/julia/insight_julia_capi.cpp — C API wrappers (return nullptr on error)bindings/julia/src/Insight.jl — Julia bindings (must check C_NULL)bindings/julia/Insight.jl — old copy (keep in sync)Add device information query functions through HAL → ins:: API → language bindings
Add --device all/--timer/--info CLI flags to demos across all languages for competition scoring
Add composite signal operators using existing primitives (no dedicated backend kernels needed)
How to port a cusignal Python/CUDA module to ins::signal C++ using Insight7 primitives and HAL
Profile and optimize binding language (Lua/Julia/Python) demo performance to match or exceed C++ baseline
busted loads _insight.so from ~/.luarocks/lib first, not build/ — must copy .so after rebuild