Program Crashed! 
Author Message
 Program Crashed!

Hi,

I was wondering if anyone knows why a program crashed. I was working
with my program and I tried to run it but it crashed. The compile is
alright and everything but when the program ran, it just simply said
fatal error. Any hints?? BTW, I don't want put my program up here
because it is way too long to have anyone look at it. I just want to
know some reasons what causes my program to crash. thanx.



Wed, 13 Oct 1999 03:00:00 GMT  
 Program Crashed!

There can be many MANY reasons why a c program fails.
The list is far to long to try and put up, my best advice
is for you to logically run the program through.
Making good note of stuff like:
        * pointers
        * are you going outside the bounds of an array
          (remember there is NO bounds checking)

small stuff, but it can stuff it up:

        * can't emphasize this enough..
          make sure your logic is correct

          my program compiled and I was happy, I went to run it and the
          program seemed to fall into an endless loop. I searched ages for
          this incesant bug, expecting some major problem with pointing to
          the wrong thing as so of, it turned out that in a simple while
          loop I didn't increment the counter!

          while (*s != '\0')
            {..blah..};

          it should of been

          while (*s++ != '\0')
            {..blah..};

          code will compile correctly, but the logic is rooted.

        * The ever popular:
          if (foo = '\0') /* blah */ ; // this is an assignment, which
                                       // will result in the if statement
                                       // running correctly
                perhaps it should be

          if (foo == '\0') /* blah */ ; // equality operator

        * watch things like typecasting
          (won't shut your program down [usually] but they
           can adversly affect the output)

best of luck,

        Matt.



Thu, 14 Oct 1999 03:00:00 GMT  
 Program Crashed!

Quote:

> Hi,

> I was wondering if anyone knows why a program crashed. I was working
> with my program and I tried to run it but it crashed. The compile is
> alright and everything but when the program ran, it just simply said
> fatal error. Any hints?? BTW, I don't want put my program up here
> because it is way too long to have anyone look at it. I just want to
> know some reasons what causes my program to crash. thanx.

Without seeing the actual source code, we can't be much help.  There are
innumerable reasons why a program (especially a C program) can crash.

Can you isolate where the crash is occurring?  If you can find the actual
line where it occurs, you may get a good idea of what is happening.

If you don't have a real de{*filter*}, you might want to sprinkle some
printf()'s throughout your code, with messages like "entering routine x",
"leaving routine x", etc.

Things to look for:

   Division by zero
   Writing beyond the end of an array
   Attempting to write to an invalid or NULL pointer
   Passing an argument by value when it should be passed by reference

Those are the Big 4 mistakes I usually make (the division by zero is rare,
but the others happen with annoying regularity -- I'm not stupid, but I
freely admit to being sloppy).

--
John Bode
"Paranoia is just reality on a finer scale" -- Strange Days



Thu, 14 Oct 1999 03:00:00 GMT  
 Program Crashed!



Quote:
> Hi,

> I was wondering if anyone knows why a program crashed. I was working
> with my program and I tried to run it but it crashed. The compile is
> alright and everything but when the program ran, it just simply said
> fatal error. Any hints?? BTW, I don't want put my program up here
> because it is way too long to have anyone look at it. I just want to
> know some reasons what causes my program to crash. thanx.

There could be dozens of reasons.  Just keep in mind that the compiler just
makes sure the language syntax is correct.  Try using the de{*filter*} for your
compiler version and step through.

Remove the  '-'   from orion-data for sending email to me.


Orion Data Systems

Solicitations to me must be pre-approved in writing
by me after soliciitor pays $1,000 US per incident.
Solicitations sent to me are proof you accept this
notice and will send a certified check forthwith.



Fri, 15 Oct 1999 03:00:00 GMT  
 Program Crashed!

Quote:

> Hi,

> I was wondering if anyone knows why a program crashed. I was working
> with my program and I tried to run it but it crashed. The compile is
> alright and everything but when the program ran, it just simply said
> fatal error. Any hints?? BTW, I don't want put my program up here
> because it is way too long to have anyone look at it. I just want to
> know some reasons what causes my program to crash. thanx.

Hi "McGee",

Please realise that you are asking us to do some kind of telekinesis
here. I could start writing you a list of 1000 possible causes for
your error and it might not be among that.

Generally try to reduce the size of you programm, to find out, which
part causes the error. Remove parts of it, just to see, if the error
disappears. Start by doing this with larger chucks and then concentrate
on the chunk which causes the error.

If you have nailed it down to some smaller piece of code, whcih still
reproduces the error, and you can't find it yourself, put that code
(max. ca. 100 lines) here to have others take a look at it.

Stephan
(self appointed member of the campaign against grumpiness in c.l.c)



Fri, 15 Oct 1999 03:00:00 GMT  
 Program Crashed!

Quote:

> Please realise that you are asking us to do some kind of telekinesis
> here. I could start writing you a list of 1000 possible causes for
> your error and it might not be among that.

You mean you don't have your telepathic interface yet? :)

Be carefull to get the polarity correct when you give the
erase instruction! :)

--
Standard disclaimers apply.
I don't buy from people who advertise by e-mail.
I don't buy from their ISPs.
Dan Evens



Fri, 15 Oct 1999 03:00:00 GMT  
 Program Crashed!

ok, I am reposting to see if anyone find the part where my program
crashed. On certain computer, it would not run..just say
"abfile.txt"cannot be opened. This is just an excerpt and my program is
way to long to post here. And then on the other computer, it crashed. I
searched and tried to find the bugs but my program cannot run. It either
stopped running when file not found or after input_ab(&ab); Need help!

#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#define ADDRESS_BOOK_SIZE 30
#define NAME_SIZE 27
#define ADDRESS_SIZE 32
#define TEL_NUM_SIZE 10

struct address_book_element
{
                char name [NAME_SIZE];
                char address1 [ADDRESS_SIZE];
                char address2 [ADDRESS_SIZE];
                char tel_num [TEL_NUM_SIZE];

Quote:
};

typedef struct address_book_element Address_Book_Element;

        /*This structure contains the array book entries and an integer
variable,
          len, that tells how many entries are in the array*/

struct address_book
{
                Address_Book_Element entry[ADDRESS_BOOK_SIZE];
                int len;

Quote:
};

typedef struct address_book Address_Book;

void input_ab (Address_Book *);
char *uppercase (char *str);

main ()
{
        Address_Book ab;
        int answer,m,choice=0;
        clrscr();
        input_ab(&ab);
        printf ("Is this a new address book? (Y-yes or N-no) > ");
        answer = getchar ();

        if (toupper(answer) == 'Y')
         {
                for (m=0; m<=ab.len; m++)
                {
                  uppercase (ab.entry[m].name);
                  uppercase (ab.entry[m].address1);
                  uppercase (ab.entry[m].address2);
                  uppercase (ab.entry[m].tel_num);

                }
         }
        while (choice != 'F')
         {
                printf ("The Menu for the Automated Address Book\n");
                printf ("  a) Look-up Entry by Name\n");
                printf ("  b) Look-up Entry by Telephone Number\n");
                printf ("  c) Insert New/Modified Entry\n");
                printf ("  d) Delete Entry\n");
                printf ("  e) List Names\n");
                printf ("  f) Quit\n");
                printf ("Enter Your Selection (a-f) > ");
                choice=toupper(getchar ());

                while (choice < 'A' || choice > 'F')
                        {
                                printf("Your selection is not valid. Please select again.\n");
                                printf("Enter Your Selection (a-f) > \n");
                                choice=toupper(getchar());
                                fflush (stdin);
                        }
                switch (choice)
                        {
                                case 'A':
                                        entry_name(&ab);
                                        break;
                                case 'B':
                                        entry_number(&ab);
                                        break;
                                case 'C':
                                        insert_entry(&ab);
                                        break;
                                case 'D':
                                        delete_entry(&ab);
                                        break;
                                case 'E':
                                        list_names(&ab);
                                        break;
                                case 'F':
                                        exit_adBook(&ab);
                                        break;
                        }
        }
        return 0;

Quote:
}

/****************************************************************************
 This will read from the file abfile.txt and store into the address
book.
****************************************************************************/

void input_ab (Address_Book *abp)
{
        FILE *afp;
        int m;

        if ((afp=fopen ("abfile.txt", "r+"))==NULL)
          {
                printf ("abfile.txt file cannot be open.\n");
                exit (1);
          }
        m=0;

        while (fgets(abp->entry[m].name, NAME_SIZE,afp)!= NULL)
                {
                        fgets (abp->entry[m].address1, ADDRESS_SIZE,afp);
                        fgets (abp->entry[m].address2, ADDRESS_SIZE,afp);
                        fgets (abp->entry[m].tel_num, TEL_NUM_SIZE,afp);
                        m++;
                }
        abp->len = m;
fclose (afp);

Quote:
}

/****************************************************************************
 This will capitalize the information that is being entered from the
 address book or whenever a user input information.
****************************************************************************/

char *uppercase (char *str)
{
        char *start;
        start=str;
        while (*str)
        {
                if (islower (*str))
                        {
                                *str=toupper (*str);
                                str++;
                        }
        }
        return (start);

Quote:
}



Fri, 15 Oct 1999 03:00:00 GMT  
 Program Crashed!

Don't you have a de{*filter*}?  Your and our lives would be much simpler
with a quick traceback...  Or at least tell us what you were trying to
do (what option was chosen, etc).

Roberto

--



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



Sat, 16 Oct 1999 03:00:00 GMT  
 Program Crashed!

Quote:

