blob: 6bf7415d7c9c0b86ade4e088dbd815510d236810 [file] [log] [blame]
David 'Digit' Turner5c734642010-01-20 12:36:51 -08001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
Elliott Hughes8f2a5a02013-03-15 15:30:25 -070029#include <../private/libc_logging.h> // Relative path so we can #include this .cpp file for testing.
30#include <../private/ScopedPthreadMutexLocker.h>
Elliott Hugheseababde2012-12-20 18:59:05 -080031
32#include <assert.h>
33#include <errno.h>
Elliott Hughes0d787c12013-04-04 13:46:46 -070034#include <fcntl.h>
Elliott Hughes8f2a5a02013-03-15 15:30:25 -070035#include <pthread.h>
Elliott Hugheseababde2012-12-20 18:59:05 -080036#include <stdarg.h>
37#include <stddef.h>
Elliott Hughes8f2a5a02013-03-15 15:30:25 -070038#include <stdlib.h>
Elliott Hugheseababde2012-12-20 18:59:05 -080039#include <string.h>
Elliott Hughes0d787c12013-04-04 13:46:46 -070040#include <sys/mman.h>
David 'Digit' Turner5c734642010-01-20 12:36:51 -080041#include <sys/uio.h>
Elliott Hughes0d787c12013-04-04 13:46:46 -070042#include <unistd.h>
David 'Digit' Turner5c734642010-01-20 12:36:51 -080043
Elliott Hughes0d787c12013-04-04 13:46:46 -070044static pthread_mutex_t gAbortMsgLock = PTHREAD_MUTEX_INITIALIZER;
Elliott Hughes8f2a5a02013-03-15 15:30:25 -070045
Elliott Hughes0d787c12013-04-04 13:46:46 -070046__LIBC_HIDDEN__ abort_msg_t** __abort_message_ptr; // Accessible to __libc_init_common.
David 'Digit' Turner5c734642010-01-20 12:36:51 -080047
Elliott Hughes0d787c12013-04-04 13:46:46 -070048// Must be kept in sync with frameworks/base/core/java/android/util/EventLog.java.
49enum AndroidEventLogType {
50 EVENT_TYPE_INT = 0,
51 EVENT_TYPE_LONG = 1,
52 EVENT_TYPE_STRING = 2,
53 EVENT_TYPE_LIST = 3,
54};
55
56struct BufferOutputStream {
57 public:
58 BufferOutputStream(char* buffer, size_t size) : total(0) {
59 buffer_ = buffer;
60 end_ = buffer + size - 1;
61 pos_ = buffer_;
62 pos_[0] = '\0';
63 }
64
65 ~BufferOutputStream() {
66 }
67
68 void Send(const char* data, int len) {
69 if (len < 0) {
70 len = strlen(data);
71 }
72
73 while (len > 0) {
74 int avail = end_ - pos_;
75 if (avail == 0) {
76 break;
77 }
78 if (avail > len) {
79 avail = len;
80 }
81 memcpy(pos_, data, avail);
82 pos_ += avail;
83 pos_[0] = '\0';
84 len -= avail;
85 total += avail;
David 'Digit' Turner5c734642010-01-20 12:36:51 -080086 }
Elliott Hughes1e980b62013-01-17 18:36:06 -080087 }
David 'Digit' Turner5c734642010-01-20 12:36:51 -080088
Elliott Hughes0d787c12013-04-04 13:46:46 -070089 int total;
David 'Digit' Turner5c734642010-01-20 12:36:51 -080090
Elliott Hughes0d787c12013-04-04 13:46:46 -070091 private:
92 char* buffer_;
93 char* pos_;
94 char* end_;
95};
David 'Digit' Turner5c734642010-01-20 12:36:51 -080096
Elliott Hughes0d787c12013-04-04 13:46:46 -070097struct FdOutputStream {
98 public:
99 FdOutputStream(int fd) : total(0), fd_(fd) {
100 }
101
102 void Send(const char* data, int len) {
103 if (len < 0) {
104 len = strlen(data);
105 }
106
107 while (len > 0) {
108 int rc = TEMP_FAILURE_RETRY(write(fd_, data, len));
109 if (rc == -1) {
110 break;
111 }
112 data += rc;
113 len -= rc;
114 total += rc;
115 }
116 }
117
118 int total;
119
120 private:
121 int fd_;
122};
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800123
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800124/*** formatted output implementation
125 ***/
126
127/* Parse a decimal string from 'format + *ppos',
128 * return the value, and writes the new position past
129 * the decimal string in '*ppos' on exit.
130 *
131 * NOTE: Does *not* handle a sign prefix.
132 */
Elliott Hughes0d787c12013-04-04 13:46:46 -0700133static unsigned parse_decimal(const char *format, int *ppos) {
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800134 const char* p = format + *ppos;
135 unsigned result = 0;
136
137 for (;;) {
138 int ch = *p;
139 unsigned d = (unsigned)(ch - '0');
140
Elliott Hughes0d787c12013-04-04 13:46:46 -0700141 if (d >= 10U) {
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800142 break;
Elliott Hughes0d787c12013-04-04 13:46:46 -0700143 }
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800144
145 result = result*10 + d;
146 p++;
147 }
148 *ppos = p - format;
149 return result;
150}
151
Elliott Hugheseababde2012-12-20 18:59:05 -0800152// Writes number 'value' in base 'base' into buffer 'buf' of size 'buf_size' bytes.
153// Assumes that buf_size > 0.
Elliott Hughes41b31792013-01-28 10:36:31 -0800154static void format_unsigned(char* buf, size_t buf_size, uint64_t value, int base, bool caps) {
Elliott Hugheseababde2012-12-20 18:59:05 -0800155 char* p = buf;
156 char* end = buf + buf_size - 1;
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800157
Elliott Hugheseababde2012-12-20 18:59:05 -0800158 // Generate digit string in reverse order.
159 while (value) {
160 unsigned d = value % base;
161 value /= base;
162 if (p != end) {
163 char ch;
164 if (d < 10) {
165 ch = '0' + d;
166 } else {
167 ch = (caps ? 'A' : 'a') + (d - 10);
168 }
169 *p++ = ch;
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800170 }
Elliott Hugheseababde2012-12-20 18:59:05 -0800171 }
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800172
Elliott Hugheseababde2012-12-20 18:59:05 -0800173 // Special case for 0.
174 if (p == buf) {
175 if (p != end) {
176 *p++ = '0';
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800177 }
Elliott Hugheseababde2012-12-20 18:59:05 -0800178 }
179 *p = '\0';
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800180
Elliott Hugheseababde2012-12-20 18:59:05 -0800181 // Reverse digit string in-place.
182 size_t length = p - buf;
183 for (size_t i = 0, j = length - 1; i < j; ++i, --j) {
184 char ch = buf[i];
185 buf[i] = buf[j];
186 buf[j] = ch;
187 }
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800188}
189
Elliott Hughes41b31792013-01-28 10:36:31 -0800190static void format_integer(char* buf, size_t buf_size, uint64_t value, char conversion) {
191 // Decode the conversion specifier.
192 int is_signed = (conversion == 'd' || conversion == 'i' || conversion == 'o');
193 int base = 10;
194 if (conversion == 'x' || conversion == 'X') {
195 base = 16;
196 } else if (conversion == 'o') {
197 base = 8;
198 }
199 bool caps = (conversion == 'X');
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800200
Elliott Hughes41b31792013-01-28 10:36:31 -0800201 if (is_signed && static_cast<int64_t>(value) < 0) {
202 buf[0] = '-';
203 buf += 1;
204 buf_size -= 1;
205 value = static_cast<uint64_t>(-static_cast<int64_t>(value));
206 }
207 format_unsigned(buf, buf_size, value, base, caps);
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800208}
209
Elliott Hughes0d787c12013-04-04 13:46:46 -0700210template <typename Out>
211static void SendRepeat(Out& o, char ch, int count) {
212 char pad[8];
213 memset(pad, ch, sizeof(pad));
214
215 const int pad_size = static_cast<int>(sizeof(pad));
216 while (count > 0) {
217 int avail = count;
218 if (avail > pad_size) {
219 avail = pad_size;
220 }
221 o.Send(pad, avail);
222 count -= avail;
223 }
224}
225
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800226/* Perform formatted output to an output target 'o' */
Elliott Hughes0d787c12013-04-04 13:46:46 -0700227template <typename Out>
228static void out_vformat(Out& o, const char* format, va_list args) {
Andy McFaddenec92af82011-07-29 12:46:34 -0700229 int nn = 0;
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800230
231 for (;;) {
Andy McFaddenec92af82011-07-29 12:46:34 -0700232 int mm;
233 int padZero = 0;
234 int padLeft = 0;
235 char sign = '\0';
236 int width = -1;
237 int prec = -1;
238 size_t bytelen = sizeof(int);
Andy McFaddenec92af82011-07-29 12:46:34 -0700239 int slen;
240 char buffer[32]; /* temporary buffer used to format numbers */
241
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800242 char c;
243
244 /* first, find all characters that are not 0 or '%' */
245 /* then send them to the output directly */
246 mm = nn;
247 do {
248 c = format[mm];
249 if (c == '\0' || c == '%')
250 break;
251 mm++;
252 } while (1);
253
254 if (mm > nn) {
Elliott Hughes0d787c12013-04-04 13:46:46 -0700255 o.Send(format+nn, mm-nn);
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800256 nn = mm;
257 }
258
259 /* is this it ? then exit */
260 if (c == '\0')
261 break;
262
263 /* nope, we are at a '%' modifier */
264 nn++; // skip it
265
266 /* parse flags */
267 for (;;) {
268 c = format[nn++];
269 if (c == '\0') { /* single trailing '%' ? */
270 c = '%';
Elliott Hughes0d787c12013-04-04 13:46:46 -0700271 o.Send(&c, 1);
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800272 return;
273 }
274 else if (c == '0') {
275 padZero = 1;
276 continue;
277 }
278 else if (c == '-') {
279 padLeft = 1;
280 continue;
281 }
282 else if (c == ' ' || c == '+') {
283 sign = c;
284 continue;
285 }
286 break;
287 }
288
289 /* parse field width */
290 if ((c >= '0' && c <= '9')) {
291 nn --;
292 width = (int)parse_decimal(format, &nn);
293 c = format[nn++];
294 }
295
296 /* parse precision */
297 if (c == '.') {
298 prec = (int)parse_decimal(format, &nn);
299 c = format[nn++];
300 }
301
302 /* length modifier */
303 switch (c) {
304 case 'h':
305 bytelen = sizeof(short);
306 if (format[nn] == 'h') {
307 bytelen = sizeof(char);
308 nn += 1;
309 }
310 c = format[nn++];
311 break;
312 case 'l':
313 bytelen = sizeof(long);
314 if (format[nn] == 'l') {
315 bytelen = sizeof(long long);
316 nn += 1;
317 }
318 c = format[nn++];
319 break;
320 case 'z':
321 bytelen = sizeof(size_t);
322 c = format[nn++];
323 break;
324 case 't':
325 bytelen = sizeof(ptrdiff_t);
326 c = format[nn++];
327 break;
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800328 default:
329 ;
330 }
331
332 /* conversion specifier */
Elliott Hughes41b31792013-01-28 10:36:31 -0800333 const char* str = buffer;
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800334 if (c == 's') {
335 /* string */
336 str = va_arg(args, const char*);
Elliott Hughes239e7a02013-01-25 17:13:45 -0800337 if (str == NULL) {
338 str = "(null)";
339 }
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800340 } else if (c == 'c') {
341 /* character */
342 /* NOTE: char is promoted to int when passed through the stack */
343 buffer[0] = (char) va_arg(args, int);
344 buffer[1] = '\0';
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800345 } else if (c == 'p') {
Andy McFaddenec92af82011-07-29 12:46:34 -0700346 uint64_t value = (uintptr_t) va_arg(args, void*);
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800347 buffer[0] = '0';
348 buffer[1] = 'x';
Elliott Hughes41b31792013-01-28 10:36:31 -0800349 format_integer(buffer + 2, sizeof(buffer) - 2, value, 'x');
Christopher Ferris885f3b92013-05-21 17:48:01 -0700350 } else if (c == 'd' || c == 'i' || c == 'o' || c == 'u' || c == 'x' || c == 'X') {
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800351 /* integers - first read value from stack */
352 uint64_t value;
Elliott Hughes41b31792013-01-28 10:36:31 -0800353 int is_signed = (c == 'd' || c == 'i' || c == 'o');
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800354
355 /* NOTE: int8_t and int16_t are promoted to int when passed
356 * through the stack
357 */
358 switch (bytelen) {
359 case 1: value = (uint8_t) va_arg(args, int); break;
360 case 2: value = (uint16_t) va_arg(args, int); break;
361 case 4: value = va_arg(args, uint32_t); break;
362 case 8: value = va_arg(args, uint64_t); break;
363 default: return; /* should not happen */
364 }
365
366 /* sign extension, if needed */
Elliott Hughes41b31792013-01-28 10:36:31 -0800367 if (is_signed) {
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800368 int shift = 64 - 8*bytelen;
369 value = (uint64_t)(((int64_t)(value << shift)) >> shift);
370 }
371
372 /* format the number properly into our buffer */
Elliott Hughes41b31792013-01-28 10:36:31 -0800373 format_integer(buffer, sizeof(buffer), value, c);
374 } else if (c == '%') {
375 buffer[0] = '%';
376 buffer[1] = '\0';
377 } else {
378 __assert(__FILE__, __LINE__, "conversion specifier unsupported");
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800379 }
380
381 /* if we are here, 'str' points to the content that must be
382 * outputted. handle padding and alignment now */
383
384 slen = strlen(str);
385
Elliott Hughes18a206c2012-10-29 17:37:13 -0700386 if (sign != '\0' || prec != -1) {
387 __assert(__FILE__, __LINE__, "sign/precision unsupported");
388 }
389
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800390 if (slen < width && !padLeft) {
391 char padChar = padZero ? '0' : ' ';
Elliott Hughes0d787c12013-04-04 13:46:46 -0700392 SendRepeat(o, padChar, width - slen);
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800393 }
394
Elliott Hughes0d787c12013-04-04 13:46:46 -0700395 o.Send(str, slen);
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800396
397 if (slen < width && padLeft) {
398 char padChar = padZero ? '0' : ' ';
Elliott Hughes0d787c12013-04-04 13:46:46 -0700399 SendRepeat(o, padChar, width - slen);
David 'Digit' Turner5c734642010-01-20 12:36:51 -0800400 }
401 }
402}
Elliott Hughes8f2a5a02013-03-15 15:30:25 -0700403
Elliott Hughes0d787c12013-04-04 13:46:46 -0700404int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...) {
405 BufferOutputStream os(buffer, buffer_size);
406 va_list args;
407 va_start(args, format);
408 out_vformat(os, format, args);
409 va_end(args);
410 return os.total;
411}
412
413int __libc_format_fd(int fd, const char* format, ...) {
414 FdOutputStream os(fd);
415 va_list args;
416 va_start(args, format);
417 out_vformat(os, format, args);
418 va_end(args);
419 return os.total;
420}
421
422static int __libc_write_log(int priority, const char* tag, const char* msg) {
Nick Kralevich17fc25d2013-06-21 13:28:42 -0700423 int main_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/main", O_CLOEXEC | O_WRONLY));
Elliott Hughes0d787c12013-04-04 13:46:46 -0700424 if (main_log_fd == -1) {
Nick Kralevich17fc25d2013-06-21 13:28:42 -0700425 return -1;
Elliott Hughes0d787c12013-04-04 13:46:46 -0700426 }
427
428 iovec vec[3];
429 vec[0].iov_base = &priority;
430 vec[0].iov_len = 1;
431 vec[1].iov_base = const_cast<char*>(tag);
432 vec[1].iov_len = strlen(tag) + 1;
433 vec[2].iov_base = const_cast<char*>(msg);
434 vec[2].iov_len = strlen(msg) + 1;
435
Nick Kralevich17fc25d2013-06-21 13:28:42 -0700436 int result = TEMP_FAILURE_RETRY(writev(main_log_fd, vec, 3));
437 close(main_log_fd);
438 return result;
Elliott Hughes0d787c12013-04-04 13:46:46 -0700439}
440
441int __libc_format_log_va_list(int priority, const char* tag, const char* format, va_list args) {
442 char buffer[1024];
443 BufferOutputStream os(buffer, sizeof(buffer));
444 out_vformat(os, format, args);
445 return __libc_write_log(priority, tag, buffer);
446}
447
448int __libc_format_log(int priority, const char* tag, const char* format, ...) {
449 va_list args;
450 va_start(args, format);
451 int result = __libc_format_log_va_list(priority, tag, format, args);
452 va_end(args);
453 return result;
454}
Elliott Hughes8f2a5a02013-03-15 15:30:25 -0700455
456static int __libc_android_log_event(int32_t tag, char type, const void* payload, size_t len) {
Elliott Hughes0d787c12013-04-04 13:46:46 -0700457 iovec vec[3];
Elliott Hughes8f2a5a02013-03-15 15:30:25 -0700458 vec[0].iov_base = &tag;
459 vec[0].iov_len = sizeof(tag);
460 vec[1].iov_base = &type;
461 vec[1].iov_len = sizeof(type);
462 vec[2].iov_base = const_cast<void*>(payload);
463 vec[2].iov_len = len;
464
Nick Kralevich17fc25d2013-06-21 13:28:42 -0700465 int event_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/events", O_CLOEXEC | O_WRONLY));
Elliott Hughes8f2a5a02013-03-15 15:30:25 -0700466 if (event_log_fd == -1) {
Nick Kralevich17fc25d2013-06-21 13:28:42 -0700467 return -1;
Elliott Hughes8f2a5a02013-03-15 15:30:25 -0700468 }
Nick Kralevich17fc25d2013-06-21 13:28:42 -0700469 int result = TEMP_FAILURE_RETRY(writev(event_log_fd, vec, 3));
470 close(event_log_fd);
471 return result;
Elliott Hughes8f2a5a02013-03-15 15:30:25 -0700472}
473
474void __libc_android_log_event_int(int32_t tag, int value) {
475 __libc_android_log_event(tag, EVENT_TYPE_INT, &value, sizeof(value));
476}
477
478void __libc_android_log_event_uid(int32_t tag) {
479 __libc_android_log_event_int(tag, getuid());
480}
481
482void __fortify_chk_fail(const char *msg, uint32_t tag) {
Elliott Hughes8f2a5a02013-03-15 15:30:25 -0700483 if (tag != 0) {
484 __libc_android_log_event_uid(tag);
485 }
Elliott Hughes0d787c12013-04-04 13:46:46 -0700486 __libc_fatal("FORTIFY_SOURCE: %s. Calling abort().", msg);
487}
488
Elliott Hughes61e699a2013-06-12 14:05:46 -0700489static void __libc_fatal(const char* format, va_list args) {
Elliott Hughes0d787c12013-04-04 13:46:46 -0700490 char msg[1024];
491 BufferOutputStream os(msg, sizeof(msg));
Elliott Hughes0d787c12013-04-04 13:46:46 -0700492 out_vformat(os, format, args);
Elliott Hughes0d787c12013-04-04 13:46:46 -0700493
494 // TODO: log to stderr for the benefit of "adb shell" users.
495
496 // Log to the log for the benefit of regular app developers (whose stdout and stderr are closed).
497 __libc_write_log(ANDROID_LOG_FATAL, "libc", msg);
498
499 __libc_set_abort_message(msg);
Elliott Hughes61e699a2013-06-12 14:05:46 -0700500}
Elliott Hughes0d787c12013-04-04 13:46:46 -0700501
Elliott Hughes61e699a2013-06-12 14:05:46 -0700502void __libc_fatal_no_abort(const char* format, ...) {
503 va_list args;
504 va_start(args, format);
505 __libc_fatal(format, args);
506 va_end(args);
507}
508
509void __libc_fatal(const char* format, ...) {
510 va_list args;
511 va_start(args, format);
512 __libc_fatal(format, args);
513 va_end(args);
Elliott Hughes8f2a5a02013-03-15 15:30:25 -0700514 abort();
515}
Elliott Hughes0d787c12013-04-04 13:46:46 -0700516
517void __libc_set_abort_message(const char* msg) {
518 size_t size = sizeof(abort_msg_t) + strlen(msg) + 1;
519 void* map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
520 if (map == MAP_FAILED) {
521 return;
522 }
523
524 if (__abort_message_ptr != NULL) {
525 ScopedPthreadMutexLocker locker(&gAbortMsgLock);
526 if (*__abort_message_ptr != NULL) {
527 munmap(*__abort_message_ptr, (*__abort_message_ptr)->size);
528 }
529 abort_msg_t* new_abort_message = reinterpret_cast<abort_msg_t*>(map);
530 new_abort_message->size = size;
531 strcpy(new_abort_message->msg, msg);
532 *__abort_message_ptr = new_abort_message;
533 }
534}