linux mmap出现Address 0x7ffff7ff6000 out of bounds>
来源:互联网 发布:爱奇艺 网络环境危险 编辑:程序博客网 时间:2024/06/06 01:45
**mmap.c** 1 #include <stdio.h> 2 #include <fcntl.h> 3 #include <signal.h> 4 #include <sys/mman.h> 5 #include <unistd.h> 6 #define FILESIZE 8192 7 8 int main() 9 { 10 int i; 11 char *p, tmp; 12 struct stat sb; 13 int fd = open("1.txt", O_RDWR | O_CREAT, S_IRUSR|S_IWUSR); 14 p = (char*)mmap(NULL,FILESIZE, PROT_READ|PROT_WRITE,MAP_SHARED, fd, 0); 15 for (i=0; i<10; i++) { 16 p[i] = 'a'; 17 } 18 close(fd); 19 munmap(p, FILESIZE); 20 printf("ok\n"); 21 return 0; 22 }
gcc mmap.c生成执行程序a.out, 运行a.out会出现总线错误 (核心已转储)
(gdb) p p $2 = 0x7ffff7ff6000 <Address 0x7ffff7ff6000 out of bounds>
用gdb去调试它会发现line 14映射的地址p有问题,而导致p有问题的原因是因为映射的文件1.txt的大小为0,也就是个空文件,修改方法很简单,让1.txt大小不为0就可以了。
mmap函数原型介绍
0 1
- linux mmap出现Address 0x7ffff7ff6000 out of bounds>
- Using GDB <Address 0xffffffff out of bounds>
- ArgumentException: Index out of bounds
- flexlib dataGrid out of bounds 解决方法
- Range or index out of bounds
- 数组溢出 Array out of bounds
- raised exception "Index out of Bounds"
- Range {2147483648, 4294967295} out of bounds;
- TypeError: value is out of bounds
- ValueError: y_i value out of bounds
- CWE -- Out-of-bounds Write 例子
- MongoDB和容易出现“mmap failed with out of memory”错误
- mongodb中出现mmap failed with out of memory的解决方法
- Dynamic MMap ran out of room
- Linux下update错误 E: Dynamic MMap ran out of room. 解决方法
- [收藏]Linux下update错误 E: Dynamic MMap ran out of room. 解决方法
- Linux下update错误 E: Dynamic MMap ran out of room. 的解决方法
- 【IndexError: index 1 is out of bounds for axis 0 with size 1】
- Linux 服务器安全技巧
- python中的正则表达式
- java数据结构之冒泡排序
- 渠道系统和 OA系统待办事项接口
- [设计]字象乾坤之字体的性格
- linux mmap出现Address 0x7ffff7ff6000 out of bounds>
- 进程kswapd0与events/0消耗大量CPU的问题
- pragma comment的使用(转)
- Java多线程的使用
- DevExtreme常用示例:如何在Visual Studio中创建本地封装包
- iOS开发——为什么我的scanForPeripheralsWithServices根本不起作用
- linux之cut用法
- [java] parse() valueOf() toString的区别
- 关于数据库字段长度字节(byte)和(bit)的几个概念问题!