Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 264831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:43:06+00:00 2026-05-11T22:43:06+00:00

We have discovered that one of our auto generated assemblies is throwing a StackOverflowException

  • 0

We have discovered that one of our auto generated assemblies is throwing a StackOverflowException on new(). This class has (bear with me please) 400+ simple properties that are initialised (most by default(string) etc) in a constructor.

We notice that its fine on 64 bits but on 32 bits it goes bang!

We need to test if it’s reasonable for our use case to create a larger default stack to give us breathing room while we reengineer the code generator.

We would esp. interested in solutions that involve app.config if possible. But I’m a realist so anything would be good.

Re reasons for the the stack over flow. We’ve narrowed the error down the constructor in question. My first impressions were also of the type of infinite recursion. However we’ve reproduced the error using a 3 line console app that :

  • creates an empty instance of class.
  • calls a non static method (Clone) on the class who first job is to create and empty instance ready pass the properties into.

It goes bang as it hits the second constructor.

now debugging through with the .net source code we see that the the stack overflow is in the Guid.NewGuid() which is passed as the second parameter to the constructor. The actual line of code is the call to the native CoCreateGuid() call.

So while it could be a bug in CoCreateGuid(), we want to eliminate our code from the problem. My first thought is to increase the size of the stack massively and see if this error reoccurs. Then, since I think we can control all use cases, is replace the constructor with object initialisation – think this can relieve the pressure on the stack.

Nb. We can stop the error from happening by removing just on int property from the class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:43:07+00:00Added an answer on May 11, 2026 at 10:43 pm

    You can use editbin to change the stack size for the executable. You can’t do this in app.config as far as I’m aware.

    Another option (also mentioned on that page) is to create a new thread with the “right” stack size. The page mentions the pros and cons of this approach.

    I’d be surprised if just setting 400 properties in a constructor was the cause of the problem though… that’s going to be one big stack frame – but unless you’ve got several big stack frames on the stack, I would expect it to be okay. The other possibility is that you’ve got endless recursion somewhere 🙂

    EDIT: An alternative suggestion…

    Presumably you have a lot of local variables in this constructor? (Otherwise it shouldn’t take up any more stack than any other call.) Is it possible to split the constructor into multiple methods, setting (say) 20 fields per method? That will be tricky if the fields are read-only, admittedly.

    If you could give us an idea of what the constructor looks like, that would help a lot. You might also want to use ildasm to see what it claims the stack size will be for that constructor.

    Just to check, this is a class rather than a struct, right?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 176k
  • Answers 176k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You will need to rewrite your logic so it is… May 12, 2026 at 3:21 pm
  • Editorial Team
    Editorial Team added an answer Many things such as color and shading gradients are difficult… May 12, 2026 at 3:21 pm
  • Editorial Team
    Editorial Team added an answer Use XQuery: select @xml.query('//Root/Gizmo1') May 12, 2026 at 3:21 pm

Related Questions

I've used source controls for a few years (if you count the Source Safe
I develop a critical application used by a multi-national company. Users in offices all
I have an img tag in my webapp that uses the onload handler to
Background: We have a Webservice that is running under axis2 on a Tomcat. We

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.