>ok, I am reposting to see if anyone find the part where my program
>crashed. On certain computer, it would not run..just say
>"abfile.txt"cannot be opened. This is just an excerpt and my program is
>way to long to post here. And then on the other computer, it crashed. I
>searched and tried to find the bugs but my program cannot run. It either
>stopped running when file not found or after input_ab(&ab); Need help!
>#include <stdio.h>
>#include <conio.h>

 ^^^^^^^^^^^^^^^^^^

  3rd party extension to ISO C, may not be portable.

[Snip definitions which appear OK]

Quote:
>main ()

int main() is *safer*.

Quote:
>{
>       Address_Book ab;
>       int answer,m,choice=0;
>       clrscr();

3rd party extension, may not be portable.

Quote:
>       input_ab(&ab);
>       printf ("Is this a new address book? (Y-yes or N-no) > ");
>       answer = getchar ();
>       if (toupper(answer) == 'Y')
>        {
>               for (m=0; m<=ab.len; m++)

Maybe I snipped it, but make sure ab's members have been initilized
to a value.

Quote:
>               while (choice < 'A' || choice > 'F')

     Bad design. use 'case else' with switch, as this stands,
     you have assumed an ASCII character encoding which might not
     be correct, and thus other characters may be acceptable input.
     for the while loop to execute.

Quote:
>       return 0;
>}
>       if ((afp=fopen ("abfile.txt", "r+"))==NULL)

You have neglected to add support for the underlying OS. Your code
assumes abfile.txt is in the current default path, this may not be
true.


Sun, 17 Oct 1999 03:00:00 GMT  
 Program Crashed!

Groovy hepcat McGee was jivin' on Sat, 26 Apr 1997 22:46:18 -0500 in
comp.lang.c.
Program Crashed!'s a cool scene! Dig it!

Quote:
>I was wondering if anyone knows why a program crashed. I was working
>with my program and I tried to run it but it crashed. The compile is
>alright and everything but when the program ran, it just simply said
>fatal error. Any hints?? BTW, I don't want put my program up here
>because it is way too long to have anyone look at it. I just want to
>know some reasons what causes my program to crash. thanx.

  The cause of your worries could be just about *anithing*. How the
hell should we know why this is occurring? Do you expect us to read
your mind? If we don't know what the program is, what it does, what
it's supposed to do, etc., then how can we help you?
  All I can suggest is that you

a) put some printf() statements into the program at key locations (eg.
on function entry/exit, etc.) to see how far it gets when you run it
and the values of key variables; and
b) run it through a de{*filter*} to find out where the problem lies.

----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------
    http://www.*-*-*.com/ ~phaywood/
============= Ain't I'm a dawg!! ==============



Sun, 24 Oct 1999 03:00:00 GMT  
 Program Crashed!

Hi, I am just learning the C language.. and i was wondering if there are
any sites out there that can assist me in learning the language of C..
if anyone knows of a web site that can help me in the language of C

this is very appreciated...

        -^x^-
      /~     ~\                    |\/\/\/\|
     |         |                   |       |
     |         |                   | _   _ |
     |     __ _,                   |(. ). )|
    /\/\  (. ).)-=-=-=-=-=-=-=-=-oOO-=(_)=-OOo-=-=-=-=-=-=-=-=-=-=-=-

     |   /~~~  \  HomePage:http://www.mathlab.sunysb.edu/~hsanghvi  |
    /   \ ~===='-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  _/`-_   `---'
_/     \--_/_



Fri, 29 Oct 1999 03:00:00 GMT  
 Program Crashed!

Quote:

> Groovy hepcat McGee was jivin' on Sat, 26 Apr 1997 22:46:18 -0500 in
> comp.lang.c.
> Program Crashed!'s a cool scene! Dig it!

> >I was wondering if anyone knows why a program crashed. I was working
> >with my program and I tried to run it but it crashed. The compile is
> >alright and everything but when the program ran, it just simply said
> >fatal error. Any hints?? BTW, I don't want put my program up here
> >because it is way too long to have anyone look at it. I just want to
> >know some reasons what causes my program to crash. thanx.

>   The cause of your worries could be just about *anithing*. How the
> hell should we know why this is occurring? Do you expect us to read
> your mind? If we don't know what the program is, what it does, what
> it's supposed to do, etc., then how can we help you?

Man, that's what I call a grumpy attitude. Havn't had our coffee yet
have we ?

Stephan
(self appointed member of the campaign against grumpiness in c.l.c)



Fri, 29 Oct 1999 03:00:00 GMT  
 
 [ 20 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Program crashes(Help)

2. Program Crashing

3. why does this little program crash ?

4. Program crashing?

5. program crash

6. Program crash

7. Program crashes with fscanf and string input

8. help, simple program crashes...

9. Help, program crashes

10. Program crash

11. program crashes before executing first line!

12. Example program crashing

 

 
Powered by phpBB® Forum Software