1,138 questions
2
votes
2
answers
88
views
mallopt(M_PERTURB) does not perturb the memory on free
I am trying to catch memory-related bugs such as use-after-free by mallopt(M_PERTURB, <value>).
According to the doc, the memory will be initialized to value when it has been released by free.
...
0
votes
1
answer
71
views
WinDbg cannot find libc.so and libcoreclr
I am trying to debug a .Net memory dump taken from an Ubuntu system in WinDbg. When I try to load the dump I get the following errors:
Module name Error
libc.so The system ...
0
votes
1
answer
84
views
Getting a 32-bit program to run on a 64-bit distro without distribution-installed 32-bit libc [closed]
I'm trying to run an executable compiled for 32-bit Linux, on two machines running 64-bit Linux.
On one machine, the 32-bit version of glibc, and perhaps some related facilities, are installed as a ...
0
votes
1
answer
110
views
How can I get number of cores on android bionic uapi?
Android bionic defines a series of structs that are used specifically to handle kernel level
uapi data, like sysinfo.h header which defines a struct called sysinfo that defines registers for kernel &...
1
vote
1
answer
62
views
Compiling C++ sources for PLC based on Linux RT (Arm Cortex A8)
I'm a full beginner in Linux.
I need to program some PLC (ADAM 5630 of Advantech). It is based on the CPU TI Cortex A8 and has Linux RT 3.12 (Linux adam5630 3.12.10-rt15-ti2013.12.01; Distributor: ...
1
vote
0
answers
84
views
Why doesn't std::tolower(int) nor std::tolower(char, std::locale) convert Ç to ç? [duplicate]
From Linux/glibc, I have run some simple experiments to test how all char values are treated by std::tolower(int) -> int and std::tolower(char, std::locale) -> char. For my locale, I was ...
0
votes
0
answers
23
views
OnePlus 11 apps crashing (libc : Fatal signal 7 (SIGBUS), code 2 (BUS_ADRERR))
Using latest OS 15. Rooted via KSUN. When I open some apps it gets stuck in opening animation and the system server gets killed and a hot reboot is performed.
Any fix?
Here are pictures of logcat....
2
votes
1
answer
127
views
Confusion of the behavior open() with O_CREAT|O_EXCL in Linux
I am working on an embedded Linux system (kernel-5.10.188), where adbd is running in the target system.
In the target system I created a file with echo "hello" > /data/open, then I ran ...
0
votes
0
answers
86
views
How to resolve missing libc.so.6 dependency on minimal Linux guest OS in RPi4 hypervisor?
I'm working on a project which involves using a RPi4B in order to build an open source hypervisor with two guest OS: Linux and FreeRTOS. Now all that build process is complete, and I'm trying to ...
2
votes
1
answer
168
views
Using Standard C Library function on ARM64 macOS assembly doesn't work after linking [duplicate]
I'm on MacOS (Apple Silicon M4 processor, so, ARM64), and when trying to use puts from the standard C library:
.global main // 1
main: ...
2
votes
1
answer
864
views
In CMake, how can I declare a dependency on glibc with a specific or a minimum version?
Suppose I'm building a C library or app, and that my code uses libc (directly); but I'm relying on functionality or a bug fix which only became available in a certain version of glibc, or on a bug fix ...
1
vote
2
answers
94
views
Get codepage for underlying terminal on POSIX systems in C
I'm working on a own libc implementation for the purpose of education. Now I want support none-ANSI characters output. For the implementation from wprintf as example I want check the underlying ...
0
votes
0
answers
163
views
When does libc's gethostname return the "hostname", rather than the FQDN (or "host name")?
On my test system, hostname --fqdn returns the Fully Qualified Domain Name (FQDN) which is foo.example.com.
I need this information in several C++ apps, and I get it as:
char array[DNSDOMAIN_LEN];
...
0
votes
1
answer
731
views
Updating libc6 on Debian to a specific version [closed]
I use sudo apt install build-essential for downloading full stack for c compiling.
A almost all libs was downloaded without a problem, but several of them return 404 and not installed.
Libs was <...
4
votes
1
answer
286
views
Hook setenv(), getenv() using C code during runtime to make them thread safe [closed]
As it is already painfully known, modifying the process environment in a multi-threaded application during runtime is asking for trouble. However, not always we can control who accesses that.
In this ...
0
votes
0
answers
34
views
Python c_types libc bind method Wrong Answer
I am trying to create my own http server without using any low-level builtin library except ctypes but things are going terribly wrong.
My configuration is correct: IP address is correct, port is ...
1
vote
2
answers
462
views
Where are libc files located [duplicate]
When I write code such as
#include <stdio.h>
int main(int argc, char** argv) {
printf("Hello, world!\n");
return 0;
}
gcc imports stdio.h which in turn requires an associated ...
0
votes
1
answer
76
views
How to access the metadata that malloc stores for each block?
I know that depending of the implementation of malloc, the algorithm used differs (free linked lists, buckets, binary buddy... - and often it is a mix).
So I was wondering if it is possible to know ...
1
vote
2
answers
131
views
Check incomplete line in fgets()
To detect it, I've seen the following if condition:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
char line[5];
while(fgets(line, 5, stdin)){
int ...
2
votes
1
answer
175
views
Multiple definitions of glibc symbols when linking several static libraries with gcc
So I have made two libraries with gcc and ar: libwa.a and libws.a.
When I link them using -l flag in my project. I get this error:
/usr/bin/ld: .../lib/libws.a(bhns.c.o): in function `atoi':
bhns.c:(....
1
vote
0
answers
738
views
How to force compiler to use musl libc libraries and includes on glibc-based system?
I am on a glibc-based host system, although it has the musl libc installed.
How do I force the compiler to use the musl dynamic linker, use the musl headers and link against the musl libraries? ...
1
vote
1
answer
92
views
Which libc/stdio IO functions Perl uses to open a file?
Which libc/stdio functions does Perl use to open and read a file (e.g. for perl -e 'open(F,"<","test.txt");print(<F>);')?
I tried running this command under strace and it ...
5
votes
2
answers
155
views
Why -Wunused-value does not catch a statement `true;`?
Given following C code:
#include <stdbool.h>
int main (void)
{
true;
return 0;
}
I expect that -Wunused-value would cause a warning at line 5: true;
because this statement does ...
1
vote
1
answer
118
views
Extending libc's fmemopen stream structure to own the buffer and deallocate it on fclose
In libc there's an extension mechanism for implementing custom FILE* streams which allows custom open/read/seek/close callback to be attached to a custom struct.
glibc's impl: https://sourceware.org/...
1
vote
1
answer
1k
views
How to link to external library while compiling in Zig?
I am reading this reddit reply and I came across this:
To answer your question, Zig has a pretty unique and intimate relationship with libc. Zig can use libc (some Operating systems like MacOS and ...
3
votes
1
answer
109
views
Inconsistent return values from open function between libc and kernel syscall
When attempting to open a non-existent file on an iOS device, I observed inconsistent return values between the open function from the standard libc library and the kernel syscall (syscall number 5). ...
3
votes
2
answers
136
views
Interpreting the format specifier in printf("%.-1f", 34.14)
Consider the following invocation of printf():
printf("%.-1f", 34.14);
it specifies a negative precision value of -1. Making this call with glibc, we get:
%0.-1f
is this correct? If so, ...
5
votes
1
answer
288
views
Intercept open syscall in C, when called via fopen
I'm trying to code up a (limited) in-memory file system redirects via libc/syscall interception and returning memfd_create-produced file descriptors for the files that are virtualized. As a ...
2
votes
1
answer
532
views
Is there anyway to compile a Rust program without a dependency on a libc for Linux?
Is there anyway I could compile a Rust program to a binary which does not depend on a libc for runtime and for Linux?
1
vote
0
answers
157
views
Self build toolchains for RISC-V lacking correct libc
I'm trying to bootstrap compile the toolchains for Vortex, which is an open source GPGPU based on RISC-V ISA. I followed the README.vortex in the pocl source file pulled from https://github.com/...
0
votes
0
answers
926
views
What is the difference between libgcc and libc?
I need to use the C standard to compile with my POSIX implementation. I downloaded the precompiled lib of gcc-11.2, but after unzipping, I am facing libgcc.a and libc.a libraries.
I tried to compile ...
3
votes
1
answer
843
views
Can I point CMake to use the (older) libc of a different rootfs?
I'm moving this here from the CMake Discourse. I’m trying to set up CMake to cross compile an application that will run on an old (Debian stretch ~2017) Linux system (functioning, but slow, so I'd ...
0
votes
1
answer
185
views
C++ and syscalls: ignoring return value and checking errno instead
Error checking in C is a task that is very verbose and makes the code unreadable. In C++ you have exceptions, but when I use C++ to call C functions, the headaches come back. I wish there was a "...
4
votes
0
answers
96
views
Why is the argument `nelp` in POSIX's `lfind` function (search.h) not `const`?
POSIX Issue 7, 2018 defines the prototype of function lfind in search.h as:
void *lfind(const void *, const void *, size_t *,
size_t, int (*)(const void *, const void *));
Or, more ...
1
vote
0
answers
2k
views
How to install libc debug symbols (libc6-dbg) on Ubuntu 20.04? /usr/lib/debug empty after installing libc6-dbg
I need the debug symbols for libc on Ubuntu 20.04 for performance profiling in gperftools (or perf). I checked how to install them and used:
sudo apt-get install libc6-dbg
After successfull ...
0
votes
1
answer
304
views
Extra Bytes Added to Packet When Sending via Raw Socket
Description
I'm currently trying to send packets via a raw socket in Rust. I'm currently using libc to manage the socket.
I've had success with sending the packet but the packet sent is never the same ...
0
votes
1
answer
156
views
Segfault on calling function pointer obtained with dlopen() in Rust
I am currently playing with POSIX functions defined in dlfcn.h with Rust, with the goal of calling a function in a separated .so file.
The project actually contains 2 crates:
The binary loading the ...
0
votes
2
answers
449
views
Why "all warnings being treated as errors" occurs even added "set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)" to CMakeLists.txt?
I'm building the llvm-18.1.3 and facing the all warnings being treated as errors error as follows:
/home/pi/llvm-project-llvmorg-18.1.3/libc/src/stdlib/bsearch.cpp:16:28: error: ‘void* ...
0
votes
1
answer
287
views
attempting to link libc statically with clang, ldd showing dynamic linking?
I'd like to compile a C program with system libraries (such as libc) linked statically, with all my other custom libraries (such as openssl) linked dynamically. When I compile a "Hello World"...
1
vote
1
answer
294
views
Compiling without a standard library but with the _start label (entry point)
I am building my own 32-bit x86 OS in which I load user programs from ELF files. When compiling the user C programs I use -nostdlib to exclude GLIBC and link my own LIBC instead. The problem is that ...
0
votes
1
answer
88
views
How to change only one of last (change | modification | access ) times in linux (UNIX)?
In some previous days, I searched and asked some questions about a file different timestamps.
Now I know I can get creation time by statx(2) and change only one of last (status change | modification | ...
1
vote
1
answer
134
views
file creation time system call in linux/gcc
As I know, stat/fstat system call tell us only 3 times about a file
Time of last access (st_atim field)
Time of last modification (st_mtim field)
Time of last status change (st_ctim)
and when I run ...
2
votes
0
answers
103
views
compile gcc on openbsd for libgccjit -- unable to find libc.a
I have cloned gcc repo from (https://github.com/gcc-mirror/gcc/tree/releases/gcc-13). Configured within build directory as such:
../configure --enable-host-shared --enable-languages=jit,c++ --disable-...
-1
votes
1
answer
155
views
yescrypt && memory usage
We're using yescrypt from libc's crypt(3) function to encrypt and check credentials in our C-written application server. Sometimes the crypt(3) fails because the application gets SIGKILL from the ...
0
votes
1
answer
152
views
Where do man pages about libc come from if they do not come from glibc?
Where do the man pages about libc come frome?
They cannot come from glibc because they slightly differ from glibc's API.
One example is the man page for mmap. It describes a flag MAP_UNINITIALIZED.
...
1
vote
2
answers
454
views
C: How is binary-mode versus text-mode implemented for `fopen`?
As a learning exercise, I am attempting to write a platform layer in C for Windows and GNU/Linux operating systems.
I am currently interested in implementing a function which opens a file on the host ...
0
votes
3
answers
210
views
__libc_init_array and global declared objects in cpp
I have a micro controller c++ project where I declare as much as possible globally instead of newing objects. In fact, I am not using the new keyword anywhere.
I now ran into the situation where the ...
2
votes
1
answer
473
views
GLIBC : How to tell the executable to link to specific version of GLIBC [duplicate]
We are building a GTK3 application targeting Ubuntu 18.04 LTS and all the later releases. But when we build an application in Ubuntu version 20.04, that application can't run on the older Ubuntu ...
3
votes
1
answer
659
views
What are link maps in libdl and why they crash my app?
Recently I tried to build a complex C++ application. App was built. But when I tried to launch it it crashed with illegal memory access. Actually it was null pointer with offset.
I started to ...
0
votes
0
answers
74
views
API for getting list of nameservers used in system
Is there a way (API) to get list of nameservers on Linux except of well known res_(n)init?
options:
use of .nscount and .nsaddr_list[] after res_(n)init() call
parsing resolv.conf on your own
???
...