1,138 questions
1
vote
1
answer
85
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
55
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
186
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
72
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
1k
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
831
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
304
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 ...
1
vote
1
answer
116
views
Setting primary group in c# on Linux
In Linux, I am logged in as bj:bj as non root user:group.
bj@pc-bj:~$ id
uid=1000(bj) gid=1000(bj) groups=1000(bj),5(tty),20(dialout),24(cdrom),25(floppy),29(audio),1006(internetallowed)
I want to ...
0
votes
0
answers
72
views
What are the extra digits when printing floating point numbers in decimal format in C? [duplicate]
If I use printf with a high precision and print a floating point number, I get extra numbers beyond what is represented by the type.
For example:
const double x = 1.0 / 3.0;
printf("%.50f\n",...
0
votes
0
answers
141
views
Maximum number of unix domain sockets that can run in the same time on linux
What is the maximum number of unix domain socket that linux can manage in parallel, besides the file descriptor limit that we can change?
Some Os have a limit https://www.ibm.com/docs/en/ztpf/1.1.0.15?...
1
vote
0
answers
494
views
Function of __syscall_cp In Musl Libc
I am working with a fork of Musl libc to add to a toy operating system I am building for a project. One of the challenges is that my OS has a slightly different calling convention which has ...
1
vote
1
answer
180
views
Could allocation size of zero in malloc result in conflicting memory locations?
So from the explanation of malloc(0) question. I find it counterintuitive that the notion of the zero size of the allocated memory chunk when returning a not-NULL value. (concluded from here)
Since, ...
0
votes
1
answer
75
views
Is there a macro that defines the limit of non-significant digits when printing a double floating point number in C?
When using printf with a large precision and a double floating point number, there is rounding that occurs on non-significant digits (when the trailing 0's start). I'm wondering if there is a macro ...
0
votes
1
answer
6k
views
Python 3.11 upgrade - lib64/libc.so.6: version `GLIBC_2.28' not found
Python 3.11 upgrade throws error: lib64/libc.so.6: version GLIBC_2.28' not found [ERROR] Runtime.ImportModuleError: Unable to import module 'xxxxx': /lib64/libc.so.6: version GLIBC_2.28' not found (...
0
votes
1
answer
99
views
Dynamic linked to libc in Linux does not have bind/connect
Is that true that Go dynamic linked to libc in Linux and Mac is different? I am trying to evaluate the use of LD_PRELOAD (Linux) or DYLD_INSERT_LIBRARIES (macOS) to intercept the bind (listen) ...
0
votes
1
answer
211
views
how to constrain gcc to a certain runtime environment
We have a CI pipeline that builds a bunch of projects. One of the projects uses advanced C++ features (C++20) and so we've upgraded our gcc version to gcc-9.
However, we have some target embedded ...
0
votes
1
answer
310
views
Can libc be faster than syscall?
I am working on heavily optimizing some code (thankfully no platform independence - Linux only). I created a very simple framework for measuring time passed (in clock cycles). An idea I had early was ...
1
vote
1
answer
168
views
How can I test my own implementation of GLIBC in NASM x64?
I'm currently developing my NASM x64 version of GLIBC, and I'm having a problem testing it. The ASM code is first compiled in .so, next my test code (in C language) is compiled via GCC, then I load my ...
-1
votes
1
answer
370
views
What is __LIBC_HIDDEN__ in C header?
Introduction
In a log output of a crash, there is an error with backtrace output as:
#00 pc 00038cf0 /apex/com.android.runtime/lib/bionic/libc.so (__futex_wait_ex(void volatile*, bool, int, bool, ...
0
votes
0
answers
45
views
Segmentation fault on ubuntu 23.04 scanf [duplicate]
This same code when I compile it using this command: gcc chal.c -fno-pie -no-pie -fno-stack-protector -O0 -g -o chal
#include <stdio.h>
#include <string.h>
int main() {
char a[2];
...
2
votes
1
answer
397
views
How to get C11 threads (and other) man pages on linux system
I can't find manual pages for any of the functions declared in threads.h added in C11.
There is good documentation for them in https://en.cppreference.com/w/c/11
and in the glibc docs, however I would ...
1
vote
1
answer
161
views
Is it true that on a Linux Ubuntu system the main function is called by the _libc_start_main function?
My system : Ubuntu 22.04.3 running on x86_64 CPU.
I have this C program in a file named test.c :
int main(){
long int a = 10;
long int b = 20;
}
I've compiled the file with "gcc test.c -...
0
votes
1
answer
1k
views
libc.so.6 error while compiling C++ program
I am a complete beginner in C++ and trying to run my first program.
#include <iostream>
int main()
{
std::cout << "Hello world!";
return 0;
}
Then I run, in the ...
0
votes
1
answer
407
views
libc6 package breaks existing packages on air gapped server
I'm running ubuntu 20.04 amd64 and trying to upgrade libc6 package on my air gapped server.
I have my own apt repositories, where i store all the packages i download. I downloaded the latest version ...
0
votes
0
answers
300
views
LD_PRELOAD'd jemalloc causes GLIB_2.32 not found
Problem
I'm trying to profile a Java program which uses JNI. I'm using this as a guide.
I've downloaded version 5.3.0 of jemalloc.
I've done configure and make to build it (in the rockylinux:8.8 ...
3
votes
1
answer
814
views
How can I ensure gcc + libc has UTF-8 for multibyte strings and UTF-32 for wchar_t?
I want to know how to force a GCC + GNU libc toolchain into normal Unicode behaviour, where the source code files encoding is UTF-8, and where the compiled program uses UTF-8 as its multibyte ...
0
votes
0
answers
102
views
How to sync system time with a big delta in C
i am working on a NTP v4 client, and i wanted to know how i can adjust system time accordingly.
i found adjtime(3) which basically adjust's the system clock's speed by some amount thus the system ...
1
vote
1
answer
345
views
Why does the GNU coding standard prefer getopt_long over argp?
I do not understand why the GNU Coding Standard has the following line in Section 4.2 - Writing Robust Programs
Use getopt_long to decode arguments, unless the argument syntax makes this unreasonable....
0
votes
0
answers
424
views
Cannot cross-compile rust/bevy from WSL2 ubuntu via Dockerfile with target stable-x86_64-pc-windows-gnu
Im not very familliar with Docker OR with rust cross compilation maybe somebody can point out what I'm doing wrong here.
The environment is not relevant but im on WSL2: ubuntu and I'm trying to ...
0
votes
1
answer
828
views
strerrorname_np and strerrordesc_np cause seg fault on linux gcc
I have been reading through info libc, and in section 2.3 "Error Reporting - Error Messages" it mentions the following two functions:
-- Function: const char * strerrorname_np (int ERRNUM)
|...
3
votes
2
answers
15k
views
What is the purpose of strlcpy and what was in the first version of its manual page?
By reading the man of strlcpy I met example:
Since it is known how many characters were copied the first time,
things can be sped up a bit by using a copy instead of an append:
char *dir, *file, ...
1
vote
2
answers
871
views
Checking that a static library does not contain undefined symbols exept ones from libc and stdlib
I build a c++ software module that is delivered as header files (.h) containing the API and a static library (.a) with the implementation.
The module only depends on standard libraries so I want to ...
1
vote
0
answers
374
views
How to compile a Rust project that includes libc dependencies to wasm?
For some reason I need to translate a piece of C code to Rust with c2rust and then compile it to wasm. The Rust code is as follows:
extern "C" {
fn printf(_: *const libc::c_char, _: ...) ...
2
votes
1
answer
530
views
Problem with OMNeT++ installation on Ubuntu: How to resolve 'Standard C math library -lm not found' error during ./configure?
I have a problem with the installation of OMNeT++ on Ubuntu. The error occurs during the ./configurecommand and relates to the math library: configure: error: Standard C math library -lm not found.
I ...
2
votes
1
answer
316
views
fflush(NULL) and POSIX compliance
TL;DR: Is it posixly incorrect for fflush(NULL) not to flush stdin?
Consider the following code snippet,
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(void) {
...
1
vote
1
answer
235
views
Why Speed of execution depends on the libc used?
When I link my executable to a libc built by myself with Crosstool-NG, the execution of my program is incomparably slower than if I link my executable with a libc built by a company called Nucleisys ...
3
votes
0
answers
446
views
How do you force the Linux kernel to reclaim unused process memory in C#?
This code creates 2 GiB of objects, then garbage collects them. Afterwards, the process is still using 2 GiB+ of memory. In Windows, I was able to force Windows to reclaim the memory by calling ...
2
votes
2
answers
2k
views
How to Fix Undefined Reference To PThread on Musl x86_64 LibC?
I've been trying to compile against Musl for a while now. My goal is to make a game engine binary which can execute on as many x86_64 Linux distros as possible with the same binary.
The problem is, ...
1
vote
1
answer
54
views
Random characters failing libc read
I'm writing a (dotnet) program that outputs random bytes to stdout.
These characters are then piped into another program that uses the libc read function.
{
char v4[76]; // [rsp+0h] [rbp-50h] BYREF
...
-1
votes
1
answer
429
views
ret2libc: sh: line 1: command not found
So I've been trying to develop a ret2libc exploit for my program as shown below:
#include <stdlib.h>
#include <stdio.h>
void vuln()
{
char arr[0x10];
scanf("%s", arr);
...
3
votes
1
answer
1k
views
Why does gcc choose the most basic memset() implementation?
My bare-metal program manually calls memset() to zero entire/aligned 4k pages like this (I'm not using uint64_t, but another 8-byte thing):
uint64_t something[512] __attribute__((aligned(4096)));
...
0
votes
2
answers
438
views
Why does gdb backtrace shows more detail that perf call stack?
I've run some sample code through perf, and get the following top hotspot:
- 63.93% 0.10% bonds libc.so.6 [.] __GI___fstatat64 ...
-1
votes
1
answer
257
views
Meaning of the [k] symbol in perf report output
What is the meaning of the [k] symbol I can see in the following perf report output:
+ 63.93% 0.10% sample libc.so.6 [.] __GI___fstatat64
+ 63.82% 63.82% sample [...
1
vote
0
answers
528
views
C Library not compatible between Docker Container and Golang built executable
I am trying to add a Golang script to my REST API and I am facing a problem of compatibility between my Golang executable and the Docker my docker container. Let me give you some context:
This is what ...
1
vote
0
answers
130
views
How to diagnose stalls when writing to a `TUN` device?
EDIT: This may be an issue with tun library I'm using https://github.com/yaa110/async-tun/issues/2
I am learning about linux networking and trying to build a simple VPN tunnel using libp2p. The code I ...
1
vote
1
answer
298
views
cobc generated "Segmentation fault" for gnuCOBOL
I'm trying to compile and execute the hello world example in:
https://gnucobol.sourceforge.io/historical/open-cobol/Hello-World-.html
But when I compile with:
$ cobc hello.cob
I get a hello.so ...
0
votes
1
answer
122
views
Difference between __errno_location defined in "csu/errno-loc.c" "nptl/errno-loc.c"
I noticed that in Glibc the macro "errno" got expanded to an invocation of "__errno_location". However, there are two different definitions of "__errno_location":
The ...
1
vote
0
answers
106
views
Call exported function in .so which was linked with a different libc than the program calling the function
Situation
Let me explain my situation:
I'm running all this stuff on Android chroot with root access and SELinux disabled
I have a program linked against glibc in the chroot (can't relink it, since I ...
1
vote
1
answer
939
views
Tries of downgrading libc6 package causes serious problems [closed]
I try to set up a local server and during the installation I get an error lined with failing build of librockdb-sys, error below:
Compiling serde_json v1.0.79
Compiling bincode v1.3.3
Compiling ...
2
votes
1
answer
417
views
Check if `_GNU_SOURCE` or `_BSD_SOURCE` is supported by the libc?
I am curious if asprintf is available. Some libc implementations provide it under specific Feature Test Macros. Namely if you #define _GNU_SOURCE or #define _BSD_SOURCE you can get asprintf and a few ...