www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 893] New: The profile flag no longer seems to work on Linux x86 64

reply d-bugmail puremagic.com writes:

           Summary: The profile flag no longer seems to work on Linux x86 64
           Product: D
           Version: 1.003
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: kevinbealer gmail.com

The -profile flag no longer works for me.  I am compiling under 64 bit linux on
a dual core machine (the binaries are 32 bit of course).  This is broken on 1.0
and 1.003 at least.

If I look at it in gdb, I see this as the crash point.
0x0804a365 in _D6object6Object5opCmpMFC6ObjectZi ()

The insns at this point (I replace the mangled name from each line with
"function" to make it easier to read, look for the line marked with <<<.

Dump of assembler code for function _D6object6Object5opCmpMFC6ObjectZi:
0x0804a344 <function+0>:      push   %ebp
0x0804a345 <function+1>:      mov    %esp,%ebp
0x0804a347 <function+3>:      sub    $0xc,%esp
0x0804a34a <function+6>:      push   %ebx
0x0804a34b <function+7>:      push   %esi
0x0804a34c <function+8>:      mov    %eax,0xfffffff8(%ebp)
0x0804a34f <function+11>:     mov    $0x805e790,%ecx
0x0804a354 <function+16>:     push   %ecx
0x0804a355 <function+17>:     call   0x80555e8 <_d_newclass>
0x0804a35a <function+22>:     add    $0x4,%esp
0x0804a35d <function+25>:     mov    %eax,0xfffffffc(%ebp)
0x0804a360 <function+28>:     push   $0x1
0x0804a362 <function+30>:     mov    0xfffffff8(%ebp),%edx
0x0804a365 <function+33>: <<< mov    (%edx),%ebx
0x0804a367 <function+35>:     mov    (%ebx),%esi
0x0804a369 <function+37>:     pushl  0x14(%esi)
0x0804a36c <function+40>:     pushl  0x10(%esi)
0x0804a36f <function+43>:     pushl  0x805afd6
0x0804a375 <function+49>:     pushl  0x805afd2
0x0804a37b <function+55>:     call   0x80561c4 <_d_arraycat>
0x0804a380 <function+60>:     add    $0x14,%esp
0x0804a383 <function+63>:     push   %edx
0x0804a384 <function+64>:     push   %eax
0x0804a385 <function+65>:     mov    0xfffffffc(%ebp),%eax
0x0804a388 <function+68>:     call   0x804b404
0x0804a38d <function+73>:     push   %eax
0x0804a38e <function+74>:     call   0x8057f5c <_d_throw 4>
0x0804a393 <function+79>:     pop    %esi
0x0804a394 <function+80>:     pop    %ebx
0x0804a395 <function+81>:     mov    %ebp,%esp
0x0804a397 <function+83>:     pop    %ebp
0x0804a398 <function+84>:     ret    $0x4
0x0804a39b <function+87>:     nop
End of assembler dump.

(gdb) info reg
eax            0x556e4fe0       1433292768
ecx            0x0      0
edx            0x18     24
ebx            0x1      1
esp            0xffffd0fc       0xffffd0fc
ebp            0xffffd114       0xffffd114
esi            0x1      1
edi            0x1      1
eip            0x804a365        0x804a365
eflags         0x10296  66198
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x0      0
gs             0x63     99

Just for completeness:

import std.stdio;

int main(char[][] x)
    return 0;

$ dmd -ofhello hello.d
$ ./hello
$ dmd -ofhello hello.d -profile
$ ./hello
Segmentation fault

Jan 26 2007
next sibling parent d-bugmail puremagic.com writes:

------- Comment #1 from hhasemann web.de  2007-02-05 08:24 -------
I could reproduce this on a Turion64 X2 (x86_64 dual core), running completely
in 32 Bit mode.
Interestingly the segfault occures in main (not _Dmain) when you have just an
empty main function:

$ cat proftst.d 
void main() {

$ dmd ./proftst.d
gcc proftst.o -o proftst -m32 -lphobos -lpthread -lm 
$ ./proftst

$ dmd -profile ./proftst.d
gcc proftst.o -o proftst -m32 -lphobos -lpthread -lm
$ ./proftst
Segmentation fault

With GDB:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1210202432 (LWP 3357)]
0x0804a333 in main ()
(gdb) info reg
eax            0x9      9
ecx            0x1      1
edx            0xfefeff00       -16843008
ebx            0x1      1
esp            0xbfa48ba8       0xbfa48ba8
ebp            0xbfa48ba8       0xbfa48ba8
esi            0x1      1
edi            0x1      1
eip            0x804a333        0x804a333 <main+87>
eflags         0x10216  [ PF AF IF RF ]
cs             0x73     115
ss             0x7b     123
ds             0x7b     123
es             0x7b     123
fs             0x0      0
gs             0x33     51

Critical row is marked below with ">>>":

Disassembly of section .gnu.linkonce.tmain:

0804a2dc <main>:
 804a2dc:       55                      push   %ebp
 804a2dd:       8b ec                   mov    %esp,%ebp
 804a2df:       83 ec 14                sub    $0x14,%esp
 804a2e2:       53                      push   %ebx
 804a2e3:       56                      push   %esi
 804a2e4:       57                      push   %edi
 804a2e5:       8b 7d 08                mov    0x8(%ebp),%edi
 804a2e8:       8b 5d 0c                mov    0xc(%ebp),%ebx
 804a2eb:       c7 45 f4 00 00 00 00    movl   $0x0,0xfffffff4(%ebp)
 804a2f2:       e8 dd fb ff ff          call   8049ed4
 804a2f7:       e8 3c fb ff ff          call   8049e38 <_STI_critical_init>
 804a2fc:       e8 53 95 00 00          call   8053854 <gc_init>
 804a301:       8b cf                   mov    %edi,%ecx
 804a303:       c1 e1 03                shl    $0x3,%ecx
 804a306:       51                      push   %ecx
 804a307:       e8 28 f3 ff ff          call   8049634 <malloc plt>
 804a30c:       89 45 f0                mov    %eax,0xfffffff0(%ebp)
 804a30f:       83 c4 04                add    $0x4,%esp
 804a312:       80 3d 40 1e 06 08 00    cmpb   $0x0,0x8061e40
 804a319:       74 4b                   je     804a366 <main+0x8a>
 804a31b:       e8 0c 01 00 00          call   804a42c <_moduleCtor>
 804a320:       e8 cf 02 00 00          call   804a5f4 <_moduleUnitTests>
 804a325:       31 f6                   xor    %esi,%esi
 804a327:       85 ff                   test   %edi,%edi
 804a329:       7e 1d                   jle    804a348 <main+0x6c>
 804a32b:       ff 34 b3                pushl  (%ebx,%esi,4)
 804a32e:       e8 11 f4 ff ff          call   8049744 <strlen plt>
 804a333:  >>>  8b 14 b3                mov    (%ebx,%esi,4),%edx
 804a336:       8b 4d f0                mov    0xfffffff0(%ebp),%ecx
 804a339:       89 04 f1                mov    %eax,(%ecx,%esi,8)
 804a33c:       89 54 f1 04             mov    %edx,0x4(%ecx,%esi,8)
 804a340:       46                      inc    %esi
 804a341:       83 c4 04                add    $0x4,%esp
 804a344:       39 fe                   cmp    %edi,%esi
 804a346:       7c e3                   jl     804a32b <main+0x4f>

Feb 05 2007
prev sibling parent d-bugmail puremagic.com writes:

bugzilla digitalmars.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

------- Comment #2 from bugzilla digitalmars.com  2007-02-12 03:42 -------
Fixed DMD 1.005

Feb 12 2007