VirtualBox

Changeset 79495 in vbox for trunk/src/VBox/Runtime/r3/win


Ignore:
Timestamp:
Jul 3, 2019 12:52:53 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/thread-win.cpp: Don't give windows a 64KB aligned stack size, because then we won't get any overflow protection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/thread-win.cpp

    r76553 r79495  
    4444#include <iprt/log.h>
    4545#include <iprt/mem.h>
     46#include <iprt/param.h>
    4647#include "internal/thread.h"
    4748#include "internal-r3-win.h"
     
    265266
    266267    /*
     268     * If a stack size is given, make sure it's not a multiple of 64KB so that we
     269     * get one or more pages for overflow protection.  (ASSUMES 64KB alloc align.)
     270     */
     271    unsigned cbStack = (unsigned)pThread->cbStack;
     272    if (cbStack > 0 && RT_ALIGN_T(cbStack, _64K, unsigned) == cbStack)
     273        cbStack += PAGE_SIZE;
     274
     275    /*
    267276     * Create the thread.
    268277     */
    269278    pThread->hThread = (uintptr_t)INVALID_HANDLE_VALUE;
    270279    unsigned    uThreadId = 0;
    271     uintptr_t   hThread = _beginthreadex(NULL, (unsigned)pThread->cbStack, rtThreadNativeMain, pThread, 0, &uThreadId);
     280    uintptr_t   hThread   = _beginthreadex(NULL, cbStack, rtThreadNativeMain, pThread, 0, &uThreadId);
    272281    if (hThread != 0 && hThread != ~0U)
    273282    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette