on master help sign in
Fix potential memory error on tail calls

SLIDE needs to use 'memmove' rather than 'memcpy' because in the case that the called function has more arguments than the current stack frame, the regions will overlap, which would lead to undefined behaviour.

commitdd065f3245be9fa9079a84e3cc1d19ae367d8f6b authorEdwin Brady <ecb10@st-andrews.ac.uk> dateThu 25 Apr 2019, 11:08 (8 years ago) parenta93d8c9
1 file changed+1−1
rts/idris_rts.h+1−1
rts/idris_rts.h+1−1
@@ -332,7 +332,7 @@ size_t GETSTROFFLEN(VAL stroff);
332332#define PROJECT(vm,r,loc,num) \
333333 memcpy(&(LOC(loc)), ((Con*)(r))->args, sizeof(VAL)*num)
334334#define SLIDE(vm, args) \
335− memcpy(&(LOC(0)), &(TOP(0)), sizeof(VAL)*args)
335+ memmove(&(LOC(0)), &(TOP(0)), sizeof(VAL)*args)
336336
337337void* iallocate(VM *, size_t, int);
338338