libc

Why does an fread loop require an extra Ctrl+D to signal EOF with glibc?

感情迁移 提交于 2021-02-18 10:13:37
问题 Normally, to indicate EOF to a program attached to standard input on a Linux terminal, I need to press Ctrl+D once if I just pressed Enter, or twice otherwise. I noticed that the patch command is different, though. With it, I need to press Ctrl+D twice if I just pressed Enter, or three times otherwise. (Doing cat | patch instead doesn't have this oddity. Also, If I press Ctrl+D before typing any real input at all, it doesn't have this oddity.) Digging into patch 's source code, I traced this

Memcpy segfaulting with valid pointers

穿精又带淫゛_ 提交于 2021-02-17 02:16:08
问题 I'm using libcurl in my program, and running into a segfault. Before I filed a bug with the curl project, I thought I'd do a little debugging. What I found seemed very odd to me, and I haven't been able to make sense of it yet. First, the segfault traceback: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffe77f6700 (LWP 592)] 0x00007ffff6a2ea5c in memcpy () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) bt #0 0x00007ffff6a2ea5c in memcpy () from /lib/x86_64-linux

Memcpy segfaulting with valid pointers

房东的猫 提交于 2021-02-17 02:13:08
问题 I'm using libcurl in my program, and running into a segfault. Before I filed a bug with the curl project, I thought I'd do a little debugging. What I found seemed very odd to me, and I haven't been able to make sense of it yet. First, the segfault traceback: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffe77f6700 (LWP 592)] 0x00007ffff6a2ea5c in memcpy () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) bt #0 0x00007ffff6a2ea5c in memcpy () from /lib/x86_64-linux

Capturing stdout/stderr separately and simultaneously from child process results in wrong total order (libc/unix)

天涯浪子 提交于 2021-02-10 14:43:49
问题 I'm writing a library that should execute a program in a child process, capture the output, and make the output available in a line by line (string vector) way. There is one vector for STDOUT, one for STDERR, and one for "STDCOMBINED", i.e. all output in the order it was printed by the program. The child process is connected via two pipes to a parent process. One pipe for STDOUT and one for STDERR. In the parent process I read from the read-ends of the pipes, in the child process I dup2() 'ed

Capturing stdout/stderr separately and simultaneously from child process results in wrong total order (libc/unix)

倖福魔咒の 提交于 2021-02-10 14:42:20
问题 I'm writing a library that should execute a program in a child process, capture the output, and make the output available in a line by line (string vector) way. There is one vector for STDOUT, one for STDERR, and one for "STDCOMBINED", i.e. all output in the order it was printed by the program. The child process is connected via two pipes to a parent process. One pipe for STDOUT and one for STDERR. In the parent process I read from the read-ends of the pipes, in the child process I dup2() 'ed

How are the trigonometric functions tested in the GNU C Library?

时间秒杀一切 提交于 2021-02-09 06:59:07
问题 I'm trying to figure out how to best write unit tests for scientific and/or mathematical functions. I searched the source code for the GNU C Library for unit tests for the sin() and cos() functions and came across the atest-sincos.c source file, reproduced below. (It can be found here) Can someone walk me through this file and give a rough idea what is being tested here? I see what looks very much like the Runge-Kutta algorithm for numerically solving differential equations, and also possibly

what is libc? what are the functions it includes? how can we get the source code of it?

こ雲淡風輕ζ 提交于 2021-02-07 13:53:40
问题 As per Wikipedia there are many variants of standard C library based on operating system and compilers. Ref: http://en.wikipedia.org/wiki/C_standard_library But I want to understand that how plenty of functions which are declared in different headers(eg: stdio.h, string.h, stdlib.h etc. ) are defined in single library. Is the source code file is same for all these header files or there are different libraries for stdio.h, string.h etc? As I am beginner to programming I don't know if multiple

what is libc? what are the functions it includes? how can we get the source code of it?

亡梦爱人 提交于 2021-02-07 13:53:26
问题 As per Wikipedia there are many variants of standard C library based on operating system and compilers. Ref: http://en.wikipedia.org/wiki/C_standard_library But I want to understand that how plenty of functions which are declared in different headers(eg: stdio.h, string.h, stdlib.h etc. ) are defined in single library. Is the source code file is same for all these header files or there are different libraries for stdio.h, string.h etc? As I am beginner to programming I don't know if multiple

gcc: Reduce libc required version

非 Y 不嫁゛ 提交于 2021-02-05 20:01:53
问题 I am trying to run a newly compiled binary on some oldish 32bits RedHat distribution. The binary is compiled C (not++) on a CentOS 32bits VM running libc v2.12. RedHat complains about libc version: error while loading shared libraries: requires glibc 2.5 or later dynamic linker Since my program is rather simplistic, It is most likely not using anything new from libc. Is there a way to reduce libc version requirement 回答1: An untested possible solution What is "error while loading shared

Understanding the gcc version and the GLIBC, GLIBCXX versions in more detail

自作多情 提交于 2021-02-05 05:07:47
问题 Assume I have the following local gcc, g++ version: $ gcc -v $ g++ -v gcc version 6.3.1 I don't understanding the relation and meaning of the following compared to my compiler version: What is this referring to? /usr/lib64/libstdc++.so.6 Trying to run a binary and I get this error, what is GLIBCXX_3.4.20 referring to? why is the number starting with 3? /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found What is all this? $ strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX GLIBCXX_3.4