[Bug gprofng/32096] UBSAN issues in gprofng

2024-09-11 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=32096

--- Comment #3 from Sourceware Commits  ---
The master branch has been updated by Vladimir Mezentsev
:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ad0751b6ecf40cb94ecb693d1acfc38fd223f408

commit ad0751b6ecf40cb94ecb693d1acfc38fd223f408
Author: Vladimir Mezentsev 
Date:   Tue Sep 10 21:05:19 2024 -0700

Fix 32096 UBSAN issues in gprofng

Fixed UBSAN runtime errors such as:
 - load of value 4294967295, which is not a valid value for type
'Cmsg_warn'
 - null pointer passed as argument 2, which is declared to never be null
 - load of value 4294967295, which is not a valid value for type
'ProfData_type'
 - reference binding to misaligned address 0x0357583c for type 'long
unsigned int', which requires 8 byte alignment

gprofng/ChangeLog
2024-09-09  Vladimir Mezentsev  .

PR gprofng/32096
* src/BaseMetric.cc: Fix UBSAN runtime errors.
* src/BaseMetric.h: Likewise.
* src/Emsg.h: Likewise.
* src/Experiment.cc: Likewise.
* src/Table.h: Likewise.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gprofng/32096] UBSAN issues in gprofng

2024-09-11 Thread arsen at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32096

Arsen Arsenović  changed:

   What|Removed |Added

 CC||arsen at sourceware dot org

--- Comment #4 from Arsen Arsenović  ---
(In reply to Vladimir Mezentsev from comment #2)
> I have fixes for these runtime errors:
>   load of value 4294967295, which is not a valid value for type 'Cmsg_warn'
>   null pointer passed as argument 2, which is declared to never be null
>   load of value 4294967295, which is not a valid value for type
> 'ProfData_type'
>   load of value 4294967295, which is not a valid value for type
> 'ProfData_type'
>   member access within misaligned address 0x0357583c for type 'union
> Value', which requires 8 byte alignment
>   reference binding to misaligned address 0x0357583c for type 'long
> unsigned int', which requires 8 byte alignment
> 
> 
> I see other errors like:
>  member call on address 0x03192cf0 which does not point to an object of
> type 'Vector'
> These errors look like a bug in libubsan.
> I don't see anything wrong in gprofng.

I think it's probably:

(gdb) break __ubsan::Diag::~Diag() 
Breakpoint 3 at 0x774bde20: file
/usr/src/debug/sys-devel/gcc-15.0.0_pre20240818/gcc-15-20240818/libsanitizer/ubsan/ubsan_diag.cpp,
line 351.
(gdb) r
Starting program: /home/arsen/gcc/binutils-bld/gprofng/src/gp-display-text
display text -metrics i.totalcpu -func test.er
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib64/libthread_db.so.1".
Warning: History and command editing is not supported on this system.
display: *** Error: not a valid experiment name
text: *** Error: not a valid experiment name
Current metrics: i.totalcpu:name
Current Sort Metric: Inclusive Total CPU Time ( i.totalcpu )

Breakpoint 3, __ubsan::Diag::~Diag (this=this@entry=0x7fffc050) at
/usr/src/debug/sys-devel/gcc-15.0.0_pre20240818/gcc-15-20240818/libsanitizer/ubsan/ubsan_diag.cpp:351
351 Diag::~Diag() {
(gdb) 
#3  0x55f96676 in CallStackP::add_stack (this=0x57558540,
dDscr=0x575572b0, idx=0, frp=, cstCtxChunk=)
at ../../../binutils-gdb/gprofng/src/CallStack.cc:635
635  CallStackNode *node = (CallStackNode*) add_stack
((Vector*)natpcs);
(gdb) list 472
467 // When pipeline optimization is turnd off, cstctxchunk passed is NULL
468 void
469 CallStackP::add_stack (DataDescriptor *dDscr, long idx, FramePacket
*frp,
470   cstk_ctx_chunk* cstCtxChunk)
471 {
472  Vector *natpcs = NULL;
473  cstk_ctx *cstctx = NULL;
474  int stack_size = frp->stackSize ();
475  if (cstCtxChunk != NULL)
476{
(gdb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gprofng/32096] UBSAN issues in gprofng

2024-09-11 Thread sam at gentoo dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32096

--- Comment #5 from Sam James  ---
Thanks for the fixes so far.

In addition to what Arsen said wrt Vector, I see this too:
```
unwind.c:1559:10: runtime error: load of misaligned address 0x623e5a670173 for
type 'int', which requires 4 byte alignment
0x623e5a670173: note: pointer points here
 d7  ff d0 b8 00 00 00 00 e8  69 e6 ff ff 48 8b 55 f8  48 89 82 88 00 00 00 b8 
00 00 00 00 e8 49 e6
  ^
#0 0x79413e876884 in read_int
/home/sam/git/binutils-gdb/gprofng/libcollector/unwind.c:1559
#1 0x79413e876884 in find_i386_ret_addr
/home/sam/git/binutils-gdb/gprofng/libcollector/unwind.c:3351
#2 0x79413e88372c in stack_unwind
/home/sam/git/binutils-gdb/gprofng/libcollector/unwind.c:4474
#3 0x79413e885353 in __collector_get_frame_info
/home/sam/git/binutils-gdb/gprofng/libcollector/unwind.c:601
#4 0x79413e818b82 in __collector_ext_profile_handler
/home/sam/git/binutils-gdb/gprofng/libcollector/profile.c:282
#5 0x79413de20fdf  (/usr/lib64/libc.so.6+0x1efdf)
#6 0x623e5a670695 in addone
/home/sam/git/binutils-gdb/gprofng/testsuite/gprofng.display/mttest/mttest.c:1139
#7 0x623e5a6704df in computeF
/home/sam/git/binutils-gdb/gprofng/testsuite/gprofng.display/mttest/mttest.c:1093
#8 0x623e5a670171 in calladd
/home/sam/git/binutils-gdb/gprofng/testsuite/gprofng.display/mttest/mttest.c:1008
#9 0x623e5a66f68d in do_work
/home/sam/git/binutils-gdb/gprofng/testsuite/gprofng.display/mttest/mttest.c:650
#10 0x79413e804be3 in collector_root
/home/sam/git/binutils-gdb/gprofng/libcollector/dispatcher.c:1123
#11 0x79413de7f708 in start_thread
/usr/src/debug/sys-libs/glibc-2.40-r1/glibc-2.40/nptl/pthread_create.c:447
#12 0x79413df03197 in __clone3
../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gprofng/32166] gprofn testsuite uses non-portable which

2024-09-11 Thread sam at gentoo dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32166

--- Comment #1 from Sam James  ---
I'll send a patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gprofng/32166] New: gprofn testsuite uses non-portable which

2024-09-11 Thread sam at gentoo dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32166

Bug ID: 32166
   Summary: gprofn testsuite uses non-portable which
   Product: binutils
   Version: unspecified
Status: NEW
  Severity: normal
  Priority: P2
 Component: gprofng
  Assignee: vladimir.mezentsev at oracle dot com
  Reporter: sam at gentoo dot org
  Target Milestone: ---

The gprofng seems to use `which` in a few places.

`which` isn't portable. Debian as well as other distros like Gentoo are trying
to remove it from their base system. See https://lwn.net/Articles/874049/.

For bash scripts, `type -P foo` is a good replacement. For POSIX shell scripts,
`command -v foo` is fine.

testsuite/lib/Makefile.skel has:
```
JAVABIN = $(shell dirname `which java`)
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gprofng/32166] gprofng testsuite uses non-portable which

2024-09-11 Thread sam at gentoo dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32166

Sam James  changed:

   What|Removed |Added

Summary|gprofn testsuite uses   |gprofng testsuite uses
   |non-portable which  |non-portable which

-- 
You are receiving this mail because:
You are on the CC list for the bug.