On Thu, 20 Jul 2023 19:32:33 -0700
Andrew Hewus Fresh <and...@afresh1.com> wrote:

> On Mon, Jul 17, 2023 at 11:54:18PM -0400, George Koehler wrote:
> > How to pread($fd, $buf, 4, 16)?
> > 
> >   1.  syscall(169, $fd, $buf, 4, 0, 16)
> >   2.  syscall(169, $fd, $buf, 4, 0, 0, 16)
> >   3.  syscall(169, $fd, $buf, 4, 16, 0)
> >   4.  syscall(169, $fd, $buf, 4, 0, 16, 0)
> >   5.  syscall(169, $fd, $buf, 4, 16)
> 
> Which is the way it works without the this middleman?

This is on macppc.  Without your diff is syscall(2).
With your diff is va_args(args, off_t).

pread(2) without your diff needs line 2,

$ perl 3</etc/passwd \                                
> -E 'syscall(169, 3, $_ = "c" x 7, 7, 0, 0, 11); say $_'
Charlie

pread(2) with your diff needs line 1,

$ perl 3</etc/passwd \                              
> -E 'syscall(169, 3, $_ = "c" x 7, 7, 0, 11); say $_'
Charlie

I don't know how it worked before we removed __syscall(2).

> > $ cd /usr/src/gnu/usr.bin/perl/obj
> > $ MALLOC_OPTIONS=S perl t/op/syscall_emulator.t  
> > /usr/include/sys/syscall.h -> /usr/include/sys/syscall.ph
> > 1..13
> > ok 1 - Opened test.txt for write/create
> > ok 2 - Wrote out to test.txt
> > ok 3 - closed test.txt
> > perl(15511) in malloc(): write after free 0xc36d1efcddc0
> > Abort trap (core dumped) 
> 
> Hmm, I guess I need to get a powerpc64 machine.

You didn't need a powerpc64.  The crash was random; if you ran the
test multiple times, then it would crash.  Your updated diff from
Thu 20 Jul doesn't crash.

Reply via email to