[Info-vax] debugging stack corruption on Macro64?

John E. Malmberg wb8tyw at qsl.network
Mon Mar 9 20:31:36 EDT 2015


On 3/9/2015 8:56 AM, "VAXman- "@SendSpamHere.ORG wrote:
> 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.

The code that touches r2, r3, and r4 was removed from the example that I 
am getting the stack corruption on.

How does the $return macro know to restore them if I do not specify it 
as part of the $ROUTINE macro invocation.

I also have not found any documentation as to what order that I should 
be saving the registers on the stack.

Regards,
-John
wb8tyw at qsl.network.



More information about the Info-vax mailing list