glibc

glibc detected - double free or corruption

試著忘記壹切 提交于 2019-12-11 02:49:48
问题 I get the following error messages when I submit the code (pasted below) to an online gcc compiler. * glibc detected /run-1326102706-2046832693/solution: double free or corruption (!prev): 0x091901a8 ** ======= The code is as follows: # include <iostream> # include <string> # include <list> # include <cstring> using namespace std; int main() { int test_cases, i, score, str_len; string str; char first_char, current_char; list <int> strlist; list <int> :: iterator it; cin>>test_cases; char

How to use __malloc_hook?

独自空忆成欢 提交于 2019-12-11 02:19:14
问题 In GNU C Library Reference Manual , there is an example program(p.65), But I don't know what the three sentences: __malloc_hook = old_malloc_hook; old_malloc_hook = __malloc_hook; __malloc_hook = my_malloc_hook; mean. Especailly the second one, who can explain for me? thanks. static void * my_malloc_hook (size_t size, const void *caller) { void *result; /* Restore all old hooks */ __malloc_hook = old_malloc_hook; __free_hook = old_free_hook; /* Call recursively */ result = malloc (size); /*

How to wrap glibc library functions to automatically use 'unsigned char' and 'wchar_t'?

时光毁灭记忆、已成空白 提交于 2019-12-11 01:55:29
问题 I always use char as unsigned char and wchar_t as wint_t . Given that, does there exist a solution to change function interfaces to use those types with or without recompiling glibc? See also this question: How to change wchar.h to make wchar_t the same type as wint_t? 回答1: You can pass a command line option to the compiler to make char unsigned by default. Changing the interface to standard library functions by redefining char with macros and typedefs is not the correct way to achieve your

Equivalent of fesetflushtozero() on various Unices

最后都变了- 提交于 2019-12-11 01:31:18
问题 This question was migrated from Unix & Linux Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . HP-UX's libc has the function fesetflushtozero to switch floating-point behavior between “gradual underflow” and “flush to zero”. Despite combing through documentation and man pages of several Unix libc's (including glibc), I have yet to find how to achieve the same thing in other Unices. I'm particularly interest in Linux/glibc, Solaris and AIX. 回答1: As you have

Error unsupported relocate against assembly system call

江枫思渺然 提交于 2019-12-11 00:00:15
问题 I am trying to cross compile glibc-2.18 for powerpc freescale evaluation board. At one of the stages in the build I get following error: glibc Failed: ../sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S: Assembler messages: ../sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S:40: Error: unsupported relocation against swapcontext make[3]: *** [/home/user/Desktop/SmoothWall/bcutm/distrib/build/sources/glibc/glibc-2.18-compile/stdlib/setcontext.o] Error 1 make[3]: Leaving directory

setvbuf() - size parameter when buf is NULL

两盒软妹~` 提交于 2019-12-10 23:39:36
问题 It seems that when I run the following code: #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv) { int i=0; setvbuf(stdout, NULL, _IOLBF,0); while (1) printf("%d ",i++); return 0; } it prints in chunks of 1024 chars, no matter the size I define for setvbuf(). The question is is if size affects somehow in this case and where is the definition for 1024 chars is coming from. 回答1: I don't know how you identified 1024 but it's probably BUFSIZ . BUFSIZ is defined in stdio.h . If

基于Java实现hello/hi简单网络聊天程序

a 夏天 提交于 2019-12-10 22:15:52
目录 Socket简要阐述 Socket的概念 Socket原理 hello/hi的简单网络聊天程序实现 服务器端 客户端 程序执行结果 跟踪分析调用栈 & Linux API对比 创建ServerSocket 调用栈图示 源码分析 Socket绑定 调用栈图示 源码分析 Socket监听 调用栈图示 源码分析 Socket Accept 调用栈图示 源码分析 Java Socekt API与Linux Socket API 参考链接 Socket简要阐述 Socket的概念 Socket的英文原义是“孔”或“插座”。 在网络编程中,网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个Socket。 Socket套接字是通信的基石,是支持 TCP/IP协议 的网络通信的基本操作单元。 它是网络通信过程中端点的抽象表示,包含进行网络通信必须的五种信息:连接使用的协议,本地主机的IP地址,本地进程的协议端口,远地主机的IP地址,远地进程的协议端口。 Socket本质是 编程接口(API) ,对TCP/IP的封装,TCP/IP也要提供可供程序员做网络开发所用的接口,这就是Socket编程接口。 HTTP是轿车,提供了封装或者显示数据的具体形式;Socket是发动机,提供了网络通信的能力。 Socket原理 Socket实质上提供了进程通信的端点。进程通信之前

why stdout can't be substituted?

邮差的信 提交于 2019-12-10 19:43:21
问题 for educational purposes, i'm trying to substitute the standard streams stdout, stdin, and stderr. i first looked up the data type of the streams, which i traced back to the struct _IO_FILE with the following members (gdb ptype _IO_FILE): type = struct _IO_FILE { int _flags; char *_IO_read_ptr; char *_IO_read_end; char *_IO_read_base; char *_IO_write_base; char *_IO_write_ptr; char *_IO_write_end; char *_IO_buf_base; char *_IO_buf_end; char *_IO_save_base; char *_IO_backup_base; char *_IO

Load both musl libc.so and gcc libc.so in the same process?

不羁的心 提交于 2019-12-10 17:46:33
问题 I have a shared library compiled with musl libc $ readelf -d ./libinterop_d.so Dynamic section at offset 0x8ecb0 contains 22 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libc.so] 0x000000000000000f (RPATH) Library rpath: [/usr/local/musl/lib] 0x000000000000000c (INIT) 0x46350 0x000000000000000d (FINI) 0x7664a 0x0000000000000019 (INIT_ARRAY) 0x28e700 0x000000000000001b (INIT_ARRAYSZ) 64 (bytes) 0x000000000000001a (FINI_ARRAY) 0x28e740 0x000000000000001c (FINI