glibc

Efficiency of repeated memory allocations in glibc

Below is my C wrapper for a Fortran ZHEEVR routine from well-known LAPACK numerical library: void zheevr(char jobz, char range, char uplo, int n, doublecomplex* a, int lda, double vl, double vu, int il, int iu, double abstol, double* w, doublecomplex* z, int ldz, int* info) { int m; int lwork = -1; int liwork = -1; int l...

About thread safety in malloc and free

Possible Duplicate: Malloc thread-safe? I heard that glibc malloc() was not thread safe, since several threads of a process calling malloc() simultaneously will lead to undefined behaviour. And my question is if a thread calls free() will another thread is calling malloc(), will this lead to undefined behaviour as well? ...

__libc_lock_lock is segfaulting

I am working on a piece of code which uses regular expressions in c. All of the regex stuff is using the standard regex c library. On line 246 of regexec.c, the line is __libc_lock_lock(dfa->lock); My program is segfaulting here and I cannot figure out why. I was trying to find where __libc_lock_lock was defined and it turns out ...

Pthread mutex assertion error

I'm encountering the following error at unpredictable times in a linux-based (arm) communications application: pthread_mutex_lock.c:82: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed. Google turns up a lot of references to that error, but little information that seems relevant to my situation. I was wondering if ...

Error converting a pipe (Handler) to fd on vs 2003

Hello! I am trying to use notify a main gtk thread ( from a separate thread) that some even occurred using pipes. I get the following warning when I am trying to setup pipes. What is a good workaround? when I can this g_io_channel_win32_new_fd, I see this warning, and thus pipe isn't created at all :( GLib-WARNING **: giowin32.c:1564:...

Update glibc in Cygwin

Hi I just wanted to make use of the Cygwin x server, but when trying to start a program I am told that glibc is too old. I have version 2.3.2 but would need version 2.3.6. Is there any easy way to update this? Cant find this package in the cygwin setup routine. Thanks ...

Any function to query the size of an allocated block?

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 s...

getpwnam_r memory leak

I use getpwnam_r to handle client connections in my programs. Sadly enough, it seems to allocate a buffer it never frees. The relevant valgrind output: ==15774== 536 (104 direct, 432 indirect) bytes in 2 blocks are definitely lost in loss record 1 of 3 ==15774== at 0x4C24CFE: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memc...

building a .so that is also an executable

So everyone probably knows that glibc's /lib/libc.so.6 can be executed in the shell like a normal executable in which cases it prints its version information and exits. This is done via defining an entry point in the .so. For some cases it could be interesting to use this for other projects too. Unfortunately, the low-level entry point y...

"corrupted double-linked list" on boost::function free()

I am going to try to ask this question without supplying too much source code because all the relevant bits add up to a bunch. The key (I think?) objects involved are using namespace o2scl; typedef MSMTModel<TASensor,PosModel,target2d,ovector,ovector_const_subvector> TA_MSMTModel; typedef MPC_funct_mfptr<MSMT_InitialState,TA_MSMTModel...

Problems on injecting into printf using LD_PRELOAD method

Hi Experts, I was hacking printf() of glibc in one of my project and encountered some problem. Could you please give some clues? And one of my concern is why the same solution for malloc/free works perfect! As attached, “PrintfHank.c” contains my own solution of printf() which will be preloaded before standard library; and “main.c” jus...

Questions about C++ memory allocation and delete

I'm getting a bad error. When I call delete on an object at the top of an object hierarchy (hoping to the cause the deletion of its child objects), my progam quits and I get this: *** glibc detected *** /home/mossen/workspace/abbot/Debug/abbot: double free or corruption (out): 0xb7ec2158 *** followed by what looks like a memory dump of...

Why inet_ntoa is designed to be a non-reentrant function?

Glancing at the source code of GNU C Library,I found the inet_ntoa is implementated with static __thread char buffer[18] My question is, since there is a need to use reeentrant inet_ntoa,why do not the author of GNU C Library use malloc to implementate it? thanks. ...

Issue with C function returning a gchar**

I have a function defined as the following (in C): gchar **Scan_Return_File_Tag_Field_From_Mask_Code (File_Tag *FileTag, gchar code) { switch (code) { case 't': /* Title */ return &FileTag->title; case 'a': /* Artist */ return &FileTag->artist; case 'b': /* Album */ ...

printf slows down my program

I have a small C program to calculate hashes (for hash tables). The code looks quite clean I hope, but there's something unrelated to it that's bugging me. I can easily generate about one million hashes in about 0.2-0.3 seconds (benchmarked with /usr/bin/time). However, when I'm printf()inging them in the for loop, the program slows dow...

GLIBCXX_3.4.9 not found

Hi, I have a problem concerning libstdc++.so. I installed a new version of gcc and tried to compile c++ code. The compiling worked, but when I try to execute the binary (m5.opt is its name) I've got the following error: build/ALPHA_SE/m5.opt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by build/ALPHA_SE/m5.op...

android sdk wants libc 2.4

My OS is debian etch. The tools want glibc 2.4. Etch comes with 2.3. I've downloaded the glibc 2.7 and pointed the adb and the avd at this glibc. The EXE's throw a segmentation fault. I looked at re-building the droid sdk on my box but the pre-requisites, like git 1.5, have un-available dependencies themselves. Any suggestions before I u...

Does anybody know if someone had integrated libsegfault.so and gdbserver in order to get gdb attached on the fly to a crashed program?

It's mentioned in http://sourceware.org/ml/gdb/2007-06/msg00360.html before. But no one seemed to have actually implemented this kind of idea. Is there any obstacles for realizing this? My requirements are the following: Being able to plugin to any elf binary executable (ex. by using LD_PRELOAD) The binary may be a multithreaded ex...

using glibc malloc hooks in a thread safe manner.

I would like to monitor the use of mallocs and frees in an application by using the malloc and free hooks. Here's the documentation http://www.gnu.org/s/libc/manual/html_node/Hooks-for-Malloc.html From the example page you can see that my_malloc_hook transiently switches the malloc hook off (or to the previous hook in the chain) before...

How do I build an app for an old linux distribution, and avoid the FATAL: kernel too old error?

I distribute a statically linked binary version of my application on linux. However, on systems with the 2.4 kernel, I get a segfault on startup, and the message: "FATAL: kernel too old." How can I easily get a version up and running with a 2.4 kernel? Some of the libraries I need aren't even available on old linux distributions circa 2...