-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linuxcncrsh segmentation faults on get/set spindle commands. #3180
Comments
Not sure what's broken but looking at some code in 'emcrsh.cc' that handles spindle it seems that it should handle multiple spindles:
|
a bunch of bugs in linuxcncrsh was fixed by daniel about a year ago. see 8b91f27, so using master should work (I just checked). we should really get rid of all C-style string handling ;-) |
Actual bugfixes should have gone into 2.9 |
I pulled the master and verified that RIP linuxcnc and linuxcncrsh run the following commands in the tests/linuxcncrsh-tcp/test.sh loop. (get/set spindle/brake/spindle-override segmentation fault does not occur with the RIP master when it did occur with the RIP 2.9.2 linuxcncrsh. echo hello EMC mt 1.0
Test.sh could be improved by saving the nc output from the commands to a file. At the end of the echo loop, I used: This would catch the results from all the commands as well as the M100 output including depreciated commands. I am not sure why "set spindle" complains about invalid state? localhost [127.0.0.1] 5007 (?) open |
Just tested and I get:
it seems that 'get spindle_override' always returns the last reply along the expected 'SPINDLE_OVERRIDE 0 ' |
This change seems to fix the bug with the extra reply to 'get spindle_override' but I'm not sure if there is a particular reason for using 'dprintf' :
I have filed a PR for this |
Just realized: |
I just tested RIP 2.9.3 and the issue does not occur. The mistake I made was reporting the issue when I was running RIP 2.9.2 followed up by missing the on in "set brake on". My apologies for not checking the latest code which had this issue fixed. I did learn quite a bit trying to figure this out and would like to use that to improve testing of the linuxcncrsh. The current test only covers "set mdi m100" commands. I have a linuxcncrsh-cmds directory that performs a minimal test of all linuxcncrsh commands, I would like to push this addition and close this issue. Does this sound appropriate? |
I spoke too soon. RIP 2.9.3 does NOT work correctly with get/set spindle/spindle_override/brake commands. (RIP Master is ok.) |
When I reported earlier that 2.9.3 worked, I was still running the Master. |
I was originally running RIP tag v2.9.2 and noticed the seg fault on any get/set spindle/spindle_override/brake command. |
are you really sure that is fixed? it looks like the out-of-bounds array access is still there. https://github.com/LinuxCNC/linuxcnc/blame/2.9/src/emc/usr_intf/emcrsh.cc#L1690 it seems linuxcncrsh is not used that much so potential for breakage seems low. Maybe it makes sense to backport the changes from 2.10. |
I opened the issue when I was testing basic commands on tag v2.9.2. tag v2.9.3 has the same issue, but branch 2.9 does not show the issue (for simple tests). It appears that because some probing tests were occasionally failing, the tests and fix did not get into the v2.9.3 tag??? (threw out the baby with the bathwater?) From #1690 there are probably more improvements needed. I agree that backporting linuxcncrsh improvements from 2.10 branch is probably the way to go. |
I still see a segfault with the latest 2.9, following your instructions:
I was planning to do a git bisect to see when it git fixed, and by what, but that's not so easy without a known-good tag and known-bad to work with. |
I just went through building and running test/linuxcncrsh/test.sh for tag v2.9.3, branch 2.9, and master. tag v2.9.3 and branch 2.9 will both seg fault if I add a "echo get brake" or "echo get spindle" line (missing spindle number) after the machine on. "echo get spindle 0" works fine with both. master (2.10.0~pre) has MUCH better testing (disabled by the skip file) The test fails on different PROGRAM_CODES but does not seg fault even when I add the "testGet spindle" equivalent to "echo get spindle" which crashes 2.9 and 2.9.3.
I am still confused by the way LCNC is branched and merged. When I look at the log for emcrsh.cc, I don't see why master works and 2.9 doesn't. It looks to me like Daniel Hiepler tested and fixed a bunch of the spindle/brake issues. Not sure why these are in the master and not 2.9. I do understand that some of the tests will return different values and flunk the test. In my case I see different PROGRAM_CODES than expected. It would be much better to disable specific tests that don't always return the same value (or refine the test) than to disable all the available testing in master. |
situation in 2.9: if you invoke "get spindle" without a number this line
will set I suggest we at least fix the segfaults, substituting |
We could easily default to spindle 0 if no spindle is given. |
I have been working on using LightBurn serial/TCP to communicate with the linuxcncrsh server and one of my first steps was extending tests/linuxcncrsh/test.sh to test all the commands to help me understand linuxcnc. Basically, I took the output from "help", "help get", and "help set" and added all the commands to test.sh. Doing this I discovered the get/set commands involving the spindle (brake, spindle, spindle_override) crash with a segmentation fault.
Here are the steps I follow to reproduce the issue:
This is what I expected to happen:
Script should execute and display spindle brake status.
This is what happened instead:
Segmentation fault when it hits the "get brake" command.
It worked properly before this:
Initially, I thought this issue was caused by the simulation not initializing a spindle.
halcmd getp spindle.0 brake verifies that a spindle is not initialized with the current test config.
Next, I added num_spindles=[TRAJ]SPINDLES to lib/hallib/core_sim.hal loadrt motmot line along with SPINDLES=1 in linuxcncrsh-test.ini and verified with halcmd that spindle.0 does exist, but "get spindle" still crashes.
Now, I suspect that emcrsh.cc was written prior to the multiple spindle implementation and these commands are no longer functional???
Information about my hardware and software:
I am using this Linux distribution and version : Debian GNU/Linux 12 (bookworm)
I am using this kernel version : Linux debian 6.1.0-17-rt-amd64 use Tcl_SetResult and Tcl_GetStringResult #1 SMP PREEMPT_RT Debian 6.1.69-1 (2023-12-30) x86_64 GNU/Linux
I am running ...
I am using this LinuxCNC version : 2.9.2
I am using this user interface (GUI) : linuxcncrsh (no other GUI)
I am using this interface hardware vendor and chipset : simulation
The text was updated successfully, but these errors were encountered: