paulfloyd / freebsdarm64_valgrind

[UNMAINTAINED] Repo used during the development of Valgrind for FreeBSD arm64. The code has been merged upstream so I won't be maintaining this repo.
GNU General Public License v2.0
1 stars 0 forks source link

Optimized build crashes #10

Closed paulfloyd closed 7 months ago

paulfloyd commented 7 months ago

This is not good.

I had been building with "-g" rather than "-O2 -g".

I put back the optimization and I get crashes right at the start when trying to read V's procmap.

paulfloyd commented 7 months ago

I've made a fair bit of progress with this.

The problem now is that running with -d crashes. The debug log is pretty nasty, basic C and asm. It's supposed to have a small buffer of 100bytes that it flushes whenever it gets to 80 capacity.

typedef 
   struct {
      HChar buf[100];
      Int   n;
   } 
   printf_buf;

static void add_to_buf ( HChar c, void* p )
{
   printf_buf* buf = (printf_buf*)p;

   if (buf->n >= 100-10 /*paranoia*/ ) {
      emit( buf->buf, local_strlen(buf->buf) );
      buf->n = 0;
      buf->buf[buf->n] = 0;      
   }
   buf->buf[buf->n++] = c;
   buf->buf[buf->n] = 0;
}

I'm seeing a crash when there are 90 characters

Maybe this

static 
UInt myvprintf_int64 ( void(*send)(HChar,void*), 
                       void* send_arg2,
                       Int flags, 
                       Int base, 
                       Int width, 
                       Bool capitalised,
                       ULong p )
{
   /* To print an ULong base 2 needs 64 characters. If commas are requested,
      add 21. Plus 1 for a possible sign plus 1 for \0. Makes 87 -- so let's
      say 90. The size of BUF needs to be max(90, WIDTH + 1) */
   HChar  buf[width + 1 > 90 ? width + 1 : 90];

but we should be far from that limit in hex.

paulfloyd commented 7 months ago

commit 28ecab3577caf03a0e1ad3f70ec6fcc98dda35eb (HEAD -> freebsdarm64_valgrind, github/freebsdarm64_valgrind) Author: Paul Floyd pjfloyd@wanadoo.fr Date: Sun Mar 10 08:31:09 2024 +0100

Put back optimization

Several fixes to clobbers and using the correct type (UInt or ULong)
to match arm64 register widths.