glibc

Does the implementation of strtoul in glibc conflicts with the C11 standard?

岁酱吖の 提交于 2019-12-11 09:50:50
问题 The follows is the description of function strtoul in stdlib.h implemented by glibc: Function: unsigned long int strtoul (const char *retrict string, char **restrict tailptr, int base) Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | See POSIX Safety Concepts. The strtoul (“string-to-unsigned-long”) function is like strtol except it converts to an unsigned long int value. The syntax is the same as described above for strtol. The value returned on overflow is ULONG_MAX (see Range of Type).

Selectively suppressing glibc link warnings?

℡╲_俬逩灬. 提交于 2019-12-11 07:13:54
问题 glibc uses the following "technique" to generate link warnings... #define link_warning(symbol, msg) \ __make_section_unallocated (".gnu.warning." #symbol) \ static const char __evoke_link_warning_##symbol[] \ __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \ = msg; For a particular link warning generated by this, is there any command-line switch that can be passed to ld or gcc in order to suppress it? (For compile-time warnings you can suppress with `#pragma diagnostic

x86-64 ELF initial stack layout when calling glibc

人走茶凉 提交于 2019-12-11 07:06:29
问题 Basically, I read through parts of http://www.nasm.us/links/unix64abi and at page 29, it shows the initial process stack of a C program. My question is: I'm trying to interface with glibc from x86-64 nasm and based on what the above shows, argc should be at rsp. So the following code should print argc: [SECTION .data] PrintStr: db "You just entered %d arguments.", 10, 0 [SECTION .bss] [SECTION .text] extern printf global main main: mov rax, 0 ; Required for functions taking in variable no. of

Is this a bug in glibc/pthread?

我是研究僧i 提交于 2019-12-11 06:14:04
问题 I am using a robust mutex together with a condition. This works most of the time, but infrequently, I get deadlocks. I could not reduce this to a small, reproducible example, and I consider it very likely that it is a problem in my code, however, I noticed something that looks suspicious: When the code deadlocks, one thread is in pthread_cond_broadcast: #0 __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135 #1 0x00007f4ab2892970 in pthread_cond_broadcast@@GLIBC_2.3.2 ()

Install glibc2.16 in Ubuntu 12.04

走远了吗. 提交于 2019-12-11 05:28:28
问题 I'm using Ubuntu 12.04 and the binary I'm trying to run needs glibc2.16, I tried updating glibc by using apt-get install libc6 but only glibc2.15 got installed , can someone suggest me how to get glibc 2.16 in my machine. Sorry if this question doesn't belong here, but I couldn't find any resource. 回答1: You need to upgrade to a newer Ubuntu version, or recompile the software which currently needs glibc 2.16 specifically for Ubuntu 12.04, so that it will work with that older glibc version.

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

僤鯓⒐⒋嵵緔 提交于 2019-12-11 04:54:48
问题 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 simple class. The error still occurs if I change the containers to hold other datatypes. The problem must be somewhere else in my code, I'm trying to figure it out at

Difference between result of ftell(FILE* fd) and lseek(int fd, off_t offset, int whence)

余生颓废 提交于 2019-12-11 04:00:46
问题 Consider this sample of code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { //this file exists and contains data: "ABCDEFGHIJKLM" FILE* file = fopen("file.txt", "r"); char data[4]; long int pos = ftell(file); fseek(file, 0, SEEK_SET); fread(data, 4, 1, file); fseek(file, pos, SEEK_SET); printf("ftell: %d\n", ftell(file)); printf("lseek: %d\n", lseek(fileno(file), 0, SEEK_CUR)); fread(data, 1, 4, file); //this correctly prints A //but external function needs fileno

global variable for getenv()?

十年热恋 提交于 2019-12-11 03:59:32
问题 Which is the global variable which holds all the environmental variables for getenv() ? In what glibc file is this var filled with env vars ? I believe it to be **environ but when I set an env var in bash it only ouputs the SSH_AGENT_PID env var. Why is SSH_AGENT_PID set and why is it the only one that is set ? DOCUMENT_ROOT='/foopath/'; export DOCUMENT_ROOT int main(void) { extern char **environ; printf("%s\n", *environ); // outputs: SSH_AGENT_PID=2822 } 回答1: char **environ is NULL

Standard way to call `ffsl` in C++?

爷,独闯天下 提交于 2019-12-11 03:34:14
问题 The ffsl function is part of glibc. In GCC it is also available via __builtin_ffsl. It returns the index of the least significant bit in a long. Is there a way to access this functionality in standards-conforming C++ code? I would like to get at these versions (if available) because they are written in assembly for high performance. (Most architectures provide an instruction for this function or similar.) 回答1: There is no standard function to achieve this and each compiler typically provides

Object code relocation and Intel Pin interaction

混江龙づ霸主 提交于 2019-12-11 02:55:12
问题 I am working on a multiprocessor architectural simulator that uses Intel Pin to instrument C++ executable binaries and report interesting events (e.g., some function calls, thread create/finish, etc.). Basically, I build an instruction-decode cache of all instructions when their images are loaded and analyze instruction execution afterwards. So it is important for instruction addresses at image-load time to be the same as (or at least get updated synchronously with) instruction addresses at