Bug 141654 - less 'hangs' when viewing binary file
Summary: less 'hangs' when viewing binary file
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: less
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jindrich Novy
QA Contact: Mike McLean
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-12-02 18:19 UTC by Ralf Ertzinger
Modified: 2013-07-02 23:03 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-10-19 11:40:22 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Ralf Ertzinger 2004-12-02 18:19:25 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5)
Gecko/20041114 Firefox/1.0

Description of problem:
I am viewing a binary file with less. It was created by 'dd
if=/dev/null of=file bs=1k count=16k', thus it is 16MB in size.
When trying to view this file with less, less warns that the file may
be binary (obviously). When replying yes, less starts to use all
available processor power, and stops reacting to all keypresses
(including ctrl-c). strace reveals a lot of mmap going on:

......
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
8192) = 8192
mmap2(NULL, 2625536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0xf6825000
mmap2(NULL, 2625536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0xf65a4000
munmap(0xf6323000, 2625536)             = 0
munmap(0xf6d25000, 2625536)             = 0
mmap2(NULL, 2625536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0xf6d25000
mmap2(NULL, 2625536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0xf6323000
munmap(0xf65a4000, 2625536)             = 0
munmap(0xf6825000, 2625536)             = 0
mmap2(NULL, 2629632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0xf6824000
mmap2(NULL, 2629632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0xf60a1000
munmap(0xf6323000, 2625536)             = 0
munmap(0xf6d25000, 2625536)             = 0
mmap2(NULL, 2629632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0xf6d24000
mmap2(NULL, 2629632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0xf65a2000
munmap(0xf60a1000, 2629632)             = 0
munmap(0xf6824000, 2629632)             = 0
......

I think it looks for linebreaks, so I expect it will stop once less
reaches the end of the file. but given the speed this may take a
minute or longer.

Version-Release number of selected component (if applicable):
less-382-5

How reproducible:
Always

Steps to Reproduce:
1. View large binary file with less
2.
3.
    

Actual Results:  less seems to hang, and uses lots of CPU

Expected Results:  less should at least react to ctrl-c, and display a
warning that the operation may take longer.

Additional info:

Comment 1 Jindrich Novy 2005-10-19 11:40:22 UTC
Seems to be fixed by the latest less-392. It uses the full CPU time, but just
for a while even in the case of large binary files.


Note You need to log in before you can comment on or make changes to this bug.