bash built-in read timeout (-t) doesn't work

Bug #1283309 reported by Miroslav Prašil
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
Expired
Low
Unassigned

Bug Description

This should timeout after 2 seconds (based on bash man page) but it doesn't:
#read -t 2 test
(waits infinitely, only terminates after pressing [enter] or ctrl-C, etc..)

bash --version:
GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)

Installed bash package version:
4.2-2ubuntu2.1

$ lsb_release -rd
Description: Ubuntu 12.04.4 LTS
Release: 12.04

Miroslav Prašil (cezz)
affects: xubuntu-meta (Ubuntu) → bash (Ubuntu)
Revision history for this message
Miroslav Prašil (cezz) wrote :

Not sure if important, but this is running on a virtualbox virt. machine. I've just tried to run the same on EC2 machine with same package version and it seems to be working fine. (timeouts as expected) So this *might* be machine specific, though I don't have any other issues and this seems really odd.

Revision history for this message
Miroslav Prašil (cezz) wrote :

I've just noticed I have libreadline5 installed on misbehaving system (due to some dependencies) That's the only difference I can see right now. (correctly working EC2 instance only has libreadline6 installed)

$ dpkg -l *readline*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-================-================-================================================
un libreadline-comm <none> (no description available)
un libreadline-ruby <none> (no description available)
un libreadline4 <none> (no description available)
ii libreadline5 5.2-11 GNU readline and history libraries, run-time lib
ii libreadline6 6.2-8 GNU readline and history libraries, run-time lib
un libterm-readline <none> (no description available)
un libterm-readline <none> (no description available)
ii readline-common 6.2-8 GNU readline and history libraries, common files
un tclreadline <none> (no description available)

tags: added: precise
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in bash (Ubuntu):
status: New → Confirmed
Revision history for this message
Charles Evans (crtiger) wrote :

Still fails randomly
@ jammy bash 5.1-6ubuntu1
Read -t 60 failure can often be triggered by changing the system clock slightly. It often fails if waiting when ntp runs.

Revision history for this message
Lukas Märdian (slyon) wrote :

I cannot seem to reproduce this issue on Jammy bash 5.1-6ubuntu1:
```
$ time read -t 2 test

real 0m2,000s
user 0m0,000s
sys 0m0,000s
$
```

@crtiger Could you please describe your "changing the system clock and wait for ntp run" reproducer in more detail?

Changed in bash (Ubuntu):
status: Confirmed → Incomplete
importance: Undecided → Low
Revision history for this message
Charles Evans (crtiger) wrote :

While date
Do
Read -t 60 x
Done

In another terminal, adjust the system clock by a few seconds
Repeat hourly until the read hangs.
Sometimes it hangs immediately after setting clock,
Sometimes it runs for hours.
I have seen hangs semi regularly for the last 5, maybe 10+ years.
It often hangs with no apparent system clock changes,
But more often when a cron job runs ntp
No VM involved.
Hangs on multiple AMD systems.

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for bash (Ubuntu) because there has been no activity for 60 days.]

Changed in bash (Ubuntu):
status: Incomplete → Expired
Revision history for this message
Charles Evans (crtiger) wrote :

Also failing in
Bash 5.0.6ubuntu1.2
In focal 20.04.5 LTS

Revision history for this message
Charles Evans (crtiger) wrote :

With multiple bash scripts running for over a month,
I now have random read fails at least once an hour PER SCRIPT.
Restarting the script did not help.
Restarting bash helps for a while.

Revision history for this message
Charles Evans (crtiger) wrote :

Hwclock -s is run on the system at least weekly as system time drifts. Adjtime is not installed.

Revision history for this message
Charles Evans (crtiger) wrote :

System time consistently falls behind, so hwclock -s is advancing the system clock.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.