Bug 1885399
| Summary: | stack overflow if cannot unlink $HOME/.sh_history | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Paulo Andrade <pandrade> |
| Component: | ksh | Assignee: | Vincent Mihalkovič <vmihalko> |
| Status: | CLOSED MIGRATED | QA Contact: | Karel Volný <kvolny> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.9 | CC: | amepatil, ccheney, lzaoral |
| Target Milestone: | rc | Keywords: | MigratedToJIRA |
| Target Release: | --- | Flags: | pm-rhel:
mirror+
|
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2023-09-20 20:57:01 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: | |||
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. 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. 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. |
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.