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


Groups > comp.lang.c > #26315

Re: Failing Malloc

Message-ID <49u9i9-ehr.ln1@wilbur.25thandClement.com> (permalink)
From William Ahern <william@wilbur.25thandClement.com>
Subject Re: Failing Malloc
Newsgroups comp.lang.c
References (4 earlier) <abcgjrF1taiU4@mid.individual.net> <50511364.5030408@verizon.net> <abcmddF1taiU5@mid.individual.net> <5052155F.5090302@verizon.net> <abeqv3F1taiU7@mid.individual.net>
Date 2012-09-13 14:03 -0700

Show all headers | View raw


Ian Collins <ian-news@hotmail.com> wrote:
> On 09/14/12 05:18 AM, James Kuyper wrote:
> > On 09/12/2012 08:07 PM, Ian Collins wrote:
> > ....
> >> I use the OS provided stack trace functions to build a stack trace to
> >> include in the exception, so there's no need to pick anything use up
> >> along the way.
> >
> > My code is allowed to assume support for any feature mandated by POSIX
> > 1003.2-1992 (except for a long list of prohibited functions - but none
> > of those seem relevant), but is not otherwise allowed to depend upon
> > OS-specific features. Do you know if any such functions were included in
> > that version of POSIX?
> >
> > If not, can you at least identify the OS you're using, and the specific
> > stack trace functions you're talking about for that OS? I'd like to know
> > how they work - off-hand, functionality that would be an adequate
> > substitute for what I'm currently doing seems implausible.

> I think most of this stuff is OS specific and there's a big whole in 
> POSIX where it should be.

> I mainly use Solaris which has a family of stack reading functions:

> http://docs.oracle.com/cd/E23824_01/html/821-1465/walkcontext-3c.html#scrolltoc

> Googling for "solaris walkcontext" will find the Linux near equivalents.

On Linux there are two easy ways to get a stack trace:

1) glibc's backtrace() from <execinfo.h>.
2) GCC's/clang's __builtin_frame_address and __builtin_return_address.

glibc also has backtrace_symbols(), but it uses dladdr. The ELF and DWARF
symbols can get you more accurate information, more reliably. But reading
the ELF and DWARF bits directly is complex, thus libbfd--which like
__builtin_frame_address should actually work everywhere GCC/GDB exists,
including Solaris/SPARC.

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


Thread

Failing Malloc Eric <nospam@nospam.com> - 2012-09-12 20:07 +0000
  Re: Failing Malloc Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2012-09-12 22:12 +0200
    Re: Failing Malloc William Ahern <william@wilbur.25thandClement.com> - 2012-09-12 14:25 -0700
  Re: Failing Malloc Andrew Cooper <andrew@nospam.example.com> - 2012-09-12 21:21 +0100
    Re: Failing Malloc Eric <nospam@nospam.com> - 2012-09-12 20:34 +0000
      Re: Failing Malloc Paul N <gw7rib@aol.com> - 2012-09-12 13:46 -0700
        Re: Failing Malloc Eric <nospam@nospam.com> - 2012-09-13 20:21 +0000
          Re: Failing Malloc Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-13 17:31 -0400
          Re: Failing Malloc James Kuyper <jameskuyper@verizon.net> - 2012-09-13 17:57 -0400
      Re: Failing Malloc John Gordon <gordon@panix.com> - 2012-09-12 20:55 +0000
        Re: Failing Malloc William Ahern <william@wilbur.25thandClement.com> - 2012-09-12 14:33 -0700
        Re: Failing Malloc falk@rahul.net (Edward A. Falk) - 2012-09-13 22:43 +0000
      Re: Failing Malloc James Kuyper <jameskuyper@verizon.net> - 2012-09-12 17:37 -0400
      Re: Failing Malloc Johann Klammer <klammerj@NOSPAM.a1.net> - 2012-09-13 08:57 +0200
  Re: Failing Malloc James Kuyper <jameskuyper@verizon.net> - 2012-09-12 17:20 -0400
    Re: Failing Malloc Ian Collins <ian-news@hotmail.com> - 2012-09-13 09:27 +1200
      Re: Failing Malloc James Kuyper <jameskuyper@verizon.net> - 2012-09-12 17:56 -0400
        Re: Failing Malloc Ian Collins <ian-news@hotmail.com> - 2012-09-13 10:28 +1200
          Re: Failing Malloc James Kuyper <jameskuyper@verizon.net> - 2012-09-12 18:57 -0400
            Re: Failing Malloc William Ahern <william@wilbur.25thandClement.com> - 2012-09-12 16:21 -0700
            Re: Failing Malloc Ian Collins <ian-news@hotmail.com> - 2012-09-13 12:07 +1200
              Re: Failing Malloc James Kuyper <jameskuyper@verizon.net> - 2012-09-13 13:18 -0400
                Re: Failing Malloc Ian Collins <ian-news@hotmail.com> - 2012-09-14 07:37 +1200
                Re: Failing Malloc James Kuyper <jameskuyper@verizon.net> - 2012-09-13 16:05 -0400
                Re: Failing Malloc William Ahern <william@wilbur.25thandClement.com> - 2012-09-13 14:21 -0700
                Re: Failing Malloc James Kuyper <jameskuyper@verizon.net> - 2012-09-13 17:38 -0400
                Re: Failing Malloc William Ahern <william@wilbur.25thandClement.com> - 2012-09-13 14:03 -0700
                Re: Failing Malloc Ian Collins <ian-news@hotmail.com> - 2012-09-15 10:01 +1200
            Re: Failing Malloc Philip Lantz <prl@canterey.us> - 2012-09-14 02:50 -0700
  Re: Failing Malloc Kaz Kylheku <kaz@kylheku.com> - 2012-09-12 21:36 +0000
  Re: Failing Malloc Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-12 17:41 -0400
  Re: Failing Malloc Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-09-12 16:07 -0600
    Re: Failing Malloc "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-09-12 16:03 -0700
  Re: Failing Malloc Kenneth Brody <kenbrody@spamcop.net> - 2012-09-12 19:24 -0400
  Re: Failing Malloc The Great Firewall of China Blue <chine.bleu@yahoo.com> - 2012-09-12 16:34 -0700
  Re: Failing Malloc Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-09-13 00:14 -0700

csiph-web