gcc 4.3.1-lubuntu2 debug code crashes in 8.10 with sigsegv in strlen

Bug #328908 reported by Andrew Robb
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-defaults (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: gcc

I have a small source file which produces a sigsegv in debug code but runs fine optimised to -O3. However, assembler from SuSE compiler or gcc 4.3.3 built on ubuntu 8.10 from gcc.gnu.org source does not crash.

$ apt-cache policy gcc
gcc:
  Installed: 4:4.3.1-1ubuntu2
  Candidate: 4:4.3.1-1ubuntu2
  Version table:
 *** 4:4.3.1-1ubuntu2 0
        500 http://gb.archive.ubuntu.com intrepid/main Packages
        100 /var/lib/dpkg/status

$ gcc -g soundex.c -o soundex
$ ./soundex burroughs ashcroft brc mcknight mcnaught mcknawght
strlen("burroughs")
B620 burroughs
strlen("ashcroft")
Segmentation fault

Package gcc-3.4 also causes crash:
$ gcc-3.4 -g soundex.c -o soundex
$ ./soundex burroughs ashcroft brc mcknight mcnaught mcknawght
strlen("burroughs")
B620 burroughs
strlen("ashcroft")
Segmentation fault

$ apt-cache policy gcc-3.4
gcc-3.4:
  Installed: 3.4.6-8ubuntu2
  Candidate: 3.4.6-8ubuntu2
  Version table:
 *** 3.4.6-8ubuntu2 0
        500 http://gb.archive.ubuntu.com intrepid/universe Packages
        100 /var/lib/dpkg/status

strlen() does not crash if optimised in line (or if I use a home-brew compiler or SuSE compiler):
$ gcc -O3 soundex.c -o soundex
$ ./soundex burroughs ashcroft brc mcknight mcnaught mcknawght
strlen("burroughs")
B620 burroughs
strlen("ashcroft")
A261 ashcroft
strlen("brc")
B620 brc
strlen("mcknight")
M252 mcknight
strlen("mcnaught")
M252 mcnaught
strlen("mcknawght")
M252 mcknawght

Revision history for this message
Andrew Robb (ajrobb) wrote :
Revision history for this message
Andrew Robb (ajrobb) wrote :

Many apologies, bug in line 66 of source - should be:

  while (src < end && dst < lim) {

I was polluting the stack - so hardly surprising that it crashed.

Changed in gcc-defaults:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.