Opened 6 years ago

Closed 6 years ago

#77 closed defect (fixed)

Fix stack size interpretation in CreateThread().

Reported by: dmik Owned by:
Priority: major Milestone: 0.8.4
Component: odin Version: 0.8.x
Severity: low Keywords:


Currently, the stack size passed to CreateThread?() is interpreted as the whole (maximum) stack size. Ноwever under real Windows, according to MSDN, this parameter by default specifies the size of the pre-committed area on top of the stack; the whole stack size is defined by the PE header in this case (1 MB by default). In order to override the header, the STACK_SIZE_PARAM_IS_A_RESERVATION flag must be used, so that the stack size in CreateThread?() will define the whole area.

Change History (3)

comment:1 Changed 6 years ago by dmik

See comment 7 in OpenJDK ticket 160.

Basically, the stack size parameter should be interpreted as follows (based on MSDN), where R is the total reserved stack size, C is a portion of it which is initially committed and PE is the stack size specified in the PE header (by default, 1 MB):

  1. 0 => R = PE, C is some default value from DosCreateThread?() (normally, 2-3 pages).
  2. N => if N < PE, R = PE, C = N; otherwise R = N rounded up to the 1 MB border, C = N.
  3. N and STACK_SIZE_PARAM_IS_A_RESERVATION => R = N, C is some default value from DosCreateThread?().

comment:2 Changed 6 years ago by dmik

  • Milestone changed from next to 0.8.4

comment:3 Changed 6 years ago by dmik

  • Resolution set to fixed
  • Status changed from new to closed

Done in r21981.

Note: See TracTickets for help on using tickets.