SungHoon_Kim

How to check the default stack size of httpd.exe

Blog Post created by SungHoon_Kim Employee on Jan 25, 2016

ASF Apache 2.4 is certified with Web Agent on Windows Platform.

However, Apache service will not startup when Web Agent is integrated.

It is getting stack overflow exception.

 

The instruction is to use editbin and set the stack size to 512KB.

editbin /STACK:524288 httpd.exe

 

In many online documents are suggesting the default stack size is 1MB.

Then are we reducing the stack size by setting it to 512KB?

 

From research, the default stack size for httpd.exe from ASF Apache 2.4 was as below.

You will need to have "link.exe" that ships with Studio.

 

link /dump /headers httpd.exe

Original httpd.exe from ASF Apache 2.4.17

Microsoft (R) COFF/PE Dumper Version 8.00.50727.42

Copyright (C) Microsoft Corporation.  All rights reserved.

 

 

 

 

Dump of file httpd.exe

 

 

PE signature found

 

 

File Type: EXECUTABLE IMAGE

 

 

FILE HEADER VALUES

            8664 machine (x64)

               6 number of sections

        561A2F0A time date stamp Sun Oct 11 20:42:34 2015

               0 file pointer to symbol table

               0 number of symbols

              F0 size of optional header

              22 characteristics

                   Executable

                   Application can handle large (>2GB) addresses

 

 

OPTIONAL HEADER VALUES

             20B magic # (PE32+)

           14.00 linker version

            2C00 size of code

            4200 size of initialized data

               0 size of uninitialized data

            2FBC entry point (0000000140002FBC)

            1000 base of code

       140000000 image base (0000000140000000 to 000000014000BFFF)

            1000 section alignment

             200 file alignment

            6.00 operating system version

            0.00 image version

            6.00 subsystem version

               0 Win32 version

            C000 size of image

             400 size of headers

            C001 checksum

               3 subsystem (Windows CUI)

            8160 DLL characteristics

                   RESERVED - UNKNOWN

                   RESERVED - UNKNOWN

                   NX compatible

                   Terminal Server Aware

           40000 size of stack reserve

            1000 size of stack commit

          100000 size of heap reserve

            1000 size of heap commit

               0 loader flags

              10 number of directories

            58E0 [      4C] RVA [size] of Export Directory

            592C [      F0] RVA [size] of Import Directory

            9000 [    1034] RVA [size] of Resource Directory

            8000 [     1E0] RVA [size] of Exception Directory

               0 [       0] RVA [size] of Certificates Directory

            B000 [      28] RVA [size] of Base Relocation Directory

            53A0 [      54] RVA [size] of Debug Directory

               0 [       0] RVA [size] of Architecture Directory

               0 [       0] RVA [size] of Global Pointer Directory

               0 [       0] RVA [size] of Thread Storage Directory

            5400 [      94] RVA [size] of Load Configuration Directory

               0 [       0] RVA [size] of Bound Import Directory

            4000 [     470] RVA [size] of Import Address Table Directory

               0 [       0] RVA [size] of Delay Import Directory

               0 [       0] RVA [size] of COM Descriptor Directory

               0 [       0] RVA [size] of Reserved Directory

 

 

 

 

SECTION HEADER #1

   .text name

    2A68 virtual size

    1000 virtual address (0000000140001000 to 0000000140003A67)

    2C00 size of raw data

     400 file pointer to raw data (00000400 to 00002FFF)

       0 file pointer to relocation table

       0 file pointer to line numbers

       0 number of relocations

       0 number of line numbers

60000020 flags

         Code

         Execute Read

 

 

SECTION HEADER #2

  .rdata name

    2976 virtual size

    4000 virtual address (0000000140004000 to 0000000140006975)

    2A00 size of raw data

    3000 file pointer to raw data (00003000 to 000059FF)

       0 file pointer to relocation table

       0 file pointer to line numbers

       0 number of relocations

       0 number of line numbers

40000040 flags

         Initialized Data

         Read Only

 

 

  Debug Directories

 

 

        Time Type       Size      RVA  Pointer

    -------- ------ -------- -------- --------

    561A2F0A cv           49 00005494     4494    Format: RSDS, {71EB6E18-61F7-45A9-9AC2-01D9BE320001}, 2, C:\VC14\Win64\httpd-2.4.17\x64\Release\httpd.pdb

    561A2F0A (   C)       14 000054E0     44E0

    561A2F0A (   D)      27C 000054F4     44F4

 

 

SECTION HEADER #3

   .data name

     6F8 virtual size

    7000 virtual address (0000000140007000 to 00000001400076F7)

     200 size of raw data

    5A00 file pointer to raw data (00005A00 to 00005BFF)

       0 file pointer to relocation table

       0 file pointer to line numbers

       0 number of relocations

       0 number of line numbers

C0000040 flags

         Initialized Data

         Read Write

 

 

SECTION HEADER #4

  .pdata name

     1E0 virtual size

    8000 virtual address (0000000140008000 to 00000001400081DF)

     200 size of raw data

    5C00 file pointer to raw data (00005C00 to 00005DFF)

       0 file pointer to relocation table

       0 file pointer to line numbers

       0 number of relocations

       0 number of line numbers

40000040 flags

         Initialized Data

         Read Only

 

 

SECTION HEADER #5

   .rsrc name

    1034 virtual size

    9000 virtual address (0000000140009000 to 000000014000A033)

    1200 size of raw data

    5E00 file pointer to raw data (00005E00 to 00006FFF)

       0 file pointer to relocation table

       0 file pointer to line numbers

       0 number of relocations

       0 number of line numbers

40000040 flags

         Initialized Data

         Read Only

 

 

SECTION HEADER #6

  .reloc name

      28 virtual size

    B000 virtual address (000000014000B000 to 000000014000B027)

     200 size of raw data

    7000 file pointer to raw data (00007000 to 000071FF)

       0 file pointer to relocation table

       0 file pointer to line numbers

       0 number of relocations

       0 number of line numbers

42000040 flags

         Initialized Data

         Discardable

         Read Only

 

 

  Summary

 

 

        1000 .data

        1000 .pdata

        3000 .rdata

        1000 .reloc

        2000 .rsrc

        3000 .text

 

The HEX 40000 is 262144 (256KB).

So, what this confirms is that the instruction to set stack size to 512KB is basically doubling up the stack size.

 

Thanks to Ujwol for revealing this.

After finding this information, we ran the same on the ASF Apache 2.2 and the stack size remained the same.

So, the memory requirement for Web Agent module for Apache 2.4 seems to have increased.

 

I did not have a full Studio installed but there was editbin and link package found on internet that worked.

http://people.sju.edu/~ggrevera/cscCV/stack/

 

Outcomes