www.digitalmars.com         C & C++   DMDScript  

D - Stack overflow

reply "Matthew Wilson" <matthew stlsoft.org> writes:
I'm having all kinds of weird behaviours with stack overflow. They are all
over the shop, so there's no consistent behaviour I can report.

For example, I've had to write a helper function to create some instances of
one type, as follows:

class Entry
{
private:
    static Entry _make_Entry(recls_info_t entry)
    {
        recls_info_t    copy    =   Search_CopyEntry(entry);
        Entry           e       =   null;

        try
        {
            e = new Entry(null);

            e.m_entry = entry;
        }
        catch(Exception x)
        {
            Search_CloseEntry(copy);

            throw x;
        }

        return e;
    }

    this(recls_info_t entry)
    {
        m_entry = entry;
    }


If I pass the "entry" variable to the ctor, I get a stack exhaustion error.

Alas, this is anything but the final workaround. Now I'm getting them inside
functions something like the following:

printf("Calling X()\n");
X();


. . .

void X()
{
  printf("In X\n"); <== This never gets called, as the stack exhaustion
comes in as X() is called


Are there any similar issues known? I can't trim down the code, as I've not
seen this until this point of implementation of the class, and this kind of
thing looks strongly like something that won't come out in a simple example.
Oct 10 2003
parent "Walter" <walter digitalmars.com> writes:
I don't have any indications of problems with stack overflows. Can you make
a small test case?

"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bm7qqh$2ea2$1 digitaldaemon.com...
 I'm having all kinds of weird behaviours with stack overflow. They are all
 over the shop, so there's no consistent behaviour I can report.

 For example, I've had to write a helper function to create some instances
of
 one type, as follows:

 class Entry
 {
 private:
     static Entry _make_Entry(recls_info_t entry)
     {
         recls_info_t    copy    =   Search_CopyEntry(entry);
         Entry           e       =   null;

         try
         {
             e = new Entry(null);

             e.m_entry = entry;
         }
         catch(Exception x)
         {
             Search_CloseEntry(copy);

             throw x;
         }

         return e;
     }

     this(recls_info_t entry)
     {
         m_entry = entry;
     }


 If I pass the "entry" variable to the ctor, I get a stack exhaustion
error.
 Alas, this is anything but the final workaround. Now I'm getting them
inside
 functions something like the following:

 printf("Calling X()\n");
 X();


 . . .

 void X()
 {
   printf("In X\n"); <== This never gets called, as the stack exhaustion
 comes in as X() is called


 Are there any similar issues known? I can't trim down the code, as I've
not
 seen this until this point of implementation of the class, and this kind
of
 thing looks strongly like something that won't come out in a simple
example.

Oct 11 2003