glibc

glibc backtrace - can't redirect output to file

偶尔善良 提交于 2019-12-18 04:42:13
问题 I'm in the process of debugging a C program (that I didn't write). I have all of the internal debugging tools (a whole bunch of printf's) enabled, and I wrote a small PHP script that uses proc_open() and just grabs both stdout and stderr, and time-coordinates them in one file. At the moment, the binary is dieing with a realloc() error that's caught by glibc, and a glibc backtrace is printed, beginning with: *** glibc detected *** /sbin/rsyslogd: realloc(): invalid next size:

How to get POSIX strerror_r instead of GNU version?

左心房为你撑大大i 提交于 2019-12-18 04:07:39
问题 How do I get the POSIX strerror_r instead of GNU version? I'm compiling with g++ on Ubuntu 8.04 with glibc version 2.7 ( based on what's in ). Edit On the above man page it says: Feature Test Macro Requirements for glibc (see feature_test_macros(7)): The XSI-compliant version of strerror_r() is provided if: (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE Otherwise, the GNU-specific version is provided. It then says in feature_test_macros(7): If no feature test macros are

How to compile glibc 32bit on an x86_64 machine

佐手、 提交于 2019-12-18 03:53:51
问题 I'm trying to compile glibc (as a secondary, not a system replacement) 2.6 on an x86_64, and trying to get it to produce 32-bit objects. When I give it a standard configure, it compiles fine, producing the usual 64-bit library objects. Some info: $ uname -a Linux localhost.localdomain 2.6.18-164.11.1.el5 #1 SMP Wed Jan 20 07:32:21 \ EST 2010 x86_64 x86_64 x86_64 GNU/Linux $ cat /etc/redhat-release CentOS release 5.4 (Final) Among other things, I've tried the following: Attempt 1: $ # [in

What makes it possible for glibc malloc to compare pointers from different “objects”?

筅森魡賤 提交于 2019-12-18 03:37:37
问题 Comparing pointers with a relational operator (e.g. < , <= , >= or > ) is only defined by the C standard when the pointers both point to within the same aggregate object (struct, array or union). This in practise means that a comparison in the shape of if (start_object <= my_pointer && my_pointer < end_object+1) { can be turned into if (1) { by an optimising compiler. Despite this, in K&R, section 8.7 "Example—A Storage Allocator", the authors make comparisons similar to the one above. They

libc random number generator flawed?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 03:05:19
问题 Consider an algorithm to test the probability that a certain number is picked from a set of N unique numbers after a specific number of tries (for example, with N=2, what's the probability in Roulette (without 0) that it takes X tries for Black to win?). The correct distribution for this is pow(1-1/N,X-1)*(1/N). However, when I test this using the following code, there is always a deep ditch at X=31, independently from N, and independently from the seed. Is this an intrinsic flaw that cannot

Static linkage with glibc without calling main

对着背影说爱祢 提交于 2019-12-17 20:52:41
问题 I have created a simple hello world using NASM which calls printf and _exit from libc but does not use main . extern printf extern _exit section .data hello: db 'Hello world!',10 section .text global _start _start: xor eax, eax mov edi, hello call printf mov rax, 0 jmp _exit I create the object file like this nasm -felf64 hello.asm Then I can link it using dynamic linkage with glibc like this ld hello.o -dynamic-linker /lib64/ld-linux-x86-64.so.2 -lc -melf_x86_64 This runs correctly with no

Any function to query the size of an allocated block?

廉价感情. 提交于 2019-12-17 20:27:58
问题 I realize that any such function is likely to be non standard, but that's ok for my use case. Basically, I need a method (even if it's only exposed through glibc's syscall() interface) that I can pass a pointer to (a pointer that was returned by a previous call to malloc()) that returns the size of the block the pointer points at. Does such a thing exist? 回答1: So far as I know, there is no such function at least in C90/C99. Some systems, mostly libc, provide functions to get allocated size (e

What does 'corrupted double-linked list' mean

ε祈祈猫儿з 提交于 2019-12-17 18:45:19
问题 I've recently gotten the following error from my PHP: WARNING: [pool www] child 42475 said into stderr: "*** glibc detected *** php-fpm: pool www: corrupted double-linked list: 0x00000000013fe680 ***" I'm not very bothered by this issue, and not very interested in fixing it. But I'm very interested in understanding what this error 'corrupted double-linked list' actually means, because I haven't seen it before. I believe to know what a double-linked list is, but I failed to produce a program

Force free() to return malloc memory back to OS

折月煮酒 提交于 2019-12-17 14:54:16
问题 Seems like even after I free all the memory for a Linux process that was allocated by malloc(), memory is still reserved for the process and not returned to the OS. Running valgrind massif tool by default revelas no leakges. Running valgrind with --pages-as-heap=yes reveals this: ->13.77% (7,655,424B) 0x35FEEEB069: brk (brk.c:31) ->13.77% (7,655,424B) 0x35FEEEB113: sbrk (sbrk.c:53) ->13.77% (7,655,424B) 0x35FEE82717: __default_morecore (morecore.c:48) ->13.77% (7,655,424B) 0x35FEE7DCCB: _int

建立 arm-linux 交叉编译环境

随声附和 提交于 2019-12-17 09:35:14
我们使用以下版本的文件为例子建立 arm-linux 交叉编译环境: 编译环境 redhat 7.2 或 8.0 binutils-2.14.tar.gz ftp://ftp.gnu.org/gnu/binutils/binutils-2.14.tar.gz gcc-core-2.95.3.tar.gz ftp://ftp.gnu.org/gnu/gcc/gcc-2.95....e-2.95.3.tar.gz gcc-g++2.95.3.tar.gz ftp://ftp.gnu.org/gnu/gcc/gcc-2.95....+-2.95.3.tar.gz glibc-2.2.4.tar.gz ftp://ftp.gnu.org/gnu/glibc/glibc-2.2.4.tar.gz glibc-linuxthreads-2.2.4.tar.gz ftp://ftp.gnu.org/gnu/glibc/glibc-l...ds-2.2.4.tar.gz linux-2.4.21.tar.gz ftp://ftp.kernle.org/pub/linux/kern...x-2.4.21.tar.gz patch-2.4.21-rmk1.gz # linux kernel patch for arm ftp://ftp.arm.linux.org.uk/pub/linu...-2.4