summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-08-08 03:58:22 +0200
committerhut <hut@lavabit.com>2012-08-08 03:58:22 +0200
commit859deb51bf9c03b0f54c5b4df4e9a3529b7aa528 (patch)
tree8a8cd8b049c8e60dd7a8a186b5f85294fbfef4b2 /ranger
parent5ee1e874cc5f9136af3a9a835b76076a85693bd0 (diff)
downloadranger-859deb51bf9c03b0f54c5b4df4e9a3529b7aa528.tar.gz
widgets.browsercolumn: Fixed segmentation fault due to 93601b17
https://github.com/hut/ranger/issues/45

hut:
  I've been experiencing irregular segfaults in ranger-master for which
  I can't figure out the reasons. Here is all the info I got:

  - It started around the time of commit 5417dda
  - I think it is a problem with curses' addstr/addnstr function
  - It happens randomly, there is no specific action that causes it
  - It happens more often with python3 than with python2
  - It's most likely somewhere in here: git diff master 5417dda5^
    ranger/gui/widgets/browsercolumn.py - but I don't see anything
    wrong.

hut:
  I nailed it down to 93601b1 and fixed it.

  For what it's worth, this is how to reproduce it: (tested with
  rxvt-unicode 9.15 and dwm but may work with any other tiling window
  manager):

  - Ensure that the setting display_tags_in_all_columns is set to True
    (this is the default)
  - Tag a file or directory with the "t" key
  - Navigate so that this tagged file is the LAST file you see of a
    column other the main column
  - Open a new window (resulting in rangers window getting smaller by at
    least one row)
  - Close a window (resulting in rangers window growing back to the
    original size)
  - Watch rangers brain being splattered all over the sand

  If you don't use a tiling window manager, you can do steps 1-3 and
  then resize rangers window very quickly.

  When resizing ranger manually, one of these messages is printed
  instead of "Segmentation Fault":

  - *** glibc detected *** python2.7: corrupted double-linked list: 0x0949cc98 ***
  - python2.7: malloc.c:3964: _int_free: Assertion `nextchunk->fd_nextsize->bk_nextsize == nextchunk' failed.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/gui/widgets/browsercolumn.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index adf79e92..1cb943d2 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -302,19 +302,20 @@ class BrowserColumn(Pager):
 
 			display_data.append([text, attr])
 
+			padding = self.wid - len(wtext)
+			if tagged and (self.main_column or \
+					self.settings.display_tags_in_all_columns):
+				padding -= 1
 			if infostring:
 				if len(text) + 1 + len(infostring) > self.wid:
 					pass
 				else:
-					padding = self.wid - len(wtext) - len(infostring)
-					if tagged and (self.main_column or \
-							self.settings.display_tags_in_all_columns):
-						padding -= 1
+					padding -= len(infostring)
 					padding = max(0, padding)
 					infostring = (" " * padding) + infostring
 					display_data.append([infostring, attr])
 			else:
-				display_data.append([" " * max(0, self.wid - len(wtext)), attr])
+				display_data.append([" " * max(0, padding), attr])
 
 			self.execute_curses_batch(line, display_data)
 			self.color_reset()