NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

__builtin_frame_address hogs cpu



Hi,

tried to compile Ruby 2.1.1 on NetBSD-6.1.3/amd64. There was a "conftest.c" program run during the "./configure" phase, which was "checking for broken backtrace". The program made no progress so I created a customized version of it and realized, that a call to the function __builtin_frame_address() hogs cpu and never returns under certain conditions.

The conditions that make the __builtin_frame_address() function return are:
1) compile with "-O0" or
2) peek at __builtin_frame_address() earlier in the call stack

The second condition makes me suspicious, that this is a gcc bug.

My version of the test program (I included a shortened pkgsrc/devel/libexecinfo-1.1 directly to the source, original test program links to libexecinfo): http://pastebin.com/0jL9mhUh

Tests:
A)
$ gcc -o conftest3 -O2 conftest3.c
$ ./conftest3
getframeddr(2)
^C [terminate the cpu hog]

B)
$ gcc -o conftest3 -O0 conftest3.c
$ ./conftest3
getframeddr(2)
__builtin_frame_address(3) from getframeaddr :: 0x7f7fffffda80
getreturnaddr(1) returned 0x7f7ff7893d10
getframeddr(3)
__builtin_frame_address(3) from getframeaddr :: 0x7f7fffffda80
getreturnaddr(2) returned 0x400ae2
getframeddr(4)
__builtin_frame_address(3) from getframeaddr :: 0x7f7fffffda80
getreturnaddr(3) returned 0x0
backtrace: 2
$

C) (uncomment appropriate comments in conftest3.c)
$ gcc -o conftest3 -O2 conftest3.c
$ ./conftest3
__builtin_frame_address(3) from backtrace :: 0x7f7ffffffce4
getframeddr(2)
__builtin_frame_address(3) from getframeaddr :: 0x7f7fffffdac8
getreturnaddr(1) returned 0x0
sigsegv() :: abort()
Abort trap (core dumped)
$

D) (uncomment appropriate comments in conftest3.c)
$ gcc -o conftest3 -O2 conftest3.c
$ ./conftest3
__builtin_frame_address(3) from sigsegv :: 0x7f7ffffffce4
__builtin_frame_address(3) from backtrace :: 0x7f7fffffdac8
getframeddr(2)
__builtin_frame_address(3) from getframeaddr :: 0x60e900
getreturnaddr(1) returned 0x7f7ff7893d10
getframeddr(3)
__builtin_frame_address(3) from getframeaddr :: 0x60e900
getreturnaddr(2) returned 0x0
backtrace: 1
$

I am curious if this behavior of __builtin_frame_address() is expected.

Thanks,

r.


Home | Main Index | Thread Index | Old Index