Revert "libc: Add logcat error message for memory corruption"
This fixes the build.
This reverts commit 7708a89c60
.
This commit is contained in:
parent
877923d369
commit
368ee1e4d6
3 changed files with 21 additions and 79 deletions
|
@ -2265,53 +2265,13 @@ static void reset_on_error(mstate m);
|
||||||
|
|
||||||
#else /* PROCEED_ON_ERROR */
|
#else /* PROCEED_ON_ERROR */
|
||||||
|
|
||||||
/* The following Android-specific code is used to print an informative
|
#ifndef CORRUPTION_ERROR_ACTION
|
||||||
* fatal error message to the log when we detect that a heap corruption
|
#define CORRUPTION_ERROR_ACTION(m) ABORT
|
||||||
* was detected. We need to be careful about not using a log function
|
#endif /* CORRUPTION_ERROR_ACTION */
|
||||||
* that may require an allocation here!
|
|
||||||
*/
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
|
|
||||||
# include <private/logd.h>
|
|
||||||
|
|
||||||
static void __bionic_heap_error(const char* msg, const char* function)
|
|
||||||
{
|
|
||||||
/* We format the buffer explicitely, i.e. without using snprintf()
|
|
||||||
* which may use malloc() internally. Not something we can trust
|
|
||||||
* if we just detected a corrupted heap.
|
|
||||||
*/
|
|
||||||
char buffer[256];
|
|
||||||
strlcpy(buffer, "@@@ ABORTING: ", sizeof(buffer));
|
|
||||||
strlcat(buffer, msg, sizeof(buffer));
|
|
||||||
if (function != NULL) {
|
|
||||||
strlcat(buffer, " IN ", sizeof(buffer));
|
|
||||||
strlcat(buffer, function, sizeof(buffer));
|
|
||||||
}
|
|
||||||
__libc_android_log_write(ANDROID_LOG_FATAL,"libc","%s", buffer);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifndef CORRUPTION_ERROR_ACTION
|
|
||||||
# define CORRUPTION_ERROR_ACTION(m) \
|
|
||||||
__bionic_heap_error("HEAP MEMORY CORRUPTION", __FUNCTION__)
|
|
||||||
# endif
|
|
||||||
# ifndef USAGE_ERROR_ACTION
|
|
||||||
# define USAGE_ERROR_ACTION(m,p) \
|
|
||||||
__bionic_heap_error("INVALID HEAP ADDRESS", __FUNCTION__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#else /* !__ANDROID__ */
|
|
||||||
|
|
||||||
# ifndef CORRUPTION_ERROR_ACTION
|
|
||||||
# define CORRUPTION_ERROR_ACTION(m) ABORT
|
|
||||||
# endif /* CORRUPTION_ERROR_ACTION */
|
|
||||||
|
|
||||||
# ifndef USAGE_ERROR_ACTION
|
|
||||||
# define USAGE_ERROR_ACTION(m,p) ABORT
|
|
||||||
# endif /* USAGE_ERROR_ACTION */
|
|
||||||
|
|
||||||
#endif /* !__ANDROID__ */
|
|
||||||
|
|
||||||
|
#ifndef USAGE_ERROR_ACTION
|
||||||
|
#define USAGE_ERROR_ACTION(m,p) ABORT
|
||||||
|
#endif /* USAGE_ERROR_ACTION */
|
||||||
|
|
||||||
#endif /* PROCEED_ON_ERROR */
|
#endif /* PROCEED_ON_ERROR */
|
||||||
|
|
||||||
|
|
|
@ -48,16 +48,6 @@
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
/* IMPORTANT IMPORTANT IMPORTANT: TECHNICAL NOTE
|
|
||||||
*
|
|
||||||
* Some of the functions below can be called when our malloc() implementation
|
|
||||||
* has detected that the heap is corrupted, or even from a signal handler.
|
|
||||||
*
|
|
||||||
* These functions should *not* use a function that allocates heap memory
|
|
||||||
* or is not signal-safe. Using direct system calls is acceptable, and we
|
|
||||||
* also assume that pthread_mutex_lock/unlock can be used too.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_BUF_SIZE 1024
|
#define LOG_BUF_SIZE 1024
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -87,7 +77,6 @@ static log_channel_t log_channels[LOG_ID_MAX] = {
|
||||||
{ __write_to_log_init, -1, "/dev/"LOGGER_LOG_RADIO }
|
{ __write_to_log_init, -1, "/dev/"LOGGER_LOG_RADIO }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Important: see technical note at start of source file */
|
|
||||||
static int __write_to_log_null(log_id_t log_id, struct iovec *vec)
|
static int __write_to_log_null(log_id_t log_id, struct iovec *vec)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -108,21 +97,23 @@ static int __write_to_log_null(log_id_t log_id, struct iovec *vec)
|
||||||
* it's supposed, that log_id contains valid id always.
|
* it's supposed, that log_id contains valid id always.
|
||||||
* this check must be performed in higher level functions
|
* this check must be performed in higher level functions
|
||||||
*/
|
*/
|
||||||
/* Important: see technical note at start of source file */
|
|
||||||
static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec)
|
static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec)
|
||||||
{
|
{
|
||||||
return TEMP_FAILURE_RETRY( writev(log_channels[log_id].fd, vec, 3) );
|
ssize_t ret;
|
||||||
|
|
||||||
|
do {
|
||||||
|
ret = writev(log_channels[log_id].fd, vec, 3);
|
||||||
|
} while ((ret < 0) && (errno == EINTR));
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Important: see technical note at start of source file */
|
|
||||||
static int __write_to_log_init(log_id_t log_id, struct iovec *vec)
|
static int __write_to_log_init(log_id_t log_id, struct iovec *vec)
|
||||||
{
|
{
|
||||||
if ((LOG_ID_NONE < log_id) && (log_id < LOG_ID_MAX)) {
|
if ((LOG_ID_NONE < log_id) && (log_id < LOG_ID_MAX)) {
|
||||||
int fd;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&log_init_lock);
|
pthread_mutex_lock(&log_init_lock);
|
||||||
|
|
||||||
fd = TEMP_FAILURE_RETRY(open(log_channels[log_id].path, O_WRONLY));
|
int fd = open(log_channels[log_id].path, O_WRONLY);
|
||||||
|
|
||||||
log_channels[log_id].logger =
|
log_channels[log_id].logger =
|
||||||
(fd < 0) ? __write_to_log_null : __write_to_log_kernel;
|
(fd < 0) ? __write_to_log_null : __write_to_log_kernel;
|
||||||
|
@ -139,9 +130,7 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Important: see technical note at start of source file */
|
static int __android_log_write(int prio, const char *tag, const char *msg)
|
||||||
__LIBC_HIDDEN__
|
|
||||||
int __libc_android_log_write(int prio, const char *tag, const char *msg)
|
|
||||||
{
|
{
|
||||||
struct iovec vec[3];
|
struct iovec vec[3];
|
||||||
log_id_t log_id = LOG_ID_MAIN;
|
log_id_t log_id = LOG_ID_MAIN;
|
||||||
|
@ -162,11 +151,7 @@ int __libc_android_log_write(int prio, const char *tag, const char *msg)
|
||||||
return log_channels[log_id].logger(log_id, vec);
|
return log_channels[log_id].logger(log_id, vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The functions below are not designed to be called from a heap panic
|
|
||||||
* function or from a signal handler. As such, they are free to use complex
|
|
||||||
* C library functions like vsnprintf()
|
|
||||||
*/
|
|
||||||
__LIBC_HIDDEN__
|
|
||||||
int __libc_android_log_vprint(int prio, const char *tag, const char *fmt,
|
int __libc_android_log_vprint(int prio, const char *tag, const char *fmt,
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
|
@ -174,10 +159,9 @@ int __libc_android_log_vprint(int prio, const char *tag, const char *fmt,
|
||||||
|
|
||||||
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
|
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
|
||||||
|
|
||||||
return __libc_android_log_write(prio, tag, buf);
|
return __android_log_write(prio, tag, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
__LIBC_HIDDEN__
|
|
||||||
int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...)
|
int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -187,10 +171,9 @@ int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...)
|
||||||
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
|
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return __libc_android_log_write(prio, tag, buf);
|
return __android_log_write(prio, tag, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
__LIBC_HIDDEN__
|
|
||||||
int __libc_android_log_assert(const char *cond, const char *tag,
|
int __libc_android_log_assert(const char *cond, const char *tag,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -201,7 +184,7 @@ int __libc_android_log_assert(const char *cond, const char *tag,
|
||||||
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
|
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
__libc_android_log_write(ANDROID_LOG_FATAL, tag, buf);
|
__android_log_write(ANDROID_LOG_FATAL, tag, buf);
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ enum {
|
||||||
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
|
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
|
||||||
};
|
};
|
||||||
|
|
||||||
int __libc_android_log_write(int prio, const char* tag, const char* buffer);
|
|
||||||
int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...);
|
int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...);
|
||||||
int __libc_android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap);
|
int __libc_android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue