This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1885399 - stack overflow if cannot unlink $HOME/.sh_history
Summary: stack overflow if cannot unlink $HOME/.sh_history
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ksh
Version: 7.9
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Vincent Mihalkovič
QA Contact: Karel Volný
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-10-05 19:45 UTC by Paulo Andrade
Modified: 2024-03-25 16:38 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-20 20:57:01 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker   RHEL-5685 0 None Migrated None 2023-09-20 20:56:52 UTC

Description Paulo Andrade 2020-10-05 19:45:16 UTC
It will also fail the rename in the chunk:

src/cmd/ksh93/edit/history.c
"""
	unlink(hist_old->histname);
	if(access(hist_old->histname,F_OK) >= 0)
	{
		/* The unlink can fail on windows 95 */
		int fd;
		char *last, *name=hist_old->histname;
		close(sffileno(hist_old->histfp));
		tmpname = (char*)malloc(strlen(name)+14);
		if(last = strrchr(name,'/'))
		{
			*last = 0;
			pathtmp(tmpname,name,"hist",NIL(int*));
			*last = '/';
		}
		else
			pathtmp(tmpname,".","hist",NIL(int*));
		if(rename(name,tmpname) < 0)
		{
			free(tmpname);
			tmpname = name;
		}
		fd = open(tmpname,O_RDONLY);
		sfsetfd(hist_old->histfp,fd);
		if(tmpname==name)
			tmpname = 0;
	}
	hist_ptr = 0;
	if(fstat(sffileno(hist_old->histfp),&statb)>=0)
	{
		histinit = 1;
		histmode =  statb.st_mode;
	}
"""

  Another condition required is to have a full .sh_history.
This will cause sh_histinit to call hist_trim, that will
again call sh_histinit.

  On the backtrace, the condition is verified in the statb
local variable of hist_trim, where the call trace shows that
the unlink and rename syscalls failed.
  The unlink call may fail due to a stale file or some filesystem
issue. The rename call will fail if tmpname is on another filesystem;
could be nfs vs local filesystem or local filesystem and a tmpfs /tmp.

  The issue only happens if the unlink fails, but still, could use
a smarter or fallback approach to not cause the stack overflow crash.

Comment 4 Paulo Andrade 2020-10-27 19:18:40 UTC
We just had another case with a slightly different condition for this to happen.

Still an erroneous state. Basically, needs a .sh_history that will cause hist_trim
to be called, and not have write permissions to $HOME.

The other recent cases were stale nfs file and an issue with a local filesystem.

Comment 8 RHEL Program Management 2023-09-20 20:23:49 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 9 RHEL Program Management 2023-09-20 20:57:01 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


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