bugGNU nano - Bugs: bug #54478, redoing any COUPLE_BEGIN/END...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #54478: redoing any COUPLE_BEGIN/END operation sets totsize to an invalid value

Submitter:  David Lawrence Ramsey <dolorous>
Submitted:  Thu 09 Aug 2018 01:55:03 AM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  dolorous Open/Closed:  Closed

Jump to the original submission

Mon 10 Sep 2018 05:51:03 PM UTC, comment #7: 

Released in 3.0.

Benno Schulenberg <bens>
Group administrator
Sat 11 Aug 2018 08:12:57 AM UTC, comment #6: 

Thanks for reporting and fixing this.  The fix looks like the perfect solution.  Pushed to master, commit fd65f744.

Benno Schulenberg <bens>
Group administrator
Thu 09 Aug 2018 06:12:36 AM UTC, comment #5: 

Took a stab at fixing it.  The patch is attached.

(file #44750)

David Lawrence Ramsey <dolorous>
Group Member
Thu 09 Aug 2018 03:55:39 AM UTC, comment #4: 

Forgot to update the mail notification again; fixed now.

David Lawrence Ramsey <dolorous>
Group Member
Thu 09 Aug 2018 03:53:14 AM UTC, comment #3: 

After tracing nano's undo and redo functions through gdb, when using COUPLE_BEGIN and COUPLE_END, in the undo struct, undo->newsize is never set to anything.  And do_redo() unconditionally assigns openfile->totsize the value of undo->newsize, so openfile->totsize is thus set to an uninitialized value.

Furthermore, undo->newsize is set only in update_multiline_undo(), update_undo(), and do_deletion().  The first of these is only used for commenting and indenting; the second of these is used by many functions, but COUPLE_BEGIN and COUPLE_END are not among them; and the third of these is used only for deleting and backspacing.

I'm uncertain where it should be properly set in order to fix this, however.

David Lawrence Ramsey <dolorous>
Group Member
Thu 09 Aug 2018 03:23:25 AM UTC, comment #2: 

(The second steps 2 and 3 in comment #1 should be 5 and 6.)

A similar problem also occurs when filtering text via the "Execute Command" menu.  This can be reproduced as follows:

1. Run:

src/nano -I spell-test.txt

2. Press ^W^Y to move the cursor to the top of the file.

3. Press ^^ to turn the mark on.

4. Press ^W^V to move the cursor to the end of the file.

5. Press ^R^X M-\, and type "wc" <Enter> at the prompt.  The text should be replaced with word count values "2 8 36".

6. Press M-U to undo the filtering, and then M-E to redo it. Then press Ctrl-C. The cursor position will be displayed as something like:

[ line 3/3 (100%), col 1/1 (100%), char 36/0 (0%) ]

The number is still not 36 when it should be.

----------

So all uses of COUPLE_BEGIN and COUPLE_END in the undo code apparently screw up the value of totsize when they're redone.  The bug description has been updated accordingly.

David Lawrence Ramsey <dolorous>
Group Member
Thu 09 Aug 2018 03:01:19 AM UTC, comment #1: 

A similar problem also occurs when running marked text through the alternate spell checker.  This can be reproduced as follows:

1. Run:

src/nano -I --speller="aspell -x -c" spell-test.txt

2. Press ^W^Y to move the cursor to the top of the file.

3. Press ^^ to turn the mark on.

4. Press ^W^V to move the cursor to the end of the file.

2. Press ^T, and use aspell to fix the two spelling errors ("thiss" and "ths" should both be "this").

3. Press M-U to undo the spell-check, and then M-E to redo it. Then press Ctrl-C. The cursor position will be displayed as something like:

[ line 3/3 (100%), col 1/1 (100%), char 36/0 (0%) ]

The number is still not 36 when it should be.

David Lawrence Ramsey <dolorous>
Group Member
Thu 09 Aug 2018 01:55:03 AM UTC, original submission:  

Currently, as of git 94b4f07, running an entire file through the alternate spell checker, and then undoing the spell check, sets the value of totsize to something completely out of range.  This can be reproduced as follows, assuming the system has aspell installed, and using the attached file spell-test.txt:

1. Run:

src/nano -I --speller="aspell -x -c" +2,2 spell-test.txt

2. Press ^T, and use aspell to fix the two spelling errors ("thiss" and "ths" should both be "this").

3. Press M-U to undo the spell-check, and then M-E to redo it.  Then press Ctrl-C.  The cursor position will be displayed as something like:

[ line 3/3 (100%), col 1/1 (100%), char 36/3410145515190571845 (0%) ]

The number may not be exactly that massive value, but it will not be 36 when it should be.

David Lawrence Ramsey <dolorous>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by dolorous
  • -email is unavailable- added by dolorous (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-10 bens Open/ClosedOpen Closed
    2018-08-11 bens Summaryundoing/redoing any COUPLE_BEGIN/COUPLE_END operation sets totsize to invalid value redoing any COUPLE_BEGIN/END operation sets totsize to an invalid value
    2018-08-11 bens StatusNone Fixed
        Assigned toNone dolorous
    2018-08-09 dolorous Attached File- Added 0001-undo-in-the-undo-struct-ensure-newsize-is-initialize.patch, #44750
    2018-08-09 dolorous Carbon-Copy- Added bens
    2018-08-09 dolorous Summaryundoing/redoing alternate spell-check sets totsize to out-of-range value undoing/redoing any COUPLE_BEGIN/COUPLE_END operation sets totsize to invalid value
    2018-08-09 dolorous Attached File- Added spell-test.txt, #44748

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code