继续按提示词推进:补tooldata mmap单创建者覆盖

This commit is contained in:
cnc
2026-06-05 09:51:37 +08:00
parent 440a61be32
commit 6506d23dc2
4 changed files with 32 additions and 0 deletions

View File

@@ -48,6 +48,10 @@ grep -F 'int tool_mmap_creator(EMC_TOOL_STAT const * ptr,int random_toolchanger)
"$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null
grep -F 'static int inited=0;' \ grep -F 'static int inited=0;' \
"$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null
grep -F 'if (inited) {' \
"$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null
grep -F 'inited = 1;' \
"$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null
grep -F 'hptr->is_random_toolchanger = random_toolchanger;' \ grep -F 'hptr->is_random_toolchanger = random_toolchanger;' \
"$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null
grep -F 'hptr->last_index = 0;' \ grep -F 'hptr->last_index = 0;' \
@@ -106,6 +110,8 @@ grep -F '`src/emc/tooldata/tool_mmap_read.cc` is the mmap tool table reader util
docs/linuxcnc-tooldata-source-map.md >/dev/null docs/linuxcnc-tooldata-source-map.md >/dev/null
grep -F '`tool_mmap_user()`, `tooldata_last_index_get()`, and `tooldata_get()`' \ grep -F '`tool_mmap_user()`, `tooldata_last_index_get()`, and `tooldata_get()`' \
docs/linuxcnc-tooldata-source-map.md >/dev/null docs/linuxcnc-tooldata-source-map.md >/dev/null
grep -F "single-creator process boundary from" docs/linuxcnc-tooldata-source-map.md >/dev/null
grep -F "including after" docs/linuxcnc-tooldata-source-map.md >/dev/null
grep -F '`src/emc/tooldata/tool_watch.cc` is the NML/mmap tool table watcher utility' \ grep -F '`src/emc/tooldata/tool_watch.cc` is the NML/mmap tool table watcher utility' \
docs/linuxcnc-tooldata-source-map.md >/dev/null docs/linuxcnc-tooldata-source-map.md >/dev/null
grep -F '`EMC_STAT::io.tool` fields through `RCS_STAT_CHANNEL`' \ grep -F '`EMC_STAT::io.tool` fields through `RCS_STAT_CHANNEL`' \
@@ -191,6 +197,10 @@ grep -F 'tooldata_db_init(too_many_db_args, 1) != -1' \
core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null
grep -F 'tooldata_db_init(non_db_program, 1) != -1' \ grep -F 'tooldata_db_init(non_db_program, 1) != -1' \
core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null
grep -F 'tool_mmap_creator(nullptr, 1);' \
core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null
grep -F 'WEXITSTATUS(recreate_status) == 0' \
core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null
grep -F 'core/wasm_shims/tooldata/tooldata_mmap_backend.cc' docs/linuxcnc-wasm-shims-source-map.md >/dev/null grep -F 'core/wasm_shims/tooldata/tooldata_mmap_backend.cc' docs/linuxcnc-wasm-shims-source-map.md >/dev/null
grep -F 'core/wasm_shims/tooldata/tooldata_runtime_stubs.cc' docs/linuxcnc-wasm-shims-source-map.md >/dev/null grep -F 'core/wasm_shims/tooldata/tooldata_runtime_stubs.cc' docs/linuxcnc-wasm-shims-source-map.md >/dev/null
@@ -205,6 +215,8 @@ grep -F 'LinuxCNC source basis: this probe compares wasm-safe tooldata runtime s
grep -F '!!!!db_init: argc exceeds MAX_DB_PROGRAM_ARGS=10' \ grep -F '!!!!db_init: argc exceeds MAX_DB_PROGRAM_ARGS=10' \
test-linuxcnc-wasm-tooldata-link.sh >/dev/null test-linuxcnc-wasm-tooldata-link.sh >/dev/null
grep -F 'not executable' test-linuxcnc-wasm-tooldata-link.sh >/dev/null grep -F 'not executable' test-linuxcnc-wasm-tooldata-link.sh >/dev/null
grep -F 'Error: tool_mmap_creator already called BYE' \
test-linuxcnc-wasm-tooldata-link.sh >/dev/null
grep -F 'run_parallel_wasm_probe "LinuxCNC wasm tooldata shim link probe" ./test-linuxcnc-wasm-tooldata-link.sh' \ grep -F 'run_parallel_wasm_probe "LinuxCNC wasm tooldata shim link probe" ./test-linuxcnc-wasm-tooldata-link.sh' \
build-wasm.sh >/dev/null build-wasm.sh >/dev/null
grep -F 'run_parallel_wasm_probe "LinuxCNC wasm tooldata_common link probe" ./test-linuxcnc-wasm-tooldata-common-link.sh' \ grep -F 'run_parallel_wasm_probe "LinuxCNC wasm tooldata_common link probe" ./test-linuxcnc-wasm-tooldata-common-link.sh' \

View File

@@ -350,5 +350,21 @@ int main() {
return 39; return 39;
} }
const pid_t recreate_child = fork();
if (recreate_child < 0) {
return 60;
}
if (recreate_child == 0) {
tool_mmap_creator(nullptr, 1);
_exit(61);
}
int recreate_status = 0;
if (waitpid(recreate_child, &recreate_status, 0) != recreate_child) {
return 62;
}
if (!WIFEXITED(recreate_status) || WEXITSTATUS(recreate_status) == 0) {
return 63;
}
return 0; return 0;
} }

View File

@@ -58,6 +58,9 @@ source-link/shim guard only; it must not add CNC behavior and must not expand th
- The mmap backend must keep the LinuxCNC random-toolchanger flag and - The mmap backend must keep the LinuxCNC random-toolchanger flag and
`last_index` initialization edges from `tool_mmap_creator()`, and `last_index` initialization edges from `tool_mmap_creator()`, and
`tooldata_last_index_get()` must preserve the last-index unavailable return. `tooldata_last_index_get()` must preserve the last-index unavailable return.
- The mmap backend must keep LinuxCNC's single-creator process boundary from
the `static inited` guard in `tool_mmap_creator()`, including after
`tool_mmap_close()` clears browser-safe in-memory state.
- `tool_mmap_user()` must keep LinuxCNC's unavailable mmap failure boundary, - `tool_mmap_user()` must keep LinuxCNC's unavailable mmap failure boundary,
and `tool_mmap_close()` must clear the browser-safe in-memory state without and `tool_mmap_close()` must clear the browser-safe in-memory state without
adding filesystem mmap behavior. adding filesystem mmap behavior.

View File

@@ -11,6 +11,7 @@ probe=$(./build-linuxcnc-wasm-standalone-probe.sh --mode tooldata-link)
"$probe" 2>"$probe.err" "$probe" 2>"$probe.err"
grep -F "tool_mmap_user(): tool mmap not available" "$probe.err" >/dev/null grep -F "tool_mmap_user(): tool mmap not available" "$probe.err" >/dev/null
grep -F "tooldata_put() no tool_mmap_base" "$probe.err" >/dev/null grep -F "tooldata_put() no tool_mmap_base" "$probe.err" >/dev/null
grep -F "Error: tool_mmap_creator already called BYE" "$probe.err" >/dev/null
grep -F "!!!PROBLEM tool_nml_register()" "$probe.err" >/dev/null grep -F "!!!PROBLEM tool_nml_register()" "$probe.err" >/dev/null
grep -F "!!!!db_init: <" "$probe.err" >/dev/null grep -F "!!!!db_init: <" "$probe.err" >/dev/null
grep -F "not executable" "$probe.err" >/dev/null grep -F "not executable" "$probe.err" >/dev/null