cmus compiled with clang crashes with sigill

Hello list,

cmus console music player (from
git://github.com/JasonWoof/cmus-unofficial.git) crashes at startup when
compiled with clang. Some gdb info:

    (gdb) run
    Starting program: /home/gregory/software/cmus/cmus
    [Thread debugging using libthread_db enabled]
    [New Thread 0xb7e536c0 (LWP 11351)]
    [New Thread 0xb6f8fb90 (LWP 11354)]
    [New Thread 0xb678eb90 (LWP 11355)]
    [New Thread 0xb5f8db90 (LWP 11356)]

    Program received signal SIGILL, Illegal instruction.
    [Switching to Thread 0xb7e536c0 (LWP 11351)]
    set_replaygain_preamp () at options.c:332
    332 val = strtod(buf, &end);
    Current language: auto; currently minimal

    (gdb) disassemble
    Dump of assembler code for function set_replaygain_preamp:
    0x08061200 <set_replaygain_preamp+0>: push %ebp
    0x08061201 <set_replaygain_preamp+1>: mov %esp,%ebp
    0x08061203 <set_replaygain_preamp+3>: push %esi
    0x08061204 <set_replaygain_preamp+4>: sub $0x14,%esp
    0x08061207 <set_replaygain_preamp+7>: lea -0x8(%ebp),%eax
    0x0806120a <set_replaygain_preamp+10>: mov %eax,0x4(%esp)
    0x0806120e <set_replaygain_preamp+14>: mov 0xc(%ebp),%esi
    0x08061211 <set_replaygain_preamp+17>: mov %esi,(%esp)
    0x08061214 <set_replaygain_preamp+20>: call 0x804f238 <strtod@plt>
    0x08061219 <set_replaygain_preamp+25>: fstpl -0x10(%ebp)
    0x0806121c <set_replaygain_preamp+28>: cmp %esi,-0x8(%ebp)
    0x0806121f <set_replaygain_preamp+31>: jne 0x8061233
<set_replaygain_preamp+51>
    0x08061221 <set_replaygain_preamp+33>: movl $0x80724d0,(%esp)
    0x08061228 <set_replaygain_preamp+40>: call 0x8069750 <error_msg>
    0x0806122d <set_replaygain_preamp+45>: add $0x14,%esp
    0x08061230 <set_replaygain_preamp+48>: pop %esi
    0x08061231 <set_replaygain_preamp+49>: pop %ebp
    0x08061232 <set_replaygain_preamp+50>: ret
    0x08061233 <set_replaygain_preamp+51>: movsd -0x10(%ebp),%xmm0
    0x08061238 <set_replaygain_preamp+56>: movsd %xmm0,(%esp)
    0x0806123d <set_replaygain_preamp+61>: call 0x8064660
<player_set_rg_preamp>
    0x08061242 <set_replaygain_preamp+66>: jmp 0x806122d
<set_replaygain_preamp+45>
    End of assembler dump.

    (gdb) disassemble $pc $pc+1
    Dump of assembler code from 0x8061233 to 0x8061234:
    0x08061233 <set_replaygain_preamp+51>: movsd -0x10(%ebp),%xmm0
    End of assembler dump.

    (gdb) info registers
    eax 0x40180000 1075314688
    ecx 0xbfe704dc -1075378980
    edx 0x80000 524288
    ebx 0x806e2b7 134668983
    esp 0xbfe70520 0xbfe70520
    ebp 0xbfe70538 0xbfe70538
    esi 0x82b6d7a 137063802
    edi 0x3 3
    eip 0x8061233 0x8061233 <set_replaygain_preamp+51>
    eflags 0x10212 [ AF IF RF ]
    cs 0x73 115
    ss 0x7b 123
    ds 0x7b 123
    es 0x7b 123
    fs 0x0 0
    gs 0x33 51

Can anybody please explain me what's going on?

        Gregory

Hello list,

cmus console music player (from
git://github.com/JasonWoof/cmus-unofficial.git) crashes at startup when
compiled with clang. Some gdb info:

[snip]

Program received signal SIGILL, Illegal instruction.
(gdb) disassemble $pc $pc+1
Dump of assembler code from 0x8061233 to 0x8061234:
0x08061233 <set_replaygain_preamp+51>: movsd -0x10(%ebp),%xmm0
End of assembler dump.

[snip]

Does your processor support SSE2? If not, there's a bug in the CPU
selection code.

-Eli

This has happened on AMD Duron, which AFAIK only supports SSE, not SSE2.

               Gregory

This is probably because clang defaults to SSE2. Try passing -mcpu=athlon-xp to clang.

-Chris

Thanks — that fixed the SIGILL issue. But why does clang defaults to
SSE2? It is more than strange when program compiled without any special
arch flags crashes due to use of SSE2. Wouldn't defaulting to 486 or
something like that make more sense?

  Gregory

We want clang to default to the native CPU type on linux, but noone has written the code to do it yet,

-Chris