bugGNU nano - Bugs: bug #51124, nano segfaults when foregrounded...

 
 

bug #51124: nano segfaults when foregrounded after a SIGTSTP

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Fri 26 May 2017 05:43:50 PM UTC  
 
Severity: 4 - ImportantStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Wed 31 May 2017 01:13:49 PM UTC, comment #7:

Apparenly it is not a good idea to call regenerate_screen() when a signal occurs. Faking a SIGWINCH instead avoids the segfault and the fake SIGHUP/SIGTERM -- it is not a HUP or TERM at all: it is the input routine giving up when it gets too many errors in a row. Argh! The error message should have said that, instead of saying something completely false.

Fixed in git, the first part, a969adf8, and the second part, a2038a9b.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 30 May 2017 07:51:48 PM UTC, comment #6:

It seems to depend on the compilation, on the boot, and on the exact position of the cursor. On a Xubuntu Zesty (ncurses-6.0+20161625) and on an old Ubuntu Lucid (ncurses-5.7), doing a 'src/nano --suspend +1 NEWS', a kill -SIGTSTP and a fg, will cause a SIGHUP/SIGTERM when using the attached "bad" nanorc. And they will work fine (apart from bug #51131) when there is no nanorc at all. On an up-to-date Manjaro, though, (ncurses-6.0+20170429) it is the other way around: without any nanorc it will SIGHUP/SIGTERM, and with the "bad" nanorc (or my normal nanorc) it will work fine.

Another bisect had brought me to 5283acdc, and when I changed

converted[index] = '\0';

back to

null_at(&converted, index);

the SIGHUP/SIGTERM was avoided on Zesty and Lucid. But it triggered the SIGHUP/SIGTERM on Manjaro. :| But upon a new boot, Manjaro seems to behave more like Zesty and Lucid: the null_at() seems to avoid the SIGHUP/SIGTERM in some situations.

There's something wrong underwater...

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 28 May 2017 06:37:07 PM UTC, comment #5:

In my current situation, 2.7.5 can still be foregrounded fine (apart from the cursor being misplaced -- see bug #51131), but foregrounding 2.8.0 (after a SIGTSTP) will result in a SIGHUP/SIGTERM. Weird. Also, after a recent bootup, I do not need any nanorc at all to make a 2.8.4 segfault upon foregrounding (after a SIGTSTP -- using an in-nano ^Z and then a fg works fine).

Attached is a backtrace. It seems that the suspending messes up some data within ncurses.

(file #40805)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 28 May 2017 12:06:02 PM UTC, comment #4:

Another bisect brings me again to 4c566c79. This is ridiculous.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 28 May 2017 12:00:15 PM UTC, comment #3:

I must have done something wrong during bisecting between 2.6.1. and 2.6.2, because the commit that triggers the HUP/TERM is 6f12992c (the addition of option '--wordchars'). It is not fully reproducible, though -- it seems to depend on the compilation.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 26 May 2017 07:08:36 PM UTC, comment #2:

Attached diff is enough to avoid the segfault. But then we would be back to the stutter (sometimes) when switching between buffers when linenumbers are on. That's not what we want.

So... we can probably get away with doing an extra edit_refresh just once, before entering the main loop. See attached patch. This avoids the segfault too.

Okay. That leaves us with the SIGHUP/SIGTERM. Fixing that will hopefully avoid the segfault altogether.

(file #40797, file #40798)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 26 May 2017 06:21:08 PM UTC, comment #1:

(Forgot to attach the file. Attached now.)

The offending commit between 2.6.1 and 2.6.2 (about getting the SIGHUP/SIGTERM) is 4c566c79.

The offending commit between 2.8.1 and 2.8.2 (the segfault) is 3275c4e5.

(file #40795)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 26 May 2017 05:43:50 PM UTC, original submission:

This is hard to reproduce. Attached is the smallest .nanorc I have been able to reproduce it with so far. Move your /etc/nanorc and ~/.nanorc out of the way, and then copy the attached NNRC to ~/.nanorc. Then run:

src/nano --suspend NEWS

Then, in another terminal:

kill -SIGTSTP $(pidof nano)

Then in the first terminal:

fg

The whole screen is repainted, and then nano segfaults while the cursor is on the status bar.

Bug exists since nano-2.8.2. (From 2.6.2 to 2.8.1, instead of segfaulting, nano will simply exit with the report that it has received a SIGHUP or SIGTERM. In nano-2.6.1 and before, sending a SIGTSTP plus foregrounding worked fine.)

(Possibly this bug exists only on my old system. I will check later on a newer one.)

(Using the file NEWS is relevant, because using the README file instead, will just result in the HUP/TERM.)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #40805:  BT1 added by bens (629B - application/octet-stream)
file #40797:  avoid-segfault.diff added by bens (276B - text/x-diff)
file #40798:  draw-content-first.patch added by bens (366B - text/x-diff)
file #40795:  NNRC added by bens (547B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bens (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 26 Jun 2017 08:21:37 AM UTCbensOpen/ClosedOpen=>Closed
    Wed 31 May 2017 01:13:49 PM UTCbensSeverity3 - Normal=>4 - Important
      StatusNone=>Fixed
      Assigned toNone=>bens
    Sun 28 May 2017 06:37:07 PM UTCbensAttached File-=>Added BT1, #40805
    Fri 26 May 2017 07:08:36 PM UTCbensAttached File-=>Added avoid-segfault.diff, #40797
      Attached File-=>Added draw-content-first.patch, #40798
    Fri 26 May 2017 06:21:08 PM UTCbensAttached File-=>Added NNRC, #40795

    Back to the top


    Powered by Savane 3.1-cleanup1