~ubuntu-branches/ubuntu/precise/eglibc/precise

« back to all changes in this revision

Viewing changes to sysdeps/unix/sysv/linux/libc_fatal.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-10-04 17:48:26 UTC
  • mfrom: (216.1.23 oneiric)
  • Revision ID: package-import@ubuntu.com-20111004174826-2cyb9ewn3ucymlsx
Tags: 2.13-20ubuntu5
libc6-dev: Don't break the current {gnat,gcj}-4.4-base versons. LP: #853688.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 1993-1995,1997,2000,2002-2005,2009,2011
 
1
/* Copyright (C) 1993-1995,1997,2000,2002-2005,2009
2
2
   Free Software Foundation, Inc.
3
3
   This file is part of the GNU C Library.
4
4
 
20
20
#include <atomic.h>
21
21
#include <errno.h>
22
22
#include <fcntl.h>
23
 
#include <ldsodefs.h>
24
23
#include <paths.h>
25
24
#include <stdarg.h>
26
25
#include <stdbool.h>
29
28
#include <string.h>
30
29
#include <sysdep.h>
31
30
#include <unistd.h>
32
 
#include <sys/mman.h>
33
31
#include <sys/syslog.h>
34
32
#include <execinfo.h>
35
33
#include <gnu/option-groups.h>
137
135
      if (cnt == total)
138
136
        written = true;
139
137
 
140
 
      if (do_abort)
 
138
      char *buf = do_abort ? malloc (total + 1) : NULL;
 
139
      if (buf != NULL)
141
140
        {
142
 
          total = ((total + 1 + GLRO(dl_pagesize) - 1)
143
 
                   & ~(GLRO(dl_pagesize) - 1));
144
 
          struct abort_msg_s *buf = __mmap (NULL, total,
145
 
                                            PROT_READ | PROT_WRITE,
146
 
                                            MAP_ANON | MAP_PRIVATE, -1, 0);
147
 
          if (__builtin_expect (buf != MAP_FAILED, 1))
148
 
            {
149
 
              buf->size = total;
150
 
              char *wp = buf->msg;
151
 
              for (int cnt = 0; cnt < nlist; ++cnt)
152
 
                wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len);
153
 
              *wp = '\0';
 
141
          char *wp = buf;
 
142
          for (int cnt = 0; cnt < nlist; ++cnt)
 
143
            wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len);
 
144
          *wp = '\0';
154
145
 
155
 
              /* We have to free the old buffer since the application might
156
 
                 catch the SIGABRT signal.  */
157
 
              struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg,
158
 
                                                             buf);
159
 
              if (old != NULL)
160
 
                __munmap (old, old->size);
161
 
            }
 
146
          /* We have to free the old buffer since the application might
 
147
             catch the SIGABRT signal.  */
 
148
          char *old = atomic_exchange_acq (&__abort_msg, buf);
 
149
          free (old);
162
150
        }
163
151
    }
164
152