1,133 questions
-1
votes
1
answer
52
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
146
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
27
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
73
views
Where are libc files located
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
0
answers
18
views
Shared memory issue between threads when using clang's nvptx loader
While compiling using clang (20.0.0) I am using nvptx64-nvidia-cuda as target and taking advantage of the recent libc for gpu feature I have found the following issue
#include <stdlib.h>
#...
0
votes
1
answer
60
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
111
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
64
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:(....
0
votes
0
answers
72
views
libc.so react native memory leak crash on firebase crashlytics
I'm encountering persistent crashes in my React Native app (version 0.72.7) with Hermes enabled. I've analyzed the memory graph for a video component in my app, which has raised concerns about ...
0
votes
0
answers
197
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
77
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
140
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
54
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
335
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
95
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
108
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
166
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 ...
0
votes
1
answer
166
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
66
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
417
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 ...
0
votes
0
answers
31
views
Questions on tls.offset calculation in musl libc
I am reading musl libc source code.
In load_library function in ldso/dynlink.c, I noticed a formula calculating p->tls.offset, here is the snippet:
#ifdef TLS_ABOVE_TP
p->tls.offset = ...
2
votes
1
answer
355
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
131
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
89
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 ...
0
votes
0
answers
779
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
178
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
121
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
211
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
108
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
147
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
67
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
64
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 ...
0
votes
0
answers
77
views
Android 14 crashing with libc of OpenCV
I'm doing a project in which I use OpenCV to manipulate some images, and everything is ok on android 13 or previous, but I've updated my S23 to Android 14 (OneUI 6.1) and now android studio crash with ...
1
vote
0
answers
58
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-...
0
votes
0
answers
92
views
Get search paths for headers in the standard library in Clang?
I am building a programming language using C++, LLVM, Clang, LLDB, user can write import "@stdio.h" which is similar to #include <stdio.h> so now I need to support C like imports of ...
-1
votes
1
answer
77
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
89
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
260
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
150
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 ...
0
votes
0
answers
237
views
Compile clang into WASM using WASI-SDK
I'm trying to compile "clang" and "lld" into web assembly with the WASI-SDK 21.0 as my system root directory. I got build errors while compiling but I cannot resolve them properly.
...
2
votes
1
answer
363
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
579
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
68
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
???
...
1
vote
1
answer
73
views
Why does not 'LANG=C' affect "Segmentation fault" message?
Here is small test C program which just intentionally crashes:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char *l = getenv("LANG");
printf("LANG = %s\n&...
1
vote
0
answers
48
views
How to disallow compilation against older shared libraries in cmake
I have a cmake C project that needs to be compiled against libc.
I want to use a function (getgrouplist) that contains a bug in glibc versions prior to 2.3.3.
I want to disallow compilation on ...
0
votes
2
answers
127
views
Linux userspace api: how to get size of address spaces of running executable linked as PIE without parsing /proc/self/maps?
With help of dl_iterate_phdr I can load start address of main executable and all binaries via dlpi_addr and it is correlates to function pointers address I can print via printf, however other fields , ...
0
votes
0
answers
57
views
moved libc.so and libc.so.6 to my /home/ dir. Can I move them back to /lib/ using a live Ubuntu image?
I stupidly moved the libc.so and libc.so.6 files to my /home/ dir. I thought I could replace them with a newer version that I compiled under /home/glibc/build but, of course, I then realised that no ...
0
votes
1
answer
653
views
Unreal Engine 5 fails to start on Ubuntu 22.04
On Ubuntu 22.04 freshly installed from Server ISO (Ubuntu 22.04.3 LTS x86_64 5.15.0-91-generic) UE5 fails to start with SIGSEGV in libc.6.so. Engine does not tell any details about function which ...
1
vote
0
answers
485
views
Nix-shell: llvm clang based cross-compilation with llvm-libc for static linkage, never finds libc "-lc"
my goal is to setup an shell.nix for C and C++ cross-compiling using llvm's clang and it's corresponding libc and libc++ for static linking.
With following hello.c
#include <stdio.h>
int main (...
1
vote
2
answers
229
views
Is there a way to run .so library(compiled by NDK for android aarch64) on linux aarch64(cent7 arm)?
I have a compiled aarch64 shared library (my_custom.so) that has been successfully integrated into an APK and runs on Android devices. As it is a standalone low-level computational library without ...