Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 847730

Summary: "module load" segfaults due to stale pointer to compiled regular expression
Product: Red Hat Enterprise Linux 6 Reporter: James Rowland <james.rowland>
Component: environment-modulesAssignee: Jan Synacek <jsynacek>
Status: CLOSED DUPLICATE QA Contact: Jiri Pospisil <jpospisi>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.3CC: ebenes, frederik.ferner, jpospisi, ksrot, richardfearn
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: environment-modules-3.2.9c-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-09-11 11:14:45 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:
Attachments:
Description Flags
module files needed to reproduce this problem, patch that fixes it none

Description James Rowland 2012-08-13 11:26:55 UTC
Created attachment 603965 [details]
module files needed to reproduce this problem, patch that fixes it

Description of problem:

"module load" segfaults in some cases. I have traced this to the precompiled regular expressions kept in static storage in utility.c::ReturnValue. The TCL manual disallows this:

http://www.tcl.tk/man/tcl/TclLib/RegExp.htm:

"Note: the return value from Tcl_RegExpCompile is only valid up to the next call to Tcl_RegExpCompile; it is not safe to retain these values for long periods of time."

This rejected upstream bug is related:

http://sourceforge.net/tracker/?func=detail&aid=1685498&group_id=15538&atid=115538

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

[jr76@pc0072 modulepath]$ rpm -qa environment-modules
environment-modules-3.2.7b-6.el6.x86_64

This bug is still present in the latest upstream.

How reproducible:

Intermittent, pointer refers to freed heap memory so may depend on environment variables.

Steps to Reproduce:

export MODULEPATH=/scratch/modulepath/modulefiles
# included in tgz

valgrind /usr/bin/modulecmd bash load fast_dp

OR

# included in tgz
gdb /usr/bin/modulecmd
run bash load fast_dp
 
Actual results:

==20842== Invalid write of size 8
==20842==    at 0x4CE71C9: Tcl_RegExpExec (tclRegexp.c:197)
==20842==    by 0x411C54: ReturnValue (utility.c:3008)
==20842==    by 0x409804: Execute_TclFile (cmdModule.c:612)
==20842==    by 0x405B5A: ModuleCmd_Load (ModuleCmd_Load.c:213)
==20842==    by 0x40A0E9: cmdModule (cmdModule.c:217)
==20842==    by 0x4C5B5FE: TclInvokeStringCommand (tclBasic.c:2146)
==20842==    by 0x4C5C692: TclEvalObjvInternal (tclBasic.c:3690)
==20842==    by 0x4CA4793: TclExecuteByteCode (tclExecute.c:2348)
==20842==    by 0x4CAB968: TclCompEvalObj (tclExecute.c:1474)
==20842==    by 0x4C5DC95: TclEvalObjEx (tclBasic.c:5095)
==20842==    by 0x4C6EBB2: Tcl_IfObjCmd (tclCmdIL.c:307)
==20842==    by 0x4C5C692: TclEvalObjvInternal (tclBasic.c:3690)
==20842==  Address 0x50887b0 is 64 bytes inside a block of size 120 free'd
==20842==    at 0x4A0595D: free (vg_replace_malloc.c:366)
==20842==    by 0x4CE6EBF: CompileRegexp (tclRegexp.c:979)
==20842==    by 0x40B795: cmdSetPath (cmdPath.c:259)
==20842==    by 0x4123B9: Update_LoadedList (utility.c:2124)
==20842==    by 0x405C62: ModuleCmd_Load (ModuleCmd_Load.c:228)
==20842==    by 0x40A0E9: cmdModule (cmdModule.c:217)
==20842==    by 0x4C5B5FE: TclInvokeStringCommand (tclBasic.c:2146)
==20842==    by 0x4C5C692: TclEvalObjvInternal (tclBasic.c:3690)
==20842==    by 0x4CA4793: TclExecuteByteCode (tclExecute.c:2348)
==20842==    by 0x4CAB968: TclCompEvalObj (tclExecute.c:1474)
==20842==    by 0x4C5DC95: TclEvalObjEx (tclBasic.c:5095)
==20842==    by 0x4C6EBB2: Tcl_IfObjCmd (tclCmdIL.c:307)


