[OT] gcc seg fault code file

Discussion in 'C Programming' started by Bill Cunningham, May 1, 2014.

  1. When I run a program and get a segmentation fault the compiler says (and
    I use gcc) core file dumped. I understand this file is to be used in the
    debugger. Is there some special switch with gccc that cause a core file to
    be dumped when the compiler conplains "core file dumped"? It's dumping
    nothing file wise. Shouldn't there be a file called core ?
    Bill Cunningham, May 1, 2014
    1. Advertisements

  2. No, the compiler doesn't say "core file dumped"; your program does that,
    or the OS or shell does it on your program's behalf.

    This is not a C question. If "ulimit core unlimited" doesn't answer
    your question, please ask elsewhere.
    Keith Thompson, May 1, 2014
    1. Advertisements

  3. Some shells have the ability to set a maximum core file size,
    as often enough one doesn't want one. When the size is set
    to zero, no file is created. (It would seem that they should
    change the message, but they don't.)

    -- glen
    glen herrmannsfeldt, May 1, 2014
  4. At the time you are executing your program, the compiler has long
    since finished its job. The segmentation fault is a result of the
    hardware/operating system detecting the fact that your program tried
    to do something impossible/illegal. gcc, or any other compiler, has
    no control over what happens at this point.
    On the Unix system I use, there are such files. Whether the same is
    true on the system you are using is something you will have to
    research. You might also need to determine under what condition the
    file would be produced and in which directory such a file would be
    Barry Schwarz, May 2, 2014
  5. Bill Cunningham

    Ike Naar Guest

    Don't they?
    If one runs a program that segfaults on this machine

    $ uname -mrs
    NetBSD 6.1_STABLE amd64

    a core file is written, and a message is printed:

    Segmentation fault (core dumped)

    when there is no restriction on the core file size,
    but no core file is written, and the message

    Segmentation fault

    is printed when the maximum core file is set to zero.
    Ike Naar, May 2, 2014
  6. Well, that is the usual way to write C compilers, but the
    standard doesn't require it. The WATFIV Fortran compiler stays
    in memory. Convenient for running many small programs with
    less wasteful disk I/O. I am not sure about any C compilers
    doing that.

    -- glen
    glen herrmannsfeldt, May 2, 2014
  7. A few days ago, a journalist, posing as someone hard up, was given food
    for him and his family by a food bank without any checks being made that
    he was indeed hard-up. Some people, let's call then "Daily Mail
    readers" were up in arms that someone was helped by a charity simply
    because they asked for help. Others, let's call then "sane people" were
    up in arms that anyone would want to write such a cynical story.

    If Bill is playing some strange long game, then all credit to him. I am
    pleased if he is enjoying himself. No one is forced to reply, so,
    presumably, those who do are happy to do so. What's more, the replies
    may also help others. It win, win, win as far as I can see.

    The only problem is if Bill is genuine, in which case he has my
    sympathy, but the replies do no harm even in this unfortunate case.

    You don't work for the Daily Mail do you?
    Ben Bacarisse, May 2, 2014
  8. Bill Cunningham

    Osmium Guest


    I'll be darned! Until that post I had no idea you were in the UK. You
    could pass for an American - I'm not sure that's a good thing.
    Osmium, May 2, 2014
  9. Don't feed the trolls
    Bill Cunningham, May 2, 2014
  10. I know this is OT. That's why I marked the post OT. It's a compiler
    question I think and I don't know where else to ask. Sorry. I've been having
    time to study C lately. So I am doing so right now.
    Bill Cunningham, May 2, 2014
  11. You could put 75 "OT"s in the Subject: line and Kiki would still feel
    obliged to point out that your post is OT.
    Kenny McCormack, May 2, 2014
  12. It's not a compiler question either.
    Barry Schwarz, May 3, 2014
  13. Bill Cunningham

    Joe Pfeiffer Guest

    It isn't a compiler question, as several people have already pointed out
    to you.
    Joe Pfeiffer, May 3, 2014
  14. YHBT

    "They shall be attended by boys graced with eternal youth, who to the
    beholder?s eyes will seem like sprinkled pearls. When you gaze upon that
    scene, you will behold a kingdom blissful and glorious."

    --- Qur'an 76:19 ---
    Kenny McCormack, May 3, 2014
  15. On one (rather unusual) OS I've used, the equivalent of core files is
    partly controlled by a flag in the executable, which is normally set
    by the linker, which is normally run automatically by the compiler,
    and there are compiler directives (for C a #pragma) to set this flag.
    Although that C compiler was not gcc.
    David Thompson, May 25, 2014
    1. Advertisements

Ask a Question

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