From 1ebf88ed9e75b46b0e0a4baf2babc5ccbe0e6cb8 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Thu, 30 Nov 2006 17:03:48 +0000 Subject: [PATCH] 1.0.0.3: correct stack start addresses on Windows * based on patch by Alastair Bridgewater. * add AB to initials glossary and sort it by initials. --- CREDITS | 29 +++++++++++++++-------------- src/runtime/x86-win32-os.c | 36 ++++++++++++++++++------------------ version.lisp-expr | 2 +- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/CREDITS b/CREDITS index b876c71..f480358 100644 --- a/CREDITS +++ b/CREDITS @@ -790,24 +790,25 @@ Raymond Wiker: INITIALS GLOSSARY (helpful when reading comments, CVS commit logs, etc.) -VJA Vincent Arkesteijn -MNA Martin Atzmueller -DB Daniel Barlow (also "dan") -DTC Douglas Crosher +AB Alastair Bridgewater +AL Arthur Lemmens APD Alexey Dejneka -PFD Paul F. Dietz -NJF Nathan Froyd CLH Cyrus Harmon -AL Arthur Lemmens -DFL David Lichteblau -RAM Robert MacLachlan -PRM Pierre Mai -MG Gabor Melis -WHN William ("Bill") Newman CSR Christophe Rhodes +DB Daniel Barlow (also "dan") +DFL David Lichteblau +DTC Douglas Crosher +JES Juho Snellman JRXR Joshua Ross -THS Thiemo Seufer +MG Gabor Melis +MNA Martin Atzmueller +NJF Nathan Froyd NS Nikodemus Siivola -JES Juho Snellman +PFD Paul F. Dietz +PRM Pierre Mai PVE Peter Van Eynde PW Paul Werkowski +RAM Robert MacLachlan +THS Thiemo Seufer +VJA Vincent Arkesteijn +WHN William ("Bill") Newman diff --git a/src/runtime/x86-win32-os.c b/src/runtime/x86-win32-os.c index 0b15ad2..13f3233 100644 --- a/src/runtime/x86-win32-os.c +++ b/src/runtime/x86-win32-os.c @@ -42,32 +42,32 @@ #include "validate.h" size_t os_vm_page_size; -int arch_os_thread_init(struct thread *thread) { +int arch_os_thread_init(struct thread *thread) +{ { void *top_exception_frame; void *cur_stack_end; void *cur_stack_start; - + MEMORY_BASIC_INFORMATION stack_memory; + asm volatile ("movl %%fs:0,%0": "=r" (top_exception_frame)); asm volatile ("movl %%fs:4,%0": "=r" (cur_stack_end)); - /* - * Can't pull stack start from fs:4 or fs:8 or whatever, + /* Can't pull stack start from fs:4 or fs:8 or whatever, * because that's only what currently has memory behind - * it from being used. Our basic options are to know, - * a priori, what the stack size is (1 meg by default) - * or to grub the default size out of the executable - * header in memory by means of hardcoded addresses and - * offsets. - * - * We'll just assume it's 1 megabyte. Easiest that way. - */ - cur_stack_start = cur_stack_end - 0x100000; - - /* - * We use top_exception_frame rather than cur_stack_end - * to elide the last few (boring) stack entries at the - * bottom of the backtrace. + * it from being used, so do a quick VirtualQuery() and + * grab the AllocationBase. -AB 2006/11/25 + */ + + if (!VirtualQuery(&stack_memory, &stack_memory, sizeof(stack_memory))) { + fprintf(stderr, "VirtualQuery: 0x%lx.\n", GetLastError()); + lose("Could not query stack memory information."); + } + cur_stack_start = stack_memory.AllocationBase; + + /* We use top_exception_frame rather than cur_stack_end to + * elide the last few (boring) stack entries at the bottom of + * the backtrace. */ thread->control_stack_start = cur_stack_start; thread->control_stack_end = top_exception_frame; diff --git a/version.lisp-expr b/version.lisp-expr index ace9742..40e453c 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.0.2" +"1.0.0.3" -- 1.7.10.4