bugGNU nano - Bugs: bug #47659, the commit "Avoiding the loss...

 
 

bug #47659: the commit "Avoiding the loss a buffer when getcwd() fails" causes a hang on Android

Submitted by:  None
Submitted on:  Sun 10 Apr 2016 11:47:03 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)

Fri 15 Apr 2016 11:59:57 AM UTC, comment #8:

On second thought, we don't want to just skip chdir'ing back up the tree, because very likely one or two chdir("..") will bring us back into inhabited country. Also, not doing these chdirs would make nano behave differently: when the current directory is gone, it will complain that it can't write a lock file, but after editing, it will happily write the file out to the parent dir. If we don't do the chdir, we can't write out the file, which is frustrating, and trying then to invoke the file browser just produces a beep. Frustrating and annoying. So the chdir'ing has to stay. (Although writing out the file to some other dir than what the user thinks is the current dir is strange too -- when she discovers that the current dir is gone, she will likely wonder: Where did my file go?

So, modified versions of the two patches have been pushed to git,
see ff1bf88 and 6a9e2a4.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 12 Apr 2016 08:49:21 PM UTC, comment #7:

Applied both patches to v2.5.3 and made a test compile and file opening works correctly again! Thanks Benno! :)

Anonymous
Tue 12 Apr 2016 08:06:52 PM UTC, comment #6:

It took a while for it to dawn... The chdir("..") will also succeed when at the root directory -- it will loop there forever.

So, the first patch simply removes that loop -- because we don't know when to stop, because as long as getcwd() fails, we don't know where we are.

The second patch adds back the previous mechanism: preallocating a buffer, but in a better way, so that it can be freed if getcwd() should fail. This patch will be made superfluous when we move to gnulib -- see https://www.gnu.org/software/gnulib/manual/html_node/getcwd.html.

(file #36913, file #36914)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 12 Apr 2016 01:11:33 PM UTC, comment #5:

breaking CHANGE.. sorry!

Anonymous
Tue 12 Apr 2016 01:09:51 PM UTC, comment #4:

breaking chance=breaking chance

Anonymous
Tue 12 Apr 2016 01:08:01 PM UTC, comment #3:

I have a short 'nano' wrapper script set up on my Android device to execute nano.bin with TERMINFO and TERM defined, so trail-good and trail-bad are both from 2.5.3 but bad has the breaking chance so it hangs.

TRAIL was me attempting to use strace to pass the variables to nano itself without the an intermediary script to confuse the output: TERMIMFO=/su/etc/terminfo TERM=pcansi strace nano.bin requests.log 2>TRAIL

and that caused a cascade of the last 2 lines across the screen. Interesting stuff!

Anonymous
Tue 12 Apr 2016 08:00:43 AM UTC, comment #2:

Could you figure out where it hangs? Maybe with 'strace src/nano somefile 2>TRAIL', kill nano, and attach the TRAIL file here.

Does a getcwd(NULL, x) maybe always fail on Android? If so, hopefully this will be taken care of by gnulib, which we should be using pretty soon.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 10 Apr 2016 11:51:35 PM UTC, comment #1:

Oh, and I forgot to mention I also tried a build compiled from master HEAD and it was still an issue as stated.

Thanks for all the great work! :)

Anonymous
Sun 10 Apr 2016 11:47:03 PM UTC, original submission:

http://git.savannah.gnu.org/cgit/nano.git/commit/?id=706f01422dd5c6f12ca3d740f1bc64d20b8119c9

Is a breaking change for execution on Android cross-compiles.

My compiles were made using the same compile fixes and options since v2.5.0 and all worked well, but starting with v2.5.3 nano hangs when a filename is specified on the command line (it does continue to execute correctly without a file specified); this hangs the entire command prompt and Ctrl+C does not break the hang.

I worked back through the git log from v2.5.3 to v2.5.2 and found that reverting the above commit resolves it. It reverts cleanly from the v2.5.3 tag so I have tested the resulting build and it is back in working order.

Thanks!

Chris Renshaw
-unavailable-

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #36906:  TRAIL added by None (8KiB - application/octet-stream)
file #36904:  trail-bad added by None (22KiB - application/octet-stream)
file #36905:  trail-good added by None (25KiB - 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 (Posted a comment)
  •  

    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 11 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 20 Jun 2016 09:51:06 AM UTCbensOpen/ClosedOpen=>Closed
    Fri 15 Apr 2016 11:59:57 AM UTCbensStatusReady For Test=>Fixed
    Tue 12 Apr 2016 08:06:52 PM UTCbensAttached File-=>Added 0001-files-avoid-getting-into-an-infinite-loop-by-chdir-i.patch, #36913
      Attached File-=>Added 0002-files-handle-systems-that-don-t-allow-NULL-as-first-.patch, #36914
      Severity3 - Normal=>4 - Important
      StatusNone=>Ready For Test
      Assigned toNone=>bens
    Tue 12 Apr 2016 01:00:28 PM UTCNoneAttached File-=>Added TRAIL, #36906
    Tue 12 Apr 2016 12:54:00 PM UTCNoneAttached File-=>Added trail-bad, #36904
      Attached File-=>Added trail-good, #36905
    Tue 12 Apr 2016 08:00:43 AM UTCbensSummaryPrevious commit "Avoiding the loss a buffer when getcwd() fails." breaks execution on Android=>the commit "Avoiding the loss a buffer when getcwd() fails" causes a hang on Android

    Back to the top


    Powered by Savane 3.1-cleanup1