Diagnosing Memory Heap Corruption in glibc with MALLOC_CHECK_

2023-05-16

原文链接: https://support.microfocus.com/kb/doc.php?id=3113982

Environment

Novell eDirectory 8.7.3 for Linux

Novell eDirectory 8.8 for Linux

Novell Open Enterprise Server (Linux based)

Novell SUSE Linux Enterprise Server 9

Novell SUSE Linux Enterprise Server 10

Novell SUSE Linux Enterprise Server 11

Situation

The GNU C Library (glibc) is the standard C library on Linux Systems. Other C libraries exist and are sometimes used for special purposes (such as very small subsets of the standard C libraries used for embedded systems and bootstrapping), but glibc is the standard C library on all Linux distributions.

The glibc includes three simple memory-checking tools. The two, mcheck() and MALLOC_CHECK_, enforce heap data structure consistency checking, and the third, mtrace(), traces memory allocation and deallocation for later processing. When memory is allocated from the heap, the memory management functions need someplace to store information about the allocations. That place is the heap itself; this means that the heap is composed of alternating areas of memory that are used by the program and by the memory management functions themselves. This means that buffer overflows or underruns can actually damage the data structures that the memory management functions use to keep track of what memory has been allocated.

When this happens, all bets are off, except that is pretty good bet that the memory management functions will eventually cause the program to crash. If we set the MALLOC_CHECK_ environment variable, a different and somewhat slower set of memory management functions is used. These functions are more tolerant of errors and can check for calling free() more than once on the same pointer for single-byte buffer overflows.

Resolution

Setting MALLOC_CHECK_ :

  1. If MALLOC_CHECK_ is set to 0 (zero), the memory management functions are simply most tolerant of errors and do not give warnings.

    • Maybe be useful if we are prevented from finding one memory bug by another that is not convenient to fix at the moment; it might allow us to use other tools to chase down the other memory bug.

    • It may also be useful if you are running code that works on another system but not on Linux. It can provide a quick workaround that may allow the code to temporarily function, before you have the chance to resolve the error.

  2. If MALLOC_CHECK_ is set to 1 (one), the memory management functions print out warning messages on standard error when problems are noticed.

    • It is useful if we are not aware of any problems and just want to be notified if any problem exist.
  3. If MALLOC_CHECK_ is set to 2 (two), the memory management functions call **abort()**when problems are noticed.

    • This is most useful from inside the debugger or a shell starting an application or daemon. It allows a backtrace to be obtained as soon as the memory management functions discover an error, providing information closest to the point at which the error has happened.

    • If a core is caused by a memory corruption, we have more information about memory allocations. This is better for troubleshooting and determining where/which application overwrote a memory address.

  4. Settings 1 and 2 can be combined by setting MALLOC_CHECK_ to 3 (three).
    This will enable the print out of warning messages on standard error (1), and will call abort() when problems are noticed (2).

Additional Information

Setting MALLOC_CHECK_ examples:

For ndsd/eDirectory:

  1. Add the following to the /opt/novell/eDirectory/sbin/pre_ndsd_start file:
    export MALLOC_CHECK_=3
    Note: the pre_ndsd_start script/file is usually empty. If there are other lines in the file, this should go first.

  2. Restart ndsd (/etc/init.d/ndsd restart) to activate.

**NOTES:
**

- SLES 12 and RHEL 7
You must add all the environment variables required for eDirectory service in the env file located in the /etc/opt/novell/eDirectory/conf directory due to systemd requirements.

- This setting should be used for debugging purposes only.

Due to potential performance impact (which could be up to 25% in some cases), it is recommended to comment it out (and restart the process) as soon as the needed core file(s) are obtained.

For namcd:

  1. Add MALLOC_CHECK_=3 to NAMCD script (/etc/init.d/namcd):
    The script will then look similar to:

    # Template configuration variables
    prefix=/usr
    exec_prefix=/usr
    sbindir=/usr/sbin
    bindir=/usr/bin
    initdir=/etc/init.d
    export MALLOC_CHECK_=3
    userID=`id`

  2. Restart NAMCD (/etc/init.d/namcd restart) to activate

