ASSERT vmareas.c in dr_map_executable_file for some standalone_library uses
I'm hitting an assert in vmareas.c on post-processing when launched from the drcachesim front-end. Running raw2trace directly works:
$ clients/bin64/drraw2trace -verbose 1 -indir drmemtrace*.dir/ -out drmemtrace.simple_app.141525.0384.dir/trace/
[drmemtrace]: Iterating dir drmemtrace.simple_app.141525.0384.dir/raw
<...>
[drmemtrace]: Successfully converted 1 thread files
$ rm -rf drmemtrace*.dir/trace && bin64/drrun -t drcachesim -verbose 2 -simulator_type func_view -indir drmemtrace.*.dir
ninja: no work to do.
[drmemtrace]: Iterating dir drmemtrace.simple_app.141525.0384.dir/raw
[drmemtrace]: Opened input file drmemtrace.simple_app.141525.0384.dir/raw/drmemtrace.simple_app.141525.3408.raw
[drmemtrace]: Opened output file drmemtrace.simple_app.141525.0384.dir/trace/drmemtrace.simple_app.141525.3408.trace.gz
[drmemtrace]: Worker 0 assigned trace thread 0
[drmemtrace]: Reading module file from memory
<Application /home/bruening/dr/git/build_x64_dbg_tests/clients/bin64/drcachesim (142423). Internal Error: DynamoRIO debug check failure: /home/bruening/dr/git/src/core/vmareas.c:3674 !vm_area_overlap(dynamo_areas, start, end)
(Error occurred @0 frags)
version 7.91.18321, custom build
-no_dynamic_options -no_deadlock_avoidance -no_vm_base_near_app
0x00007ffe1509a640 0x00007f5d526d2f6e
0x00007ffe1509a890 0x00007f5d5278d7e4
0x00007ffe1509a8d0 0x00007f5d527684e2
0x00007ffe1509a940 0x00007f5d5276c197
0x00007ffe1509a9c0 0x00007f5d528fc7ec
0x00007ffe1509aaa0 0x00007f5d528e2d07
0x00007ffe1509ae50 0x00007f5d527e036c
0x00007ffe1509ae90 0x0000556235654099
0x00007ffe1509b040 0x00005562356415fa
0x00007ffe1509b060 0x0000556235653cd8
0x00007ffe1509b0b0 0x0000556235655a17
0x00007ffe1509b1e0 0x00005562355e90f6
0x00007ffe1509b6b0 0x00005562355d61f6
0x00007ffe1509bdc0 0x00007f5d52124bbb
0x00005562356be930 0x5541d68949564100>
Breakpoint 1, report_dynamorio_problem (dcontext=0x0, dumpcore_flag=8, exception_addr=0x0, report_ebp=0x0,
fmt=0x7ffff7c1eed0 "DynamoRIO debug check failure: %s:%d %s\n(Error occurred @%d frags)") at /home/bruening/dr/git/src/core/utils.c:2141
2141 synchronize_dynamic_options();
(gdb) bt
#0 report_dynamorio_problem (dcontext=0x0, dumpcore_flag=8, exception_addr=0x0, report_ebp=0x0,
fmt=0x7ffff7c1eed0 "DynamoRIO debug check failure: %s:%d %s\n(Error occurred @%d frags)") at /home/bruening/dr/git/src/core/utils.c:2141
#1 0x00007ffff79c3f6e in d_r_internal_error (file=0x7ffff7c35008 "/home/bruening/dr/git/src/core/vmareas.c", line=3674,
expr=0x7ffff7c37220 "!vm_area_overlap(dynamo_areas, start, end)") at /home/bruening/dr/git/src/core/utils.c:176
#2 0x00007ffff7a7e7e4 in add_dynamo_vm_area (start=0x7fff7739a000 "\177ELF\002\001\001", end=0x7fff773b1000 "", prot=3, unmod_image=true,
comment=0x7ffff7c31df7 "map_file") at /home/bruening/dr/git/src/core/vmareas.c:3674
#3 0x00007ffff7a594e2 in account_for_memory (p=0x7fff7739a000, size=94208, prot=3, add_vm=true, image=true, comment=0x7ffff7c31df7 "map_file")
at /home/bruening/dr/git/src/core/heap.c:2539
#4 0x00007ffff7a5d197 in d_r_map_file (f=3, size=0x7fffffffc760, offs=0, addr=0x7fff7739a000 "\177ELF\002\001\001", prot=3,
map_flags=(MAP_FILE_COPY_ON_WRITE | MAP_FILE_IMAGE | MAP_FILE_FIXED)) at /home/bruening/dr/git/src/core/heap.c:3251
#5 0x00007ffff7bed7ec in elf_loader_map_phdrs (elf=0x7fffffffc840, fixed=false, map_func=0x7ffff7a5cf85 <d_r_map_file>,
unmap_func=0x7ffff7a5d1a2 <d_r_unmap_file>, prot_func=0x7ffff7ba7376 <set_protection>, check_bounds_func=0x7ffff7bd3a58 <privload_check_new_map_bounds>,
flags=(MODLOAD_NOT_PRIVLIB | MODLOAD_SKIP_WRITABLE)) at /home/bruening/dr/git/src/core/drlibc/drlibc_module_elf.c:465
#6 0x00007ffff7bd3d07 in privload_map_and_relocate (filename=0x453ed0c0 "/home/bruening/dr/git/build_x64_dbg_tests/clients/lib64/debug/libdrmemtrace.so",
size=0x7fffffffcc18, flags=(MODLOAD_NOT_PRIVLIB | MODLOAD_SKIP_WRITABLE)) at /home/bruening/dr/git/src/core/unix/loader.c:526
#7 0x00007ffff7ad136c in dr_map_executable_file (filename=0x453ed0c0 "/home/bruening/dr/git/build_x64_dbg_tests/clients/lib64/debug/libdrmemtrace.so",
flags=DR_MAPEXE_SKIP_WRITABLE, size=0x7fffffffcc18) at /home/bruening/dr/git/src/core/lib/instrument.c:4175
#8 0x0000555555618099 in module_mapper_t::read_and_map_modules (this=0x55555577bf30) at /home/bruening/dr/git/src/clients/drcachesim/tracer/raw2trace.cpp:348
#9 0x00005555556055fa in module_mapper_t::get_loaded_modules (this=0x55555577bf30) at /home/bruening/dr/git/src/clients/drcachesim/tracer/raw2trace.h:357
#10 0x0000555555617cd8 in raw2trace_t::read_and_map_modules[abi:cxx11]() (this=0x7fffffffd050)
at /home/bruening/dr/git/src/clients/drcachesim/tracer/raw2trace.cpp:308
#11 0x0000555555619a17 in raw2trace_t::do_conversion[abi:cxx11]() (this=0x7fffffffd050) at /home/bruening/dr/git/src/clients/drcachesim/tracer/raw2trace.cpp:603
#12 0x00005555555ad0f6 in analyzer_multi_t::analyzer_multi_t (this=0x5555557767f0) at /home/bruening/dr/git/src/clients/drcachesim/analyzer_multi.cpp:111
#13 0x000055555559a1f6 in main (argc=15, targv=0x7fffffffdc08) at /home/bruening/dr/git/src/clients/drcachesim/launcher.cpp:284
(gdb) p standalone_library
$1 = true
We should have privload_map_and_relocate use os_map_file for standalone_library.