1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-03-10 04:24:32 +00:00

Catch more pointer problems in NativeAligned4FromLAddr

This commit is contained in:
Nick Briggs
2023-07-22 15:37:14 -07:00
parent c74e7a0169
commit 1c6d366e3c

View File

@@ -28,11 +28,19 @@
*/
/**********************************************************************/
#include <execinfo.h>
#include <stddef.h>
#include <stdio.h>
#include "lispemul.h"
#include "lspglob.h"
static inline void dobacktrace()
{
void* callstack[128];
int i, frames = backtrace(callstack, 128);
backtrace_symbols_fd(callstack, frames, 2);
}
static inline LispPTR LAddrFromNative(void *NAddr)
{
if ((uintptr_t)NAddr & 1) {
@@ -48,8 +56,9 @@ static inline DLword *NativeAligned2FromLAddr(LispPTR LAddr)
static inline LispPTR *NativeAligned4FromLAddr(LispPTR LAddr)
{
if (LAddr & 1) {
printf("Misaligned pointer in NativeAligned4FromLAddr 0x%x\n", LAddr);
if (LAddr & 1 || LAddr > 0x0FFFFFFF) {
printf("Misaligned/bad pointer in NativeAligned4FromLAddr 0x%x\n", LAddr);
dobacktrace();
}
return (void *)(Lisp_world + LAddr);
}