NOTE: This setting should be used for debugging purposes only.

Due to potential performance impact (which could be up to 25% in some cases), it is recommended to comment it out (and restart the process) as soon as the needed core file(s) are obtained.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Diagnosing Memory Heap Corruption in glibc with MALLOC_CHECK_ 的相关文章

  • Ant:将compilerarg传递给javac

    我有可以编译的 ant 脚本
  • 我是否想访问地址零?

    常量 0 在 C 和 C 中用作空指针 但正如问题中 指向特定固定地址的指针 https stackoverflow com questions 2389251 pointer to a specific fixed address分配固定
  • 在 Windows 上使用 PHP 获取总可用系统内存

    使用 PHP 我想获取系统可用的总内存 而不仅仅是空闲或已用内存 在 Linux 上 这非常简单 你可以做 memory fopen proc meminfo 然后解析该文件 有人知道 Windows 的等效方法吗 我愿意接受任何建议 编辑
  • 哪些简单的改变对您的 Delphi 程序产生了最大的改进 [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我有一个 Delphi 2009 程序 需要处理大量数据 并且需要尽可能快且不使用太多内存 What 小简单您是否对 Delphi 代
  • Swift 栈和堆的理解

    我想快速了解堆栈和堆中存储的内容 我有一个粗略的估计 您打印的所有内容和内存地址都不是值 它们存储在堆栈中 而作为值打印出来的内容则在堆上 基本上根据值和引用类型 我完全错了吗 或者 您可以提供堆栈 堆的可视化表示吗 As Juul htt
  • 复制期间的字节交换

    我需要有效地交换数组的字节顺序during复制到另一个数组中 源数组是某种类型 char short 或 int 因此所需的字节交换是明确的 并且将根据该类型进行 我的计划是通过多遍字节复制 short 为 2 int 为 4 来非常简单地
  • Python创建大字典时内存错误

    我正在尝试处理 3GB XML 文件 并且在读取文件并将一些数据存储在字典中的循环中间遇到内存错误 class Node object def init self osmid latitude longitude self osmid in
  • Java:在循环中实例化变量:好还是坏风格?

    我有一个简单的问题 通常我会写这样的代码 String myString hello for int i 0 i lt 10 i myString hello again 因为我认为以下不会是好的样式 因为它会创建太多不必要的对象 for
  • ActiveMQ 内存消耗通过屋顶(页面文件)...该怎么办?

    我们使用的是旧版本的 ActiveMQ 5 3 2 请参阅 ActiveMQ可靠吗 https stackoverflow com questions 4303610 is activemq reliable 我们取消了持久性 因为我们需要
  • Chrome 中的 FileReader 内存泄漏

    我有一个具有文件上传功能的网页 上传以 5MB 块执行 我想在将每个块发送到服务器之前计算其哈希值 块表示为Blob https developer mozilla org en docs Web API Blob对象 为了计算哈希值 我将
  • 数组中超过 640 000 个元素 - 内存问题 [Dijkstra]

    我有一个脚本将 803 803 644809 每个图表内有 1 000 000 个值 使用 500 500 一切正常 但现在它崩溃了 它尝试分配超过 64MB 的内存 我没有 解决办法是什么 以某种方式 分裂 它还是 result mysq
  • C++ 中的向量存储

    我希望存储一个大的 d 维点向量 d 固定且小 如果我定义一个Point as vector
  • C# 位图/图形内存不足

    我正在尝试拍摄整个屏幕的快照以读取像素值 事实上我这样做没有任何问题 但在 214 个快照之后 我出现了内存不足的异常 Bitmap ScreenShot new Bitmap Screen PrimaryScreen Bounds Wid
  • glibc 已弃用的 __malloc_hook 功能的替代方案

    我正在为 C 编写一个内存分析器 并为此拦截对malloc realloc and free通过 malloc hooks 函数 不幸的是 这些已被弃用 因为它们在多线程环境中表现不佳 我找不到描述实现相同目标的替代最佳实践解决方案的文档
  • C#:模拟内存泄漏

    我想用c 编写以下代码 a 模拟内存泄漏的小型控制台应用程序 b 小型控制台应用程序 它将调用上述应用程序并立即释放它 模拟管理内存泄漏问题 换句话说 应用程序 b 将不断调用并释放应用程序 a 以模拟如何遏制 叛逆 内存泄漏应用程序 而不
  • 除了内存管理之外,QObject 的父对象还用于什么?

    我知道 当一个QObject http doc qt io qt 5 qobject html被摧毁了 它也摧毁了它所有的孩子 但是 在我最近的所有 Qt 代码中 我总是声明任何类的成员 例如 QMainWindow https doc q
  • 访问单个结构体成员是否会将整个结构体拉入缓存?

    我一直在读乌尔里希 德雷珀的书 每个程序员都应该了解的内存知识 http lwn net Articles 250967 并在部分3 3 2 缓存效果的测量 http lwn net Articles 252125 页面中间 它给我的印象是
  • C# 中类实例的内存使用情况[重复]

    这个问题在这里已经有答案了 可能的重复 C NET 对象使用多少内存 https stackoverflow com questions 426396 how much memory does a c net object use 就像标题
  • 有关 Linux 内存类型的问题

    关于Linux内存我有以下问题 我知道活动内存是最常访问的内存部分 但是有人可以解释一下 linux 如何考虑将内存位置用于活动内存或非活动内存 主动存储器由哪些部分组成 磁盘 文件缓存是否被视为活动内存的一部分 有什么区别Buffers
  • gcc 不太可能使用宏

    我正在编写一段关键代码 其逻辑大致如下 if expression is true do something with extremely low latency before the nuke blows up This branch i

随机推荐

  • LAMP-手动架构部署

    1 lamp简介 有了前面学习的知识的铺垫 xff0c 今天可以来学习下第一个常用的web架构了 所谓lamp xff0c 其实就是由Linux 43 Apache 43 Mysql MariaDB 43 Php Perl Python的一
  • 华为云欧拉操作系统(OpenEuler)部署K8S集群

    华为云欧拉操作系统 xff08 OpenEuler xff09 部署K8S集群 需要提前准备好OpenEular操作系统虚拟机3台 xff0c 本文使用模板机创建 一 主机硬件要求 1 1 主机操作系统说明 序号操作系统及版本备注1open
  • 虚拟机centos关闭繁忙导致无法操作(已解决)

    虚拟机关闭提示虚拟机繁忙导致关闭失败的问题 最近复制了一台虚拟机 xff0c 但是在关闭的时候总是遇到关不上的问题 xff0c 虚拟机提示繁忙 xff0c 开关机和重启按钮一直是灰色图标 xff0c 不能点击 解决办法倒是找到了 xff0c
  • ubuntu桌面图标全部消失,快捷键也打不开终端解决办法

    前几天远程todesk连接实验室服务器过程中出现了ubuntu桌面图标全部消失的现象 按照C到的很多方法操作过都不行 奇怪的是快捷键终端也打不开 界面是下面这个样子的 xff1a 整个人束手无策 然后 xff01 解决方法就是 重启实验室的
  • Ubuntu系统进去之后黑屏是什么问题,及解决办法【最全】

    出现黑屏可能有多种原因 xff0c 以下是一些常见的解决方法 xff1a 1 检查电源线和视频连接线是否牢固 有时候连接线松动或者断开都可能导致黑屏 2 检查显卡驱动是否正确安装 如果显卡驱动没有正确安装 xff0c 可能会导致黑屏 你可以
  • 【在Ubuntu中安装Pycharm(Ubuntu22.04,Pycharm2022.3.3)】详细如何解压文件

    本文讲述了在Ubuntu中安装pycharm的具体步骤 准备环境 xff1a Ubuntu22 04 xff0c Pycharm2022 3 3 具体步骤 xff1a 1 首先下载pycharm xff1a Pycharm官方下载地址 我在
  • 算法—求x的平方根,只保留整数部分(Java)

    需求 给你一个非负整数 x xff0c 计算并返回 x 的 算术平方根 由于返回类型是整数 xff0c 结果只保留 整数部分 xff0c 小数部分将被 舍去 注意 xff1a 不允许使用任何内置指数函数和算符 xff0c 例如 pow x
  • Finding memory bugs with AddressSanitizer

    AddressSanitizer ASan is an instrumentation tool created by Google security researchers to identify memory access proble
  • Android编译出现Warning: Mapping new ns to old ns的解决方案

    出现场景 更新了Android Studio版本后 xff0c 运行项目就出现以下警告 Warning Mapping new ns http schemas android com repository android common 02
  • Maven详细配置(全)

    目录 前言 maven下载配置 配置文件的修改 前言 maven是一个jar包管理工具 可以管理多个jar包 Maven是一个项目管理工具 它包含了一个项目对象模型 Project Object Model 一组标准集合 一个项目生命周期
  • Tomcat:HTTP状态 404 - 未找到解决方法

    出现如下问题 HTTP状态 404 未找到 类型 状态报告 消息 请求的资源 ajax war exploded 不可用 描述 源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示 Apache Tomcat 8 5 69 H
  • jdk动态代理(AOP)从入门到精通(全)

    目录 前言1 了解代理模式2 静态代理案例3 动态代理3 1 入门案例3 2 原理实现3 3 深层案例3 4 步骤流程 4 模板总结 前言 整篇文章的代码源码如下 代码源码 理解什么是动态代理以及动态代理能干什么 使用jdk的反射机制 xf
  • SpringBoot从入门到精通(全)

    目录 前言1 入门案例1 1 新建项目1 2 代码模板 2 配置详解2 1 核心配置文件properties2 2 核心配置文件yml yaml2 3 多环境核心配置文件properties2 4 多环境核心配置文件yml2 5 自定义配置
  • jdbc之问号占位符的详细分析

    目录 前言实战 前言 先写sql语句框架 一个问号代表一个占位符 xff0c 之后占位符接收一个值占位符不可使用双引号或者单引号获取占位符 xff0c 给占位符传值 xff0c 通过setString等方法 之所以要用问号占位符 xff0c
  • docker出现Error response from daemon: driver failed programming external connectivity on endpoint解决方法

    目录 1 问题所示 2 分析原理 3 问题解决 1 问题所示 出现了如下问题 即简单测试run命令 运行一个简易命令不加端口的tomcat docker run d P name tomcat01 tomcat docker span cl
  • java框架 零基础从入门到精通的学习路线 附开源项目面经等(超全)

    目录 前言1 学习路线2 学习方法 前言 这篇文章主要总结我之前所学过的框架以及学习路线 从实打实的零基础到框架再到项目 之后实习工作 也在这篇博客中记录我的学习笔记 以及在笔记中遇到的配置安装 代码bug等错误 都从零开始摸索并且记录了下
  • Bootstrap从入门到精通(全)

    目录 前言1 下载安装2 布局容器和栅格网格系统2 1 布局容器2 2 栅格网格系统 3 常用样式4 表单4 1 控件4 2 布局 5 插件5 1 导航框5 2 下拉菜单 前言 在了解这篇文章的时候 需要提前知道这些知识点 可看我之前的文章
  • RestTemplate的超全讲解(全)

    目录 前言1 简介2 http状态码3 get请求4 post请求5 Exchange 前言 主要介绍RestTemplate的原理以及使用等 1 简介 常见的http客户端请求工具 xff1a jdk HttpURLConnectionA
  • 出现蓝屏代码为DPC_WATCHDOG_VIOLATION的解决方法

    最近过年 电脑一直时不时出现这个问题 已经严重影响我的工作 你的设备遇到问题 需要重启 我们只收集某些错误信息 然后你可以重新启动 有关此问题的详细信息和可能的解决方法 请访问 https www windows com stopcode
  • Diagnosing Memory Heap Corruption in glibc with MALLOC_CHECK_

    原文链接 https support microfocus com kb doc php id 61 3113982 Environment Novell eDirectory 8 7 3 for Linux Novell eDirecto