[Bug gcov-profile/97594] [11 Regression] new test case gcc.dg/tree-prof/pr97461.c execution failure

2020-11-06 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97594

Martin Liška  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #5 from Martin Liška  ---
Fixed in r11-4785-g15bcd01a94c23f312ac03b5faea29f18ef8d2a07.

[Bug gcov-profile/97594] [11 Regression] new test case gcc.dg/tree-prof/pr97461.c execution failure

2020-11-06 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97594

--- Comment #4 from Martin Liška  ---
Thank you Kewen, the patch works! The analysis is correct, what a stupid
mistake from my side :P.

[Bug gcov-profile/97594] [11 Regression] new test case gcc.dg/tree-prof/pr97461.c execution failure

2020-11-05 Thread linkw at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97594

--- Comment #3 from Kewen Lin  ---


(In reply to Martin Liška from comment #2)
> (In reply to Martin Liška from comment #1)
> > Mine, I see a strange error:
> > 
> > $ Program received signal SIGBUS, Bus error.
> > 0x3fffb7ceddbc in __GI__IO_link_in () from /lib64/libc.so.6
> > Missing separate debuginfos, use: debuginfo-install
> > glibc-2.17-307.el7.1.ppc64le
> > (gdb) bt
> > #0  0x3fffb7ceddbc in __GI__IO_link_in () from /lib64/libc.so.6
> > #1  0x3fffb7cebe58 in _IO_new_file_init_internal () from 
> > /lib64/libc.so.6
> 
> All right, so the test-case overloads malloc and returns a memory that is a
> static buffer. For some reason, it leads to SEGBUS.
> Do Power people know what's causing that?

I was testing the patch for PR97705 and met this issue during regression
testing, happened to notice this PR and just realized this one is also a random
issue. (how lucky I am :-))

Checked the assembly insn causing the SEGBUS

   0x77cc6940 <+240>:   beq 0x77cc6b30 <__GI__IO_link_in+736>
   0x77cc6944 <+244>:   li  r9,1
   0x77cc6948 <+248>:   clrldi  r10,r10,32
=> 0x77cc694c <+252>:   lwarx   r8,0,r3
   0x77cc6950 <+256>:   subf.   r8,r10,r8

r3 0x100207e6  268568550

As Power ISA pointed out, the EA for lwarx must be a multiple of 4. "If it is
not, either the system alignment error handler is invoked or the results are
boundedly undefined."

So the code of function __GI__IO_link_in has already assumed the address there
would have one reasonable alignment.

By checking the manual of malloc/calloc, it says:

   RETURN VALUE
 The malloc() and calloc() functions return a pointer to the 
 allocated memory, which is  suitably  aligned  for any built-in
 type.  On error, these functions return NULL.  NULL may also be
 returned by a successful call to malloc() with a size of zero,
 or by a successful call to calloc() with nmemb or size equal to
 zero.

I think the assumption there is reasonable, the addresses returned from
user-overloaded malloc/calloc should also take care of this alignment
requirement and adjust the return address respecting this.

The below small patch can get the case to pass.

$ diff ~/gcc/gcc-git/gcc/testsuite/gcc.dg/tree-prof/pr97461.c pr97461.c
20a21,26
> /* The malloc() and calloc() functions return a pointer to the allocated
>memory, which is suitably aligned for any built-in type.  Use 16
>bytes here as the basic alignment requirement for user-defined malloc
>and calloc.  See PR97594 for the details.  */
> #define ROUND_UP_FOR_16B_ALIGNMENT(x) ((x + 15) & (-16))
>
23c29
< memory_p += size;
---
> memory_p += ROUND_UP_FOR_16B_ALIGNMENT (size);

[Bug gcov-profile/97594] [11 Regression] new test case gcc.dg/tree-prof/pr97461.c execution failure

2020-10-27 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97594

--- Comment #2 from Martin Liška  ---
(In reply to Martin Liška from comment #1)
> Mine, I see a strange error:
> 
> $ Program received signal SIGBUS, Bus error.
> 0x3fffb7ceddbc in __GI__IO_link_in () from /lib64/libc.so.6
> Missing separate debuginfos, use: debuginfo-install
> glibc-2.17-307.el7.1.ppc64le
> (gdb) bt
> #0  0x3fffb7ceddbc in __GI__IO_link_in () from /lib64/libc.so.6
> #1  0x3fffb7cebe58 in _IO_new_file_init_internal () from /lib64/libc.so.6
> #2  0x3fffb7cd9dcc in fdopen@@GLIBC_2.17 () from /lib64/libc.so.6
> #3  0x10002928 in __gcov_open (name=0x100204f0 
> "/home/marxin/Programming/gcc/objdir/gcc/testsuite/gcc35/pr97461.gcda") at
> ../../../libgcc/../gcc/gcov-io.c:171
> #4  0x10002db8 in gcov_exit_open_gcda_file (gi_ptr=0x10020408,
> gi_ptr=0x10020408, gf=) at
> ../../../libgcc/libgcov-driver-system.c:312
> #5  dump_one_gcov (run_max=, run_counted=,
> gf=, gi_ptr=0x10020408) at
> ../../../libgcc/libgcov-driver.c:478
> #6  gcov_do_dump (list=, run_counted=) at
> ../../../libgcc/libgcov-driver.c:555
> #7  0x100047d8 in __gcov_dump_one (root=0x10040590 <__gcov_root>) at
> ../../../libgcc/libgcov-driver.c:578
> #8  __gcov_dump_one (root=0x10040590 <__gcov_root>) at
> ../../../libgcc/libgcov-driver.c:573
> #9  __gcov_exit () at ../../../libgcc/libgcov-driver.c:600
> #10 0x1e18 in _sub_D_00100_1 ()
> #11 0x3fffb7fc7c68 in _dl_fini () from /lib64/ld64.so.2
> #12 0x3fffb7ca4a34 in __run_exit_handlers () from /lib64/libc.so.6
> #13 0x3fffb7ca4a84 in exit () from /lib64/libc.so.6
> #14 0x3fffb7c85308 in generic_start_main.isra.0 () from /lib64/libc.so.6
> #15 0x3fffb7c854f4 in __libc_start_main () from /lib64/libc.so.6
> #16 0x in ?? ()

All right, so the test-case overloads malloc and returns a memory that is a
static buffer. For some reason, it leads to SEGBUS.
Do Power people know what's causing that?

[Bug gcov-profile/97594] [11 Regression] new test case gcc.dg/tree-prof/pr97461.c execution failure

2020-10-27 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97594

Martin Liška  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |marxin at gcc dot 
gnu.org
 Ever confirmed|0   |1
 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2020-10-27

--- Comment #1 from Martin Liška  ---
Mine, I see a strange error:

$ Program received signal SIGBUS, Bus error.
0x3fffb7ceddbc in __GI__IO_link_in () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install
glibc-2.17-307.el7.1.ppc64le
(gdb) bt
#0  0x3fffb7ceddbc in __GI__IO_link_in () from /lib64/libc.so.6
#1  0x3fffb7cebe58 in _IO_new_file_init_internal () from /lib64/libc.so.6
#2  0x3fffb7cd9dcc in fdopen@@GLIBC_2.17 () from /lib64/libc.so.6
#3  0x10002928 in __gcov_open (name=0x100204f0 
"/home/marxin/Programming/gcc/objdir/gcc/testsuite/gcc35/pr97461.gcda") at
../../../libgcc/../gcc/gcov-io.c:171
#4  0x10002db8 in gcov_exit_open_gcda_file (gi_ptr=0x10020408,
gi_ptr=0x10020408, gf=) at
../../../libgcc/libgcov-driver-system.c:312
#5  dump_one_gcov (run_max=, run_counted=,
gf=, gi_ptr=0x10020408) at
../../../libgcc/libgcov-driver.c:478
#6  gcov_do_dump (list=, run_counted=) at
../../../libgcc/libgcov-driver.c:555
#7  0x100047d8 in __gcov_dump_one (root=0x10040590 <__gcov_root>) at
../../../libgcc/libgcov-driver.c:578
#8  __gcov_dump_one (root=0x10040590 <__gcov_root>) at
../../../libgcc/libgcov-driver.c:573
#9  __gcov_exit () at ../../../libgcc/libgcov-driver.c:600
#10 0x1e18 in _sub_D_00100_1 ()
#11 0x3fffb7fc7c68 in _dl_fini () from /lib64/ld64.so.2
#12 0x3fffb7ca4a34 in __run_exit_handlers () from /lib64/libc.so.6
#13 0x3fffb7ca4a84 in exit () from /lib64/libc.so.6
#14 0x3fffb7c85308 in generic_start_main.isra.0 () from /lib64/libc.so.6
#15 0x3fffb7c854f4 in __libc_start_main () from /lib64/libc.so.6
#16 0x in ?? ()

[Bug gcov-profile/97594] [11 Regression] new test case gcc.dg/tree-prof/pr97461.c execution failure

2020-10-27 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97594

Richard Biener  changed:

   What|Removed |Added

Summary|new test case   |[11 Regression] new test
   |gcc.dg/tree-prof/pr97461.c  |case
   |execution failure   |gcc.dg/tree-prof/pr97461.c
   ||execution failure
 CC||marxin at gcc dot gnu.org
   Target Milestone|--- |11.0
  Component|other   |gcov-profile