glibc

How do the standard C library and system calls work together?

半城伤御伤魂 提交于 2019-12-07 04:53:02
问题 I recently got interested about inner workings of compilers, standard libraries and kernels. While I was searching for the source code of the standard C library, I came across with Glibc. But what it says in Glibc's official website is: the library which defines the ''system calls'' and other basic facilities such as open, malloc, printf, exit... So I guess that Glibc actually doesn't provide the source code of the standard C library, but instead provides the system calls for those functions,

orcale安装(grid 及变量的编写 )

最后都变了- 提交于 2019-12-07 04:23:11
环境:cenos6.8 软件:11.2.0.1.0 安装前的oracle了解 oracle: 关系型数据库(mysql)主要存放数据和二维表结构 非关系型数据库:树型结构 1.安装前准备: 1.1.OS层面设置: 1.1.1.关闭iptables、selinux(getenforce setenforce)、ntp、ntpdate病设置开机不启动例如:chkconfig xxx off; 1.1.2.设置ip 1.1.3.设置/etc/hosts xxxx.xxxx.xxxx.xxxx name 1.1.4.设置主机名 永久生效:vim /etc/sysconfig/network HOSTNAME=xxxx 在线生效不重启:hostname xxxx 1.2.GI相关设置 1.2.1.创建用户及所属组 [root @localhost ~]# groupadd -g 1000 oinstall [root @localhost ~]# groupadd -g 1001 asmadmin [root @localhost ~]# groupadd -g 1002 asmdba [root @localhost ~]# groupadd -g 1003 asmoper [root @localhost ~]# groupadd -g 1004 dba [root@localhost

Is `asprintf` thread-safe?

情到浓时终转凉″ 提交于 2019-12-07 03:28:46
问题 Is the GNU function asprintf (print to allocated string) thread-safe? (IIC, basically, this boils down to the question whether malloc is thread-safe.) Consider the example code: #define _GNU_SOURCE #include <stdio.h> #include "getValue.h" char * getValue(int key) { char * value; asprintf(&value, "%d", key); // TODO: No error handling! // If memory allocation wasn't possible, or some other error occurs, these functions will // return -1, and the contents of strp is undefined. return value; }

call gettid witin glibc

Deadly 提交于 2019-12-07 02:04:08
问题 I am working in glibc and I need to get the id of the current thread. For this i use syscall(SYS_gettid); Issue is, i am forced to include bits/syscall.h instead of ideal case i.e sys/syscall.h . sys/syscall.h internally calls bits/syscall.h but that is wrapped with #ifndef _LIBC macro. i.e #ifndef _LIBC /* The Linux kernel header file defines macros `__NR_<name>', but some programs expect the traditional form `SYS_<name>'. So in building libc we scan the kernel's list and produce <bits

oracle-rdbms-server-11gR2-preinstall RPM 软件包的功能

為{幸葍}努か 提交于 2019-12-06 23:22:58
oracle-rdbms-server-11gR2-preinstall RPM 软件包的功能 转载 2016年08月20日 20:57:35 基于Linux安装过 Oracle 的童鞋们都应该清楚,安装Oracle的确是一件比较费时费力的差事,因为仅仅是前期的rpm包,内核参数,创建用户等等这些个步骤都让那些新手不免眼花缭乱,一不留神,就导致最终的安装过程中报错而不得不从头来过。现在基于Oracle Linux,Oracle仅仅需要通过安装oracle-rdbms-server-11gR2-preinstall RPM包即可全部搞定其余未安装的RPM包,解决之间的依赖关系,配置内核参数等等。客官,正在基于Oracle Linux 安装Oralce 11g?那就接着往下看。 1、oracle-rdbms-server-11gR2-preinstall RPM 软件包的功能 a、 Automatically downloading and installing any additional software packages and specific package versions needed for installing Oracle Grid Infrastructure and Oracle Database 12 c Release 1 (12.1) or 11g

/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15&apos;

℡╲_俬逩灬. 提交于 2019-12-06 23:18:24
./filezilla: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./filezilla) 如果是64位系统报错信息如下: ./filezilla: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./filezilla) 原因是没有GLIBCXX_3.4.15版本,或是更高的版本。 输入命令查询一下结果: [root @localhost ~]# strings /usr/lib/libstdc++.so.6 | grep GLIBCXX GLIBCXX_3.4 GLIBCXX_3.4.1 GLIBCXX_3.4.2 GLIBCXX_3.4.3 GLIBCXX_3.4.4 GLIBCXX_3.4.5 GLIBCXX_3.4.6 GLIBCXX_3.4.7 GLIBCXX_3.4.8 GLIBCXX_3.4.9 GLIBCXX_3.4.10 GLIBCXX_3.4.11 GLIBCXX_3.4.12 GLIBCXX_3.4.13 GLIBCXX_FORCE_NEW GLIBCXX_DEBUG_MESSAGE_LENGTH 我们看到当前GCC版本中的确没有GLIBCXX_3.4

linux C/C++内存检测

痴心易碎 提交于 2019-12-06 20:11:39
MTRACE glibc提供了一个检查内存泄漏的方法, 前提是你的程序使用glibc的标准函数 分配内存(如malloc, alloc...): 1. 在需要内存泄漏检查的代码的开始调用void mtrace(void) (在mcheck.h中有声明). mtrace为malloc等函数安装hook, 用于记录内存分配信息. 在需要内存泄漏检查的代码的结束调用void muntrace(void). 注意: 一般情况下不要调用muntrace, 而让程序自然结束. 因为可能有些释放内存代码要到muntrace之后才运行. 2. 用debug模式编译被检查代码(-g或-ggdb) 3. 设置环境变量MALLOC_TRACE为一文件名, 这一文件将存有内存分配信息. 4. 运行被检查程序, 直至结束或muntrace被调用. 5. 用mtrace命令解析内存分配Log文件($MALLOC_TRACE) , (mtrace foo $MALLOC_TRACE, where foo is the executible name) ,如果有内存泄漏, mtrace会输出分配泄漏内存的代码位置,以及分配数量. valgrind 下载完成后执行安装 #sh sutogen.sh #./configure #make #make install 执行 valgrind ls -l 来验证是否成功

Spring Boot引起的“堆外内存泄漏”排查及经验总结

大城市里の小女人 提交于 2019-12-06 17:35:44
背景 为了更好地实现对项目的管理,我们将组内一个项目迁移到MDP框架(基于Spring Boot),随后我们就发现系统会频繁报出Swap区域使用量过高的异常。笔者被叫去帮忙查看原因,发现配置了4G堆内内存,但是实际使用的物理内存竟然高达7G,确实不正常。JVM参数配置是“-XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=256M -XX:+AlwaysPreTouch -XX:ReservedCodeCacheSize=128m -XX:InitialCodeCacheSize=128m, -Xss512k -Xmx4g -Xms4g,-XX:+UseG1GC -XX:G1HeapRegionSize=4M”,实际使用的物理内存如下图所示: 排查过程 1. 使用Java层面的工具定位内存区域(堆内内存、Code区域或者使用unsafe.allocateMemory和DirectByteBuffer申请的堆外内存) 笔者在项目中添加 -XX:NativeMemoryTracking=detail JVM参数重启项目,使用命令 jcmd pid VM.native_memory detail 查看到的内存分布如下: 发现命令显示的committed的内存小于物理内存,因为jcmd命令显示的内存包含堆内内存、Code区域、通过unsafe

*** glibc detected *** sendip: free(): invalid next size (normal): 0x09da25e8 *** [duplicate]

你。 提交于 2019-12-06 15:26:55
This question already has answers here : Closed 8 years ago . Possible Duplicate: C++ Error: free(): invalid next size (fast): That's a C++ question (albeit a 'C++ being abused' question). Alternative duplicate: Facing an error: glibc detected free invalid next size (fast) I am using a Linux tool to generate some n/w traffic but getting this error when i try to send data greater than some length while the tool has provision for it. My whole project has stuck in between. As I have not created the tool so not sure where exactly is the error occurring... and this error(even gdb ) is not giving

《Glibc内存管理》笔记DAY5

谁都会走 提交于 2019-12-06 15:07:34
分箱式内存管理 Unsorted bin   Unsorted bin 可以看作是 small bins 和 large bins 的 cache,只有一个 unsorted bin,以双向链表管理空闲 chunk,空闲 chunk 不排序,所有的 chunk 在回收时都要先放到 unsorted bin 中,分配时,如果在 unsorted bin 中没有合适的 chunk,就会把 unsorted bin 中的所有 chunk 分别加入到所属的 bin 中,然后再在 bin 中分配合适的 chunk。Bins 数组中的元素 bin[1]用于存储 unsorted bin 的 chunk 链表头。 /* The otherwise unindexable 1-bin is used to hold unsorted chunks. */ #define unsorted_chunks(M) (bin_at(M, 1)) /* Conveniently, the unsorted bin can be used as dummy top on first call */ #define initial_top(M) (unsorted_chunks(M)) unsorted_chunks(M):把 bin[1]设置为 unsorted bin 的 chunk 链表头。