[comp.lang.c] (Question) Wired runtime error

Discussion in 'C Programming' started by Sleepy, Feb 5, 2011.

  1. Sleepy

    Sleepy Guest

    Dear Support

    When i run my program, i get the following:

    "Exiting due to signal SIGSEGV
    General Protection Fault at eip=0001cdc0
    eax=00000009 ebx=000ca110 ecx=000ca110 edx=00000000 esi=0000160e
    edi=00000009 ebp=000c99f8 esp=000c99e0 program=C:\TEST.EXE
    cs: sel=01a7 base=029d0000 limit=000dffff
    ds: sel=01af base=029d0000 limit=000dffff
    es: sel=01af base=029d0000 limit=000dffff
    fs: sel=017f base=00006ca0 limit=0000ffff
    gs: sel=01bf base=00000000 limit=0010ffff
    ss: sel=01af base=029d0000 limit=000dffff
    App stack: [000c9aac..00049aac] Excetn stack: [00049a00..00047ac0]

    Call frame traceback EIPs:
    0x0001cdc0
    0x0001c46e
    0x00001757
    0x00005548
    "

    That makes no sense at all to me... Do you know what the error is?

    Thanks.
    Sleepy, Feb 5, 2011
    #1
    1. Advertising

  2. Sleepy <> writes:

    > When i run my program, i get the following:
    >
    > "Exiting due to signal SIGSEGV
    > General Protection Fault at eip=0001cdc0
    > eax=00000009 ebx=000ca110 ecx=000ca110 edx=00000000 esi=0000160e
    > edi=00000009 ebp=000c99f8 esp=000c99e0 program=C:\TEST.EXE
    > cs: sel=01a7 base=029d0000 limit=000dffff
    > ds: sel=01af base=029d0000 limit=000dffff
    > es: sel=01af base=029d0000 limit=000dffff
    > fs: sel=017f base=00006ca0 limit=0000ffff
    > gs: sel=01bf base=00000000 limit=0010ffff
    > ss: sel=01af base=029d0000 limit=000dffff
    > App stack: [000c9aac..00049aac] Excetn stack: [00049a00..00047ac0]
    >
    > Call frame traceback EIPs:
    > 0x0001cdc0
    > 0x0001c46e
    > 0x00001757
    > 0x00005548
    > "
    >
    > That makes no sense at all to me... Do you know what the error is?


    A general protection fault means that your program tried to access an
    invalid address. This can be the result of a huge number of different
    programming errors -- so many that it's probably unwise to suggest any
    particular ones. A debugger will be able to turn those addresses (in
    particular the stacked EIPs) into lines of code so you can see where the
    exception is raised. If you are lucky, this will be near the source of
    the error. If you are unlucky, it will simply where some earlier error
    shows up.

    --
    Ben.
    Ben Bacarisse, Feb 5, 2011
    #2
    1. Advertising

  3. Sleepy wrote:
    > Dear Support


    Who he?

    > When i run my program, i get the following:
    >
    > "Exiting due to signal SIGSEGV
    > General Protection Fault at eip=0001cdc0
    > eax=00000009 ebx=000ca110 ecx=000ca110 edx=00000000 esi=0000160e
    > edi=00000009 ebp=000c99f8 esp=000c99e0 program=C:\TEST.EXE
    > cs: sel=01a7 base=029d0000 limit=000dffff
    > ds: sel=01af base=029d0000 limit=000dffff
    > es: sel=01af base=029d0000 limit=000dffff
    > fs: sel=017f base=00006ca0 limit=0000ffff
    > gs: sel=01bf base=00000000 limit=0010ffff
    > ss: sel=01af base=029d0000 limit=000dffff
    > App stack: [000c9aac..00049aac] Excetn stack: [00049a00..00047ac0]
    >
    > Call frame traceback EIPs:
    > 0x0001cdc0
    > 0x0001c46e
    > 0x00001757
    > 0x00005548
    > "
    >
    > That makes no sense at all to me... Do you know what the error is?
    >
    > Thanks.


    Yes, there's most likely something wrong in your program.
    http://www.catb.org/~esr/faqs/smart-questions.html may help.
    J. J. Farrell, Feb 5, 2011
    #3
  4. Sleepy

    Hans Vlems Guest

    Re: (Question) Wired runtime error

    On 5 feb, 23:09, Sleepy <> wrote:
    > Dear Support
    >
    > When i run my program, i get the following:
    >
    > "Exiting due to signal SIGSEGV
    > General Protection Fault at eip=0001cdc0

    [snip]
    >
    > That makes no sense at all to me... Do you know what the error is?
    >
    > Thanks.


    Without the program source there's no way to tell what went wrong.
    Guessing might help you but, more likely, confuse you even more.
    Hans
    Hans Vlems, Feb 6, 2011
    #4
  5. Re: (Question) Wired runtime error

    In article <>,
    Hans Vlems <> wrote:
    >On 5 feb, 23:09, Sleepy <> wrote:
    >> Dear Support
    >>
    >> When i run my program, i get the following:
    >>
    >> "Exiting due to signal SIGSEGV
    >> General Protection Fault at eip=0001cdc0

    >[snip]
    >>
    >> That makes no sense at all to me... Do you know what the error is?
    >>
    >> Thanks.

    >
    >Without the program source there's no way to tell what went wrong.
    >Guessing might help you but, more likely, confuse you even more.
    >Hans


    That's not true. The way newsgroups run nowadays, posting the source is
    the last thing you want to do.

    --

    Some of the more common characteristics of Asperger syndrome include:

    * Inability to think in abstract ways (eg: puns, jokes, sarcasm, etc)
    * Difficulties in empathising with others
    * Problems with understanding another person's point of view
    * Hampered conversational ability
    * Problems with controlling feelings such as anger, depression
    and anxiety
    * Adherence to routines and schedules, and stress if expected routine
    is disrupted
    * Inability to manage appropriate social conduct
    * Delayed understanding of sexual codes of conduct
    * A narrow field of interests. For example a person with Asperger
    syndrome may focus on learning all there is to know about
    baseball statistics, politics or television shows.
    * Anger and aggression when things do not happen as they want
    * Sensitivity to criticism
    * Eccentricity
    * Behaviour varies from mildly unusual to quite aggressive
    and difficult
    Kenny McCormack, Feb 6, 2011
    #5
  6. Re: (Question) Wired runtime error

    Sleepy <> wrote:
    > Dear Support
    >
    > When i run my program, i get the following:
    >
    > "Exiting due to signal SIGSEGV

    <snip>
    >
    > That makes no sense at all to me... Do you know what the error is?


    I did a calculation that yielded -42 when it was supposed to
    yield a positive number. It makes no sense at all to me...
    Do you know what the error is?

    You're asking us to find Wally/Waldo in a picture that doesn't
    contain Wally/Waldo. Show the minimum compilable source code
    that exhibits the problem.

    --
    Peter
    Peter Nilsson, Feb 7, 2011
    #6
  7. Sleepy

    Sleepy Guest

    [comp.lang.c] (Followup) Re: (Question) Wired runtime error

    Thanks... here is the source-code.

    #include "stdhdrs.h"
    void main()
    {
    char *buf=malloc(SIZE_MAX*sizeof(char));
    printf("Enter your name:");
    scanf("%s",buf);
    printf("Hello %s",buf);
    }


    > Please find a response from our support team below. You may also
    > receive other replies in due course.
    >
    > Sleepy <> wrote:
    >> Dear Support
    >>
    >> When i run my program, i get the following:
    >>
    >> "Exiting due to signal SIGSEGV

    > <snip>
    >>
    >> That makes no sense at all to me... Do you know what the error is?

    >
    > I did a calculation that yielded -42 when it was supposed to yield a
    > positive number. It makes no sense at all to me... Do you know what the
    > error is?
    >
    > You're asking us to find Wally/Waldo in a picture that doesn't contain
    > Wally/Waldo. Show the minimum compilable source code that exhibits the
    > problem.
    Sleepy, Feb 7, 2011
    #7
  8. Re: [comp.lang.c] (Followup) Re: (Question) Wired runtime error

    Sleepy <> writes:
    >> Please find a response from our support team below. You may also
    >> receive other replies in due course.
    >>
    >> Sleepy <> wrote:
    >>> Dear Support
    >>>
    >>> When i run my program, i get the following:
    >>>
    >>> "Exiting due to signal SIGSEGV

    >> <snip>
    >>>
    >>> That makes no sense at all to me... Do you know what the error is?

    >>
    >> I did a calculation that yielded -42 when it was supposed to yield a
    >> positive number. It makes no sense at all to me... Do you know what the
    >> error is?
    >>
    >> You're asking us to find Wally/Waldo in a picture that doesn't contain
    >> Wally/Waldo. Show the minimum compilable source code that exhibits the
    >> problem.

    >
    > Thanks... here is the source-code.
    >
    > #include "stdhdrs.h"
    > void main()
    > {
    > char *buf=malloc(SIZE_MAX*sizeof(char));
    > printf("Enter your name:");
    > scanf("%s",buf);
    > printf("Hello %s",buf);
    > }


    Please don't top-post. See:
    http://www.caliburn.nl/topposting.html
    http://www.cpax.org.uk/prg/writings/topposting.php

    "stdhdrs.h" is not a standard header. If you want your code to be
    portable, you need:
    #include <stdlib.h> /* for malloc */
    #include <stdio.h> /* for printf and scanf */
    #include <limits.h> /* for SIZE_MAX -- but see below */

    "void main()" is wrong. It should be "int main(void)". If your book
    tells you that "void main()" is correct, get a better book.

    SIZE_MAX is the maximum possible value of type size_t. It's guaranteed
    to be at least 65535, but is more likely to be 4294967295 on most
    systems, or even 18446744073709551615 on 64-bit systems.

    You really don't want to try to allocate that much memory.

    sizeof(char) is guaranteed to be exactly 1. If you really wanted to
    try to allocate SIZE_MAX bytes, you could write:

    char *buf = malloc(SIZE_MAX);

    If malloc() fails, it returns a null pointer to indicate that the memory
    was not allocated. You should *always* check for this, and take some
    action (perhaps just quitting the program with an error message) in
    response to a failure. Since you probably just tried to allocate 4
    gigabytes of memory, malloc() almost certainly failed, giving you a null
    pointer that you try to use later. This is the cause of the symptom
    you're seeing.

    Since
    printf("Enter you name:");
    doesn't print a new-line, it doesn't guarantee that the output will
    appear immediately. It probably does on your system, but to be sure
    you can add
    fflush(stdout);
    after the printf.

    Never use a "%s" format with scanf. It doesn't limit the number of
    characters that the user can enter, and will attempt to store *all* of
    them in the buffer. (Is that you used SIZE_MAX for malloc()?) There
    are ways to restrict the size of the input. Also, "%s" reads a
    blank-delimited word; if I enter "Keith Thompson", it will only store
    "Keith" in the buffer. Consider using fgets() (*not* gets()) rather
    than scanf().

    printf("Hello %s",buf);
    doesn't print a new-line. For various reasons, you should use:
    printf("Hello %s\n", buf);

    Finally, since main returns an int, you should add
    return 0;
    before the closing "}". There are circumstances where this isn't
    required, but it's easier to always add it.

    But hey, the lines with the curly braces were just fine!

    You might find the comp.lang.c FAQ, <http://www.c-faq.com/>, a useful
    resource.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Feb 7, 2011
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page