Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #89748

Re: Long Question: What might cause the seg fault?

From John Gordon <gordon@panix.com>
Newsgroups comp.lang.c
Subject Re: Long Question: What might cause the seg fault?
Date 2016-06-22 00:29 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <nkcm62$aod$2@reader1.panix.com> (permalink)
References <nkcdmc$usf$1@dont-email.me>

Show all headers | View raw


In <nkcdmc$usf$1@dont-email.me> bilsch <king621@comcast.net> writes:

> QUESTION: I don't think code sample #2 contains the underlying cause of 
> the seg. fault.  There is something wrong in the larger program of which 
> sample #2 is a small part.  What might this be?

These kinds of errors are caused by writing beyond the end of a buffer,
calling free() on a value that was not returned from malloc, or calling
free() twice on the same value.

It's as simple, and as complicated, as that.  Your code is doing this
somewhere.  The trick is finding where.

> Note: there is no other dynamic memory allocation than that shown.

This is no guarantee that the error is somewhere in the code you've
shown us; writing past the end of a non-dynamic buffer can cause the
problem as well.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Long Question: What might cause the seg fault? bilsch <king621@comcast.net> - 2016-06-21 15:04 -0700
  Re: Long Question: What might cause the seg fault? BartC <bc@freeuk.com> - 2016-06-21 23:51 +0100
    Re: Long Question: What might cause the seg fault? BartC <bc@freeuk.com> - 2016-06-21 23:53 +0100
      Re: Long Question: What might cause the seg fault? bilsch <king621@comcast.net> - 2016-06-22 01:55 -0700
    Re: Long Question: What might cause the seg fault? John Gordon <gordon@panix.com> - 2016-06-22 00:25 +0000
  Re: Long Question: What might cause the seg fault? Jerry Stuckle <jstucklex@attglobal.net> - 2016-06-21 19:22 -0400
    Re: Long Question: What might cause the seg fault? John Gordon <gordon@panix.com> - 2016-06-22 00:17 +0000
  Re: Long Question: What might cause the seg fault? "James R. Kuyper" <jameskuyper@verizon.net> - 2016-06-21 19:35 -0400
    Re: Long Question: What might cause the seg fault? bilsch <king621@comcast.net> - 2016-06-22 03:36 -0700
  Re: Long Question: What might cause the seg fault? John Gordon <gordon@panix.com> - 2016-06-22 00:29 +0000
    Re: Long Question: What might cause the seg fault? bilsch <king621@comcast.net> - 2016-06-22 03:38 -0700
  Re: Long Question: What might cause the seg fault? Barry Schwarz <schwarzb@dqel.com> - 2016-06-21 21:20 -0700

csiph-web