Repository navigation
emcmodule: retry the tool mmap attach in stat.poll() - #4658
Conversation
|
The real problem is that the progression is an effective race. |
|
Agreed. The launcher is racy: |
| snprintf(why, sizeof(why), "size %jd < %zu", | ||
| (intmax_t)st.st_size, (size_t)(TOOL_MMAP_SIZE)); |
There was a problem hiding this comment.
It should be safe to cast to size_t since most syscalls use that for file size (and ssize_t if errors are to be returned). Then you don't need intmax_t as it is unclear what size int actually is. However, off_t must encapsulate at least ssize_t or the syscall would no longer be 64-bit safe.
There was a problem hiding this comment.
Done, compared and printed as size_t; the intmax_t and <stdint.h> are gone.
|
Thanks a lot for fixing this! It was also the reason the other tests failed, probably due to the zero size I cherry-picked the commits in my branch, dropped the workaround and it works nicely. Except some other bugs from my PR... ;-) Just one thing: I would expect a 3. message: I had a hard time discriminating between errors and warnings in the CI logs. And it also took me some time to discover that |
|
Thanks for testing it. Added: after the first warning, |
The first stat.poll() in a process tried tool_mmap_user() once. If task had not created ~/.tool.mmap yet, a static flag latched and every later poll() returned NULL without setting an exception, so Python raised SystemError forever and a new linuxcnc.stat() did not help. A stale ~/.tool.mmap from an earlier run hid it; isolated test runs and a fresh HOME failed every time. Retry the attach on each poll until it succeeds and leave initialized at 0 meanwhile, so tool_table and toolinfo report no data instead of touching a NULL mapping. poll() warns once, and says when the mmap became available, so the warning does not read as a failure (hdiethelm asked for that after hunting the cause in CI logs). tool_mmap_user() warns once and names the file and the step that failed: open or fstat with the errno, or a file still shorter than the mapping. The creator truncates before extending, and mapping the file in that window would SIGBUS on first access, so a short file counts as absent. BsAtHome asked for the reason and the size_t comparison. Drop the drive.py comment that described the SystemError as normal startup noise. Fixes LinuxCNC#4656
c88ed53 to
83b5368
Compare
|
Correction to my earlier reply: I misread the startup order. task's |
Fixes #4656.
The first
stat.poll()in a process triedtool_mmap_user()once; if task had not created~/.tool.mmapyet, a static flag latched and every laterpoll()returned NULL without an exception (SystemErrorforever). ui-smoke polls before task is up, so isolated runs (#4648) failed withtask not ready within 60.0s.poll()retries the attach until it succeeds;initializedstays 0 meanwhile, sotool_table/toolinforeport no data. Correction to my issue comment: a NULL base is not safe intooldata_get()(it exits), which is why the gate stays.tool_mmap_user()warns once and treats a file shorter than the mapping as absent (creator truncates before extending; mapping it then would SIGBUS).Tested in a sandbox with a fresh HOME and no
~/.tool.mmap: ui-smoke axis fails on master with the issue's error and passes with this;tests/ui-smokeplustests/*tool*20/20. With this, thetouch $HOME/.tool.mmapin #4648 should not be needed.