Closed GoogleCodeExporter closed 9 years ago
From r.peniaev: "Actually, on error ::mmap returns -1, not 0. E.g. we can easily catch double SIGSEGV on Linux while iterating modules in /proc/<pid>/maps if some module can't be mapped." --------- patch ------------- Index: src/common/linux/file_id.cc =========================================================== ======== --- src/common/linux/file_id.cc (revision 309) +++ src/common/linux/file_id.cc (working copy) @@ -101,7 +101,7 @@ } void *base = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); - if (!base) { + if ( base == MAP_FAILED ) { close(fd); return false; } Index: src/common/linux/dump_symbols.cc =========================================================== ======== --- src/common/linux/dump_symbols.cc (revision 309) +++ src/common/linux/dump_symbols.cc (working copy) @@ -759,7 +759,7 @@ return false; void *obj_base = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, obj_fd, 0); - if (!obj_base) + if ( obj_base == MAP_FAILED ) return false; MmapWrapper map_wrapper(obj_base, st.st_size); ElfW(Ehdr) *elf_header = reinterpret_cast<ElfW(Ehdr) *>(obj_base); Index: src/common/solaris/file_id.cc =========================================================== ======== --- src/common/solaris/file_id.cc (revision 309) +++ src/common/solaris/file_id.cc (working copy) @@ -151,7 +151,7 @@ return false; void *base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (!base) + if ( base == MAP_FAILED ) return false; bool success = false; Index: src/common/solaris/dump_symbols.cc =========================================================== ======== --- src/common/solaris/dump_symbols.cc (revision 309) +++ src/common/solaris/dump_symbols.cc (working copy) @@ -650,7 +650,7 @@ return false; void *obj_base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, obj_fd, 0); - if (!obj_base) + if ( obj_base == MAP_FAILED ) return false; MmapWrapper map_wrapper(obj_base, st.st_size); GElf_Ehdr elf_header;
Original issue reported on code.google.com by neal...@gmail.com on 22 Feb 2009 at 1:21
neal...@gmail.com
Original comment by neal...@gmail.com on 22 Feb 2009 at 1:34
Original issue reported on code.google.com by
neal...@gmail.com
on 22 Feb 2009 at 1:21