(gdb) run bash load fast_dp
Starting program: /usr/bin/modulecmd bash load fast_dp
Detaching after fork from child process 28657.
Detaching after fork from child process 28658.
Detaching after fork from child process 28675.
Detaching after fork from child process 28697.

Program received signal SIGSEGV, Segmentation fault.
0x00000000006c2dd8 in ?? ()
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.80.el6_3.3.x86_64 libX11-1.3-2.el6.x86_64 libXau-1.0.5-1.el6.x86_64 libxcb-1.5-1.el6.x86_64
(gdb) bt 5
#0  0x00000000006c2dd8 in ?? ()
#1  0x00007ffff7cf5cfc in Tcl_DeleteCommandFromToken (interp=0x6c2c00, cmd=0x68f940)
    at /usr/src/debug/tcl8.5.7/generic/tclBasic.c:2838
#2  0x00007ffff7d67b64 in TclTeardownNamespace (nsPtr=0x6c7d00)
    at /usr/src/debug/tcl8.5.7/generic/tclNamesp.c:1087
#3  0x00007ffff7cf6cc0 in DeleteInterpProc (interp=0x6c2c00) at /usr/src/debug/tcl8.5.7/generic/tclBasic.c:1254
#4  0x0000000000405b98 in ModuleCmd_Load (interp=<value optimized out>, load=1, argc=1, 
    argv=<value optimized out>) at ModuleCmd_Load.c:268
(More stack frames follow...)
(gdb) 

Expected results:

Various bash commands to stdout, no SIGSEGV:

BALBES_ROOT=/dls_sw/apps/ccp4/64/6.2.0/7dec2011/ccp4-6.2.0/share/BALBES/Package ;export BALBES_ROOT;BINSORT_SCR=/home/jr76/tmp ;export BINSORT_SCR;CBIN=/dls_sw/apps/ccp4/64/6.2.0/7dec2011/ccp4-6.2.0/bin ;export CBIN;CCP4=/dls_sw/apps/ccp4/64/6.2.0/7dec2011/ccp4-6.2.0 ;export CCP4;CCP4I_HELP=/dls_sw/apps/ccp4/64/6.2.0/7dec2011/ccp4-6.2.0/ccp4i/help ;export CCP4I_HELP;CCP4I_TCLTK=/dls_sw/dasc/TclTkBlt/bin ;export CCP4I_TCLTK;CCP4I_TOP=/dls_sw/apps/ccp4/64/6.2.0/7dec2011/ccp4-6.2.0/ccp4i ;export CCP4I_TOP;CCP4_BIN=/dls_sw/apps/ccp4/64/6.2.0/7dec2011/ccp4-6.2.0/bin ;export CCP4_BIN;CCP4_BROWSER=firefox ;export CCP4_BROWSER;CCP4_HELPDIR=/dls_sw/apps/ccp4/64/6.2.0/7dec2011/ccp4-6.2.0/help/ ;export CCP4_HELPDIR;CCP4_LIB=/dls_sw/apps/ccp4/64/6.2.0/7dec2011/ccp4-6.2.0/lib ;export CCP4_LIB;CCP4_MASTER=/dls_sw/apps/ccp4/64/6.2.0/7dec2011 ;export CCP4_MASTER;CCP4_OPEN=UNKNOWN ;export CCP4_OPEN;CCP4_SCR=/home/jr76/tmp ;export CCP4_SCR

etc.


Additional info:

Attached patch which fixes this problem, and modules directory

Comment 3 RHEL Program Management 2012-09-11 07:59:34 UTC
This request was evaluated by Red Hat Product Management for
inclusion in a Red Hat Enterprise Linux release.  Product
Management has requested further review of this request by
Red Hat Engineering, for potential inclusion in a Red Hat
Enterprise Linux release for currently deployed products.
This request is not yet committed for inclusion in a release.

Comment 4 James Rowland 2012-09-11 08:31:40 UTC
See also https://bugzilla.redhat.com/show_bug.cgi?id=834580

Comment 5 Jan Synacek 2012-09-11 11:14:45 UTC
Fixed together with #818177.

Comment 6 Karel Srot 2012-09-11 11:46:04 UTC

*** This bug has been marked as a duplicate of bug 818177 ***