[Bug target/18929] Profiling optimized code causes segfaults on ARM due to missing frames

2004-12-13 Thread opensource at artnaseef dot com

--- Additional Comments From opensource at artnaseef dot com  2004-12-13 
15:55 ---
Subject: Re:  Profiling optimized code causes segfaults on
 ARM due to missing frames

Alright, since my instructions are not good enough for you, I will
put together an example.


rearnsha at gcc dot gnu dot org wrote:

>--- Additional Comments From rearnsha at gcc dot gnu dot org  2004-12-13 
>15:43 ---
>Subject: Re:  Profiling optimized code causes segfaults
>   on ARM due to missing frames
>
>On Mon, 2004-12-13 at 15:28, opensource at artnaseef dot com wrote:
>
>>--- Additional Comments From opensource at artnaseef dot com  2004-12-13 
>>15:28 ---
>>Subject: Re:  Profiling optimized code causes segfaults on
>> ARM due to missing frames
>>
>>Two things
>>
>>  1. Why do you not think the  patch is correct?  It works great for 
>>me.  Without
>> that information, I can only respond with "I think you are wrong," 
>>and that
>> is not productive.
>>
>>
>Because I don't think profiling should need the a frame pointer to
>work.  If it does, then my feeling is that it's the profiling code
>that's broken, not the compiler.  The layout of a stack frame is private
>to the function that built it, and any code outside of that function
>that tries to probe it is simply broken.
>
>
>>  2. The comment in the patch you show is that the Profiler clobbers the 
>>Link
>> Register.  That is NOT this problem.
>>
>>
>
>Well, that patch was never applied to the 3.3 branch.  The bug it refers
>to was reported against 3.0, so there's a strong likelihood that it will
>be needed in 3.3 as well.
>
>
>>In this problem, the profiler causes a segmentation fault when it reads 
>>the wrong
>>return address off the stack and uses it as an invalid function 
>>address.  It does
>>not use the link register value.
>>
>>To reproduce the problem:
>>
>>  - Build an arm-linux toolchain
>>
>>  - Compile a program with optimization and profiling (try -O2 and -pg).
>>
>> - Make sure the program includes a function for which the optimizer
>>   drops its frame pointer (this can easily be verified by looking at
>>   the assembly output of the compiler).
>>
>>  - Run the program.
>>
>>If a trace is needed, I will be able to produce one within a few days
>>and provide an example.  Note that this problem was quite easy for me
>>to reproduce, so I would expect reproducing it to be simple enough for
>>others.
>>
>
>I'm not in the business of trying to second guess how you encountered a
>problem.  If you want us to investigate a bug then you need to send us
>precise instructions (including source code) so that we can reproduce
>it.
>
>
>



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18929


[Bug target/18929] Profiling optimized code causes segfaults on ARM due to missing frames

2004-12-13 Thread opensource at artnaseef dot com

--- Additional Comments From opensource at artnaseef dot com  2004-12-13 
15:28 ---
Subject: Re:  Profiling optimized code causes segfaults on
 ARM due to missing frames

Two things

  1. Why do you not think the  patch is correct?  It works great for 
me.  Without
 that information, I can only respond with "I think you are wrong," 
and that
 is not productive.

  2. The comment in the patch you show is that the Profiler clobbers the 
Link
 Register.  That is NOT this problem.

In this problem, the profiler causes a segmentation fault when it reads 
the wrong
return address off the stack and uses it as an invalid function 
address.  It does
not use the link register value.

To reproduce the problem:

  - Build an arm-linux toolchain

  - Compile a program with optimization and profiling (try -O2 and -pg).

 - Make sure the program includes a function for which the optimizer
   drops its frame pointer (this can easily be verified by looking at
   the assembly output of the compiler).

  - Run the program.

If a trace is needed, I will be able to produce one within a few days
and provide an example.  Note that this problem was quite easy for me
to reproduce, so I would expect reproducing it to be simple enough for
others.

Let me know if you have trouble reproducing it.

rearnsha at gcc dot gnu dot org wrote:

>--- Additional Comments From rearnsha at gcc dot gnu dot org  2004-12-13 
>11:44 ---
>I don't think that patch is correct.  Please try the one from bug 3724:
>
>http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/linux-elf.h.diff?cvsroot=gcc&r1=1.39&r2=1.40
>
>Also, please add a testcase if you want further investigation.
>
>



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18929


[Bug target/18929] Profiling optimized code causes segfaults on ARM due to missing frames

2004-12-10 Thread opensource at artnaseef dot com

--- Additional Comments From opensource at artnaseef dot com  2004-12-10 
18:40 ---
Subject: Re:  Profiling optimized code causes segfaults
on ARM due to missing frames

I have not tested it, but I don't see why not.  The patch is fairly short and 
straight-forward, I believe.

-- Original Message -
Subject: [Bug target/18929] Profiling optimized code causes segfaults on ARM 
due to missing frames
Date: 10 Dec 2004 18:20:04 -
From: "pinskia at gcc dot gnu dot org" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]



--- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-10 
18:20 ---
Does this work in 3.4.?

-- 
   What|Removed |Added

  Component|c   |target


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18929

--- You are receiving this mail because: ---
You reported the bug, or are watching the reporter.
You are on the CC list for the bug, or are watching someone who is.





-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18929


[Bug c/18929] Profiling optimized code causes segfaults on ARM due to missing frames

2004-12-10 Thread opensource at artnaseef dot com

--- Additional Comments From opensource at artnaseef dot com  2004-12-10 
18:19 ---
Created an attachment (id=7720)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7720&action=view)
recommended fix

This patch fixes the problem by forcing functions to keep their frame pointers
when compiled with profiling.  It maintains portability by using a macro, and
only defining it for the ARM architecture, that indicates when mcount requires
the frame pointer.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18929


[Bug c/18929] New: Profiling optimized code causes segfaults on ARM due to missing frames

2004-12-10 Thread opensource at artnaseef dot com
When compiling with the arm-linux compiler with optimization enabled, the 
compiler removes frame pointers from functions even when they are profiled.  
This leads to a segmentation fault with the glibc version of mcount when it 
attempts to determine the caller of a function from the current stack because 
mcount assumes the frame pointer is there.

It seems that optimized functions, on this platform, should not drop their 
frame 
pointers when profiling is enabled.

-- 
   Summary: Profiling optimized code causes segfaults on ARM due to
missing frames
   Product: gcc
   Version: 3.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: opensource at artnaseef dot com
CC: gcc-bugs at gcc dot gnu dot org,opensource at artnaseef
dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18929