Bug 1906064
Summary: | tcsh history breaks when using modifiers | |||
---|---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Frank Hirtz <fhirtz> | |
Component: | tcsh | Assignee: | Jan Macku <jamacku> | |
Status: | CLOSED WONTFIX | QA Contact: | Karel Volný <kvolny> | |
Severity: | high | Docs Contact: | ||
Priority: | high | |||
Version: | 7.9 | CC: | jamacku, snavale | |
Target Milestone: | rc | Flags: | pm-rhel:
mirror+
|
|
Target Release: | --- | |||
Hardware: | All | |||
OS: | All | |||
Whiteboard: | ||||
Fixed In Version: | Doc Type: | If docs needed, set a value | ||
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 1997981 1997986 (view as bug list) | Environment: | ||
Last Closed: | 2023-07-18 15:41:32 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: | ||||
Bug Depends On: | ||||
Bug Blocks: | 1997981, 1997986 |
Description
Frank Hirtz
2020-12-09 15:51:23 UTC
Quick check and notes: <rhel7> [root@lab-rhel7-2 ~]# tcsh [root@lab-rhel7-2 ~]# alias postcmd '/bin/echo -n "COMMAND:"'"'"'\!#:-$:gx'"'"'' [root@lab-rhel7-2 ~]# echo 1 2 3 4 5 COMMAND:echo 1 2 3 4 51 2 3 4 5 [root@lab-rhel7-2 ~]# echo "a" 'b' "c" COMMAND:echo "a" 'b' "c"a b c [root@lab-rhel7-2 ~]# history|tail -4 COMMAND:history | tail -4 3 15:28 echo "a" 'b' "c" -50000000 15:28 echo \"a\" \'b\' 4 15:29 history | tail -4 -50000000 15:29 history | tail [root@lab-rhel7-2 ~]# rpm -q tcsh COMMAND:rpm -q tcshtcsh-6.18.01-17.el7_9.1.x86_64 <downgrade to previous build> [root@lab-rhel7-2 ~]# exit [root@lab-rhel7-2 ~]# tcsh [root@lab-rhel7-2 ~]# alias postcmd '/bin/echo -n "COMMAND:"'"'"'!#:-$:gx'"'"'' alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' [root@lab-rhel7-2 ~]# echo 1 2 3 4 5 COMMAND:alias postcmd1 2 3 4 5 [root@lab-rhel7-2 ~]# echo "a" 'b' "c" COMMAND:alias postcmda b c [root@lab-rhel7-2 ~]# history|tail -4 COMMAND:alias postcmd 11 15:32 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' 12 15:33 echo 1 2 3 4 5 13 15:33 echo "a" 'b' "c" 14 15:33 history | tail -4 [root@lab-rhel7-2 ~]# rpm -q tchs COMMAND:alias postcmdpackage tchs is not installed [root@lab-rhel7-2 ~]# rpm -q tcsh COMMAND:alias postcmdtcsh-6.18.01-17.el7.x86_64 </snip> <upstream for reference> fmhirtz ~ git kernel-rhel tcsh [fmhirtz@gkar kernel-rhel]$ [fmhirtz@gkar kernel-rhel]$ alias postcmd '/bin/echo -n "COMMAND:"'"'"'\!#:-$:gx'"'"'' [fmhirtz@gkar kernel-rhel]$ echo 1 2 3 4 5 COMMAND:echo 1 2 3 4 51 2 3 4 5 [fmhirtz@gkar kernel-rhel]$ echo "a" 'b' "c" COMMAND:echo "a" 'b' "c"a b c [fmhirtz@gkar kernel-rhel]$ history | tail -4 COMMAND:history | tail -4 7 15:35 alias postcmd '/bin/echo -n "COMMAND:"'"'"'\!#:-$:gx'"'"'' 8 15:36 echo 1 2 3 4 5 9 15:37 echo "a" 'b' "c" 10 15:37 history | tail -4 [fmhirtz@gkar kernel-rhel]$ rpm -q tcsh COMMAND:rpm -q tcshtcsh-6.22.03-1.fc33.x86_64 </snip> Notes: The version prior to the 7.9 patch appears to work correctly per this test (I don't know the validity of the test though; just reproducing). The 7.9 patch truncates and adds some "garbage". Upstream truncates as well on the "up arrow" (it does a "one up"->"1 2 3 4" "two up"->"1 2 3 4 5", but doesn't have the garbage. So, it looks both of these were picked up in the patch.. some is backporting the "truncation" behavior that's upstream but the "garbage" is novel. The patch that was backported was to correct an issue in the space: Bug 1846271 - [RHEL-7.9] tcsh corrupt history file results in rapid memory consumption until memory exhausted So, this behavior change looks to have been pulled in with this; we'll have to assess. Hi,
I was able to reproduce this issue and it seems like regression was introduced in tcsh-6.18.01-16.el7.
.history file shows that at the end of each command is added timestamp:
# less .history
> #+1614063515
> alias postcmd '/bin/echo -n "COMMAND:"'"'"'!#:-$:gx'"'"''
> #+1614063520
> echo 1 2 3 4 5#+1614063612
> #+1614063612
> echo 1 2 3 4 5#+1614063647
Strange is that when I was upgrading from tcsh-6.18.01-15.el7 to newer package I wasn't able to reproduce the issue.
I will continue with debugging.
Jan
Hi, I tried to reproduce it again but this time I removed .history file first and then I wasn't able to reproduce it issue. [root@localhost ~]# rm .history > rm: remove regular file ‘.history’? y [root@localhost ~]# tcsh [root@localhost ~]# alias postcmd '/bin/echo -n "COMMAND:"'"'"'!#:-$:gx'"'"'' > alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' [root@localhost ~]# echo 1 2 3 4 5 > COMMAND:alias postcmd1 2 3 4 5 [root@localhost ~]# echo "a" 'b' "c" > COMMAND:alias postcmda b c [root@localhost ~]# history | tail -4 > COMMAND:alias postcmd 1 4:11 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' > 2 4:11 echo 1 2 3 4 5 > 3 4:11 echo "a" 'b' "c" > 4 4:11 history | tail -4 [root@localhost ~]# rpm -q tcsh > COMMAND:alias postcmdtcsh-6.18.01-17.el7_9.1.x86_64 Then I exit from tcsh and try it again without deleting .history and everything works as expected. History in tcsh was always causing issues. The last Z-stream release should fix some issues with corrupted history. So I would highly suggest to get rid of corrupted history if possible and update to latest tcsh release (tcsh-6.18.01-17.el7_9.1). Jan Hi Jan, I'll check that with my case, have the client run through it and let you know. Thanks for looking into this. <baseline with the previous version> -sh-4.2$ id uid=777000010(fmhirtz) gid=777000010(fmhirtz) groups=777000010(fmhirtz) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 -sh-4.2$ ls -l ~/.history ls: cannot access /home/fmhirtz/.history: No such file or directory -sh-4.2$ rpm -q tcsh tcsh-6.18.01-17.el7.x86_64 -sh-4.2$ tcsh [fmhirtz@lab-rhel7-1 ~]$ alias postcmd '/bin/echo -n "COMMAND:"'"'"'!#:-$:gx'"'"'' alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' [fmhirtz@lab-rhel7-1 ~]$ echo 1 2 3 4 5 COMMAND:alias postcmd1 2 3 4 5 [fmhirtz@lab-rhel7-1 ~]$ echo "a" 'b' "c" COMMAND:alias postcmda b c [fmhirtz@lab-rhel7-1 ~]$ history | tail -4 COMMAND:alias postcmd 1 17:12 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' 2 17:12 echo 1 2 3 4 5 3 17:12 echo "a" 'b' "c" 4 17:13 history | tail -4 [fmhirtz@lab-rhel7-1 ~]$ cat ~/.history COMMAND:alias postcmdcat: /home/fmhirtz/.history: No such file or directory [fmhirtz@lab-rhel7-1 ~]$ history -S COMMAND:alias postcmd[fmhcat ~/.history COMMAND:alias postcmd#+1622567559 alias postcmd#+1622567559 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' #+1622567569 echo 1 2 3 4 5 #+1622567576 echo "a" 'b' "c" #+1622567586 history | tail -4 #+1622567604 cat ~/.history #+1622567607 history -S </baseline> <clean w/ update> -sh-4.2$ rm -f ~/.history -sh-4.2$ tcsh [fmhirtz@lab-rhel7-1 ~]$ history 1 17:16 history [fmhirtz@lab-rhel7-1 ~]$ cat ~/.history cat: /home/fmhirtz/.history: No such file or directory [fmhirtz@lab-rhel7-1 ~]$ alias postcmd '/bin/echo -n "COMMAND:"'"'"'!#:-$:gx'"'"'' alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' [fmhirtz@lab-rhel7-1 ~]$ echo 1 2 3 4 5 COMMAND:alias postcmd1 2 3 4 5 [fmhirtz@lab-rhel7-1 ~]$ echo "a" 'b' "c" COMMAND:alias postcmda b c [fmhirtz@lab-rhel7-1 ~]$ history | tail -4 COMMAND:alias postcmd 3 17:16 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' 4 17:17 echo 1 2 3 4 5 5 17:17 echo "a" 'b' "c" 6 17:17 history | tail -4 [fmhirtz@lab-rhel7-1 ~]$ cat ~/.history COMMAND:alias postcmdcat: /home/fmhirtz/.history: No such file or directory [fmhirtz@lab-rhel7-1 ~]$ history -S COMMAND:alias postcmd[fmhcat ~/.history COMMAND:alias postcmd#+1622567793 history #+1622567819 alias postcmd#+1622567819 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' #+1622567838 echo 1 2 3 4 5 #+1622567848 echo "a" 'b' "c" #+1622567858 history | tail -4 #+1622567875 cat ~/.history #+1622567881 history -S </update> <previous version clean/test -> update/test> -sh-4.2$ rpm -q tcsh tcsh-6.18.01-17.el7_9.1.x86_64 -sh-4.2$ tcsh [fmhirtz@lab-rhel7-1 ~]$ history | tail -4 9 17:26 cat ~/.history 10 17:26 sudo yum update 11 17:27 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' 12 17:28 history | tail -4 [fmhirtz@lab-rhel7-1 ~]$ echo 1 2 3 4 5 1 2 3 4 5 [fmhirtz@lab-rhel7-1 ~]$ alias postcmd '/bin/echo -n "COMMAND:"'"'"'!#:-$:gx'"'"'' alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' [fmhirtz@lab-rhel7-1 ~]$ echo 1 2 3 4 5 COMMAND:alias postcmd1 2 3 4 5 [fmhirtz@lab-rhel7-1 ~]$ echo "a" 'b' "c" COMMAND:alias postcmda b c [fmhirtz@lab-rhel7-1 ~]$ history | tail -4 COMMAND:alias postcmd 14 17:29 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' 15 17:29 echo 1 2 3 4 5 16 17:29 echo "a" 'b' "c" 17 17:29 history | tail -4 [fmhirtz@lab-rhel7-1 ~]$ cat ~/.history COMMAND:alias postcmd#+1622568259 history #+1622568314 alias postcmd#+1622568314 #+1622568314 alias postcmd#+1622568314 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' #+1622568321 echo 1 2 3 4 5 #+1622568328 echo "a" 'b' "c" #+1622568333 history | tail -4 #+1622568348 history -S #+1622568363 cat ~/.history #+1622568378 sudo yum update #+1622568398 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' [fmhirtz@lab-rhel7-1 ~]$ history -S COMMAND:alias postcmd[fmhcat ~/.history COMMAND:alias postcmd#+1622568259 history #+1622568314 alias postcmd#+1622568314 #+1622568378 sudo yum update #+1622568554 alias postcmd#+1622568554 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' #+1622568560 echo 1 2 3 4 5 #+1622568565 echo "a" 'b' "c" #+1622568573 history | tail -4 #+1622568587 cat ~/.history #+1622568597 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' #+1622568597 history -S </previous/update> <reset history on update> COMMAND:alias postcmd[fmhirtz@lab-rhel7-1 ~]$ exit -sh-4.2$ rm -f .history -sh-4.2$ tcsh [fmhirtz@lab-rhel7-1 ~]$ cat ~/.history cat: /home/fmhirtz/.history: No such file or directory [fmhirtz@lab-rhel7-1 ~]$ history | tail -4 1 17:31 cat ~/.history 2 17:31 history | tail -4 [fmhirtz@lab-rhel7-1 ~]$ alias postcmd '/bin/echo -n "COMMAND:"'"'"'!#:-$:gx'"'"'' alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' [fmhirtz@lab-rhel7-1 ~]$ echo 1 2 3 4 5 COMMAND:alias postcmd1 2 3 4 5 [fmhirtz@lab-rhel7-1 ~]$ echo "a" 'b' "c" COMMAND:alias postcmda b c [fmhirtz@lab-rhel7-1 ~]$ history | tail -4 COMMAND:alias postcmd 3 17:32 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' 4 17:32 echo 1 2 3 4 5 5 17:32 echo "a" 'b' "c" 6 17:32 history | tail -4 [fmhirtz@lab-rhel7-1 ~]$ history -S COMMAND:alias postcmd[fmhtail -10 ~/.history COMMAND:alias postcmdalias postcmd#+1622568742 alias postcmd '/bin/echo -n "COMMAND:"'"'"'alias postcmd'"'"'' #+1622568748 echo 1 2 3 4 5 #+1622568754 echo "a" 'b' "c" #+1622568761 history | tail -4 #+1622568767 history -S [fmhirtz@lab-rhel7-1 ~]$ </retest> This all seems to work, but I was initially seeing the issue where the timestamp is appended to the command in the history file: <snip> COMMAND:cat ~/.history#+1622555182 alias postcmd '/bin/echo -n "COMMAND:"'"'"'!#:-$:gx'"'"'' #+1622555202 COMMAND:echo 1 2 3 4 51 2 3 4 5 #+1622555202 COMMAND:echo 1 2 3 4 51 2 3 4 5#+1622555266 #+1622555529 echo 1 2 3 4 5 #+1622555266 echo 1 2 3 4 5#+1622555300 #+1622555529 echo "a" 'b' "c" #+1622555300 echo "a" 'b' "c"#+1622555326 #+1622555529 history | tail -4 #+1622555326 history | tail -4#+1622555420 #+1622555420 cd#+1622555466 ls --color=auto -a#+1622555479 #+1622555529 tail -f .bash_history #+1622555479 tail -f .bash_history#+1622555491 #+1622555529 less .tcshrc #+1622555491 less .tcshrc#+1622555496 #+1622555500 man tcsh #+1622555500 ls -l #+1622555536 cd #+1622555537 ls -a #+1622555543 cat .history #+1622555592 yum update tcsh #+1622555885 rpm -q tcsh #+1622555951 rm -f .history </snip> That was just on my initial setup and I didn't have a .history, but when I tried to reproduce in a more controlled manner, the issue went away. I'm not quite sure what the relevant variable is here that does this. I'll see about reproducing some more to understand it and check with the client on reproducing in their environment. Stepping back and reinstalling, I can reproduce this with a "clean" history: <snip> -sh-4.2$ sudo yum install tcsh HTTP error (400 - Bad Request) =========================================================================================================================================================================== Package Arch Version Repository Size =========================================================================================================================================================================== Installing: tcsh x86_64 6.18.01-17.el7_9.1 rhel-7-server-rpms 339 k Transaction Summary =========================================================================================================================================================================== Install 1 Package Total download size: 339 k Installed size: 662 k Is this ok [y/d/N]: y Warning: RPMDB altered outside of yum. HTTP error (400 - Bad Request) HTTP error (400 - Bad Request) Installed: tcsh.x86_64 0:6.18.01-17.el7_9.1 HTTP error (400 - Bad Request) -sh-4.2$ rpm -q tcsh tcsh-6.18.01-17.el7_9.1.x86_64 -sh-4.2$ cat ~/.history cat: /home/fmhirtz/.history: No such file or directory -sh-4.2$ tcsh [fmhirtz@lab-rhel7-1 ~]$ alias postcmd '/bin/echo -n "COMMAND:"'"'"'\!#:-$:gx'"'"'' [fmhirtz@lab-rhel7-1 ~]$ echo 1 2 3 4 5 COMMAND:echo 1 2 3 4 51 2 3 4 5 [fmhirtz@lab-rhel7-1 ~]$ echo "a" 'b' "c" COMMAND:echo "a" 'b' "c"a b c [fmhirtz@lab-rhel7-1 ~]$ history | tail -10 COMMAND:history | tail -10 1 17:45 alias postcmd '/bin/echo -n "COMMAND:"'"'"'\!#:-$:gx'"'"'' 2 17:45 echo 1 2 3 4 5 -50000000 17:45 echo 1 2 3 4 3 17:45 echo "a" 'b' "c" -50000000 17:45 echo \"a\" \'b\' 4 17:46 history | tail -10 -50000000 17:46 history | tail [fmhirtz@lab-rhel7-1 ~]$ cat ~/.history COMMAND:cat ~/.historycat: /home/fmhirtz/.history: No such file or directory [fmhirtz@lab-rhel7-1 ~]$ history -S COMMAND:history -Shistory -S[fmhirtz@lab-rhel7-1 ~]$ tail -10 ~/.history COMMAND:tail -10 ~/.history#+1622569540 echo "a" 'b' "c"#+1622569565 history | tail -10 #+1622569565 history | tail -10#+1622569591 cat ~/.history #+1622569591 cat ~/.history#+1622569594 history -S #+1622569594 [fmhirtz@lab-rhel7-1 ~]$ </snip> This was removing the previous tcsh install, deleting the ~/.history, installing the current version, and running the reproducer flow. When I continued with the install, as noted, things get murkier in that this doesn't happen reliably, but the simple install->run appears to show it. There's no ~/.history, so it's not latent corruption... in the file at least. Hello Frank, I'll have a look into in next week. I'll keep you updated. Thank you for reproducer. Jan Hi Frank, I was able to reproduce the issue. RHEL 7.9: --------- > [root@localhost ~]# rpm -qa tcsh > tcsh-6.18.01-17.el7_9.1.x86_64 > ... > [root@localhost ~]# history | tail -10 > COMMAND:history | tail -10 1 2:23 alias postcmd '/bin/echo -n "COMMAND:"'"'"'\!#:-$:gx'"'"'' > 2 2:23 echo 1 2 3 4 5 > -50000000 2:23 echo 1 2 3 4 > 3 2:23 echo "a" 'b' "c" d > -50000000 2:23 echo \"a\" \'b\' \"c\" > 4 2:24 history | tail -10 > -50000000 2:24 history | tail Fedora Rawhide: --------------- > [root@localhost ~]# rpm -qa tcsh > tcsh-6.22.04-1.fc35.x86_64 > ... > [root@localhost ~]# history | tail -10 > COMMAND:history | tail -10 1 2:30 alias postcmd '/bin/echo -n "COMMAND:"'"'"'\!#:-$:gx'"'"'' > 2 2:30 echo 1 2 3 4 5 > 3 2:31 echo "a" 'b' "c" > 4 2:32 history | tail -10 In upstream (Fedora) the history looks cleaner, but when I hit the upper arrow, then the last word is always missing (same behaviour as in RHEL 7.9). I'll continue debugging this issue. Jan Hi Frank, I don't think this is regression, if so, then it's a very old one. I tried RHEL 7.6 and it behaves the same as RHEL 7.9 and Fedora rawhide. Regards Jan Development Management has reviewed and declined this request. You may appeal this decision by reopening this request. |