bugThe nmh Mail Handling System - Bugs: bug #16793, Segmentation fault in show (1.1RC4...

 
 

bug #16793: Segmentation fault in show (1.1RC4 & 1.2, OpenSuse 10.1)

Submitted by:  None
Submitted on:  Fri 09 Jun 2006 03:14:45 PM UTC  
 
Category: compatibilitySeverity: 3 - Normal
Priority: 5 - NormalStatus: Fixed
Assigned to: NoneOpen/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 10 Apr 2007 07:25:07 AM UTC, comment #2:

Assuming comment #1 below is correct, the problem has been fixed in CVS, since strcasecmp() has been renamed to mh_strcasecmp().

Joel Reicher <jjr>
Project Member
Thu 14 Dec 2006 04:13:54 PM UTC, comment #1:

The problem appears to be that gcc with -O2 is emitting code for its own version of strcasecmp() instead of building what's present in sbr/strcasecmp.c. I ran into the problem on FC5, using GCC 4.1.1 20060525 (Red Hat 4.1.1-1).

The crash occurs when show invokes mhl, which calls strcasecmp().

A simple test program to demonstrate the program (stest.c) is:
#include <stdio.h>

main(int argc, char *argv[])
{
printf("Result: %u\n", strcasecmp(NULL, "test_string");
}

Using GCC 4.x, compilie and link this with strcasecmp.o, like so:
cc -O2 -o stest strcasecmp.o stest.c
and it will dump core when run.

I could be completely wrong here, but I believe that GCC sees the function name "strcasecmp", and says, "Hey! I've got a builtin for this. Here's the code." The code it supplies has no check for NULL, so when NULL is passed in, KA-BOOM!. If strcasecmp.c is built with the -fno-builtin-strcasecmp switch, the correct code (with NULL checks and tolower() calls) is be generated.

In a way, the fix has already been applied to CVS because strcasecmp() was renamed mh_strcasecmp() in March of 2006, which works around the problem. (I suspect that this bug was why the function was renamed.)

So, to solve the problem, take your pick of the following solutions:
1) Get and build the source from CVS
2) If you're building from source, apply the patch found at:
http://lists.gnu.org/archive/html/nmh-commits/2006-03/msg00013.html
3) Change the function name in an scripted fashion:
find . -type f -name \*.[ch] -print |
xargs grep casecmp |
sed -e 's/:.*$//' |
sort -u |
while read f; do
cp $f $f.orig
sed -e 's/strcasecmp/mh_strcasecmp/g' \
-e 's/strncasecmp/mh_strncasecmp/g' $f > $f.new
cp $f.new $f
done

4) Build sbr/strcasecmp.c by itself, specifying the -fno-builtin-strcasecmp flag, and built the rest by itself.
5) Persuade someone that GCC 4.x is pervasive enough in the community to warrant either a patch or release. ;-)

m@ <mxbraun>
Fri 09 Jun 2006 03:14:45 PM UTC, original submission:

I installed OpenSuse 10.1 (contains nmh 1.1 RC 4) on two machines (one from scratch), and on both "show" resulted in a segmentation fault. Then I compiled version 1.2, which still produced the same error.

The error disappeared when I compiled the same version with the --enable-debug option.

Andrej

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jjr (Posted a comment)
  • -unavailable- added by mxbraun (Posted a comment)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 10 Apr 2007 07:25:07 AM UTCjjrStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1