glibc

How to use getaddrinfo_a to do async resolve with glibc

An often overlooked function that requires no external library, but basically has no documentation whatsoever. ...

Using glibc, why does my gethostbyname fail after I/DHCP has changed the DNS server?

If our server (running on a device) starts before a DHCP lease had been acquired then it can never connect using a hostname. If that happens it can find hosts by IP address but not by DNS. I initially thought that the Curl DNS cache was at fault as the curl connections failed. But I used CURLOPT_DNS_CACHE_TIMEOUT to prevent curl from c...

GLIBC: debugging memory leaks: how to interpret output of mtrace()

I’m trying to debug a memory leak problem. I’m using mtrace() to get a malloc/free/realloc trace. I’ve ran my prog and have now a huge log file. So far so good. But I have problems interpreting the file. Look at these lines: @ /usr/java/ibm-java2-x86_64-50/jre/bin/libj9prt23.so:[0x2b270a384a34] + 0x1502570 0x68 @ /usr/java/ibm-java2-x86...

Using C++ library in C code

I have a C++ library that provides various classes for managing data. I have the source code for the library. I want to extend the C++ API to support C function calls so that the library can be used with C code and C++ code at the same time. I'm using GNU tool chain (gcc, glibc, etc), so language and architecture support are not an is...

Fastest way to do a case-insensitive substring search in C/C++?

I need to do a fast case-insensitive substring search in C/C++. My requirements are as follows: Should behave like strstr() (i.e. return a pointer to the match point). Must be case-insensitive (doh). Must support the current locale. Must be available on Windows (MSVC++ 8.0) or easily portable to Windows (i.e. from an open source librar...

glibc's '-lmcheck' option and multithreading.

We've been trying to hunt down some heap corruption issues in our multi-threaded C++ apps. As one technique, we tried add -lmcheck to the libraries line of the application. This is causing the app to crash out with apparent heap corruption in relatively short order. Our app does use both malloc/free and new/delete (as appropriate). On...

What size should I allow for strerror_r?

The OpenGroup POSIX.1-2001 defines strerror_r, as does The Linux Standard Base Core Specification 3.1. But I can find no reference to the maximum size that could be reasonably expected for an error message. I expected some define somewhere that I could put in my code but there is none that I can find. The code must be thread safe. Whic...

Statically linking to a dynamic library. glibc

So. I have a problem where I have two versions of GCC on a machine. 3.4.6 and 4.1 This is due to some dependency issues with a new piece of software. (requires glibc 4.1) When I go to link this new software with the 4.1 libraries it links fine. However, when it comes to executing the software it can't find the library, because it is...

Is there an auto-resizing array/dynamic array implementation for C that comes with glibc?

Is there a dynamic array implementation in glibc or any of the standard Linux libraries for C? I want to be able to add to a list without worrying about its size. I know std::vector exists for C++, but I need the C equivalent. ...

Building crti.o for i386

I am trying to build a cross-compiler with x86_64 being the host and i386 being the target. I'm getting the (all to common) crti.o: No such file error. Instead of grabbing an already built crti.o and crtn.o from a distro... how might I go about building these files explicitly from glibc (or possibly gcc) sources? FYI, I am well aware of...

Use GNU libc regexec() to count substring

Is it possible to count how many times a substring appears in a string using regex matching with GNU libc regexec()? ...

Why does glibc "timezone" global not agree with system time on DST?

I'm experiencing a bizarre issue where my system clock knows that it's daylight savings time, but glibc seems not to. This is an up-to-date Ubuntu installation, and I have checked /etc/localtime and it has the correct changeover time for last week's switch to DST. The current correct timezone for me is Pacific Daylight Time (UTC-7). Whe...

How can I disable "demand paging" for one of my userspace programs ?

For an dedicated test I have to disable "demand paging" for exactly one of my userspace programs http://en.wikipedia.org/wiki/Demand_paging Any idea how I could do this ? (embedded linux appliance; 2.6 kernel) ...

problem with containers: *** glibc detected *** free(): invalid pointer: 0x41e0ce94 ***

I have a C++ program on Linux that crashes after some time with the message: *** glibc detected *** free(): invalid pointer: 0x41e0ce94 *** Inside the program I make extensive use of containers. They have to store objects of a simple class. EDIT 2009-4-17: In the meantime it seems clear that the error has nothing to do with the simp...

legacy linker (uses libc5) fails on linux kernel 2.6.25

We have a legacy linker that uses libc5, and due to several factors we only have the binary and not the source. Yes, version control would have saved us from our current problem... that is now in use for our full tool chain and product line, but this particular horse is long gone. This linker works on linux kernel 2.6.24, but on 2.6.25 ...

Where does glibc get its database of unicode attributes?

Where does glibc get its database of unicode attributes, for such functions as eg, wcwidth()? I'm interested in correcting a few errant entries, but I can't seem to find where this information is in its source distribution. If it matters, I'm primarily interested in this under debian or ubuntu linux. ...

Multiple glibc libraries on a single host

Multiple glibc libraries on a single host My linux (SLES-8) server currently has glibc-2.2.5-235, but I have a program which won't work on this version and requires glibc-2.3.3. Is it possible to have multiple glibcs installed on the same host? This is the error I get when I run my program on the old glibc: ./myapp: /lib/i686/libc.so...

Linux iNotify one shot and event mask problem

I'm trying to use iNotify in linux rhel5, kernel 2.6.18, glibc 2.5-18. I did not define the event as one shot but for some some reason it behaves as if I did. The impact is that I have to re-add a watch after each event. Any one ever used iNotify? Another problem is that the mask returned in the event object contains only one flag: IN_ON...

*** glibc detected *** perl: double free or corruption (!prev): 0x0c2b7138 ***

While running a perl program I encountered the following error *** glibc detected *** perl: double free or corruption (!prev): 0x0c2b7138 *** /lib/tls/i686/cmov/libc.so.6[0xb7daea85] /lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7db24f0] perl(Perl_pregfree+0x3e)[0x80a004e] perl(perl_destruct+0xcf1)[0x806b711] /usr/local/lib/perl/5.8.8/au...

glibc regexp performance

Anyone has experience measuring glibc regexp functions? Are there any generic tests I need to run to make such a measurements (in addition to testing the exact patterns I intend to search)? Thanks. ...