fix(interp): don't fseek(NULL) on M99 in MDI#4095
Open
grandixximo wants to merge 1 commit into
Open
Conversation
Task always enables loop_on_main_m99, so M99 entered as an MDI command took the Fanuc endless-loop branch in convert_stop() and called loop_to_beginning() -> fseek(settings->file_pointer, ...). In MDI no file is open, so file_pointer is NULL and milltask crashed with SIGSEGV. Require file_pointer != NULL for the loop branch; otherwise MDI M99 now falls through to the M2/M30 program-end path (already NULL-guarded). Add a defensive NULL check in loop_to_beginning() as well. Fixes LinuxCNC#4094
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Entering
M99as an MDI command crashesmilltaskwith SIGSEGV. Gmoccapy and QTdragon die; AXIS happens to survive. Reported in #4094.Backtrace:
Cause
Task always enables
loop_on_main_m99(emctask.cc), soM99in the main program takes the Fanuc endless-loop branch inconvert_stop(), which callsloop_to_beginning()->fseek(settings->file_pointer, 0, SEEK_SET). In MDI there is no open g-code file, sofile_pointerisNULLandfseek(NULL)segfaults.Fix
file_pointer != NULLto take the M99 loop branch. In MDI,M99now falls through to the existingM2/M30program-end path, which already null-guardsfile_pointer. This matches AXIS-style "end" behavior.NULLcheck inloop_to_beginning().Testing
Built against current master. Verified on Gmoccapy:
M99in MDI no longer crashes.Fixes #4094