[Info-vax] debugging stack corruption on Macro64?

VAXman- at SendSpamHere.ORG VAXman- at SendSpamHere.ORG
Mon Mar 9 09:56:51 EDT 2015


In article <UeOdnWOeg9Uo2WDJnZ2dnUU7-S-dnZ2d at mchsi.com>, "John E. Malmberg" <wb8tyw at qsl.network> writes:
>On 3/8/2015 11:26 PM, John E. Malmberg wrote:
>>
>> The R17 value appears to be quadword aligned when the corruption occurs.
>
>I am now reproducing the stack corruption with this program once I made 
>a change to save some registers.  The test macro code does not use the 
>registers, the actual program does.
>
>
>EAGLE> type [.vms]test.c,test2.m64
>
>#define __NEW_STARLET 1
>#include <psigdef.h>
>#include <stdio.h>
>#include <builtins.h>
>#pragma message disable badptrarith
>
>extern void ffi_call_osf(void *stack, void *frame, unsigned flags,
>                          void *raddr, void (*fn)(void), void *closure);
>
>
>int main(int argc, char **argv) {
>
>unsigned long * argp;
>void * frame;
>unsigned flags;
>int ret_value;
>long long * stack;
>AIDEF *vms_ai;
>unsigned long long *vms_ai_llong;
>
>
>     argp = frame = __ALLOCA(8 * (6 + 4));
>     frame += (8 * 6);
>     vms_ai = (AIDEF *) frame;
>     vms_ai_llong = (unsigned long long *) frame;
>     vms_ai_llong[0] = 0;
>     vms_ai->ai$b_arg_count = 1;
>
>     flags = 1;
>     stack = (long long *) argp;
>     stack[0] = (long long)"test string";
>
>     ffi_call_osf(argp, frame, flags, &ret_value, (void (*)(void))puts, 
>NULL);
>
>}
>
>VMS_ROOT:[libffi.vms]test2.m64
>
>         .TITLE "VMS"
>
>         .PSECT MY_CODE,EXE,NOMIX
>         .align long
>
>         $ROUTINE ffi_call_osf,-
>                  SAVED_REGS=<R2,R3,R4,FP>,-
-------------------^^^^^^^^^^^^^^^^^^^^^^^^^

Why???  Save them yourself in your prologue is they're needed.  As far as
I can tell, you're not touching R2,R3 or R4 and you save frame pointer at
16 off the new stack space you've reserved.

-- 
VAXman- A Bored Certified VMS Kernel Mode Hacker    VAXman(at)TMESIS(dot)ORG

I speak to machines with the voice of humanity.



More information about the Info-vax mailing list