2020-07-06 17:58 EDT

View Revisions: Issue #2875

Summary 0002875: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free)
Revision 2013-05-16 05:23 by niffiwan
Description Reported by AddressSanitizer, a memory error detector for C/C++, in FS2Open builds based on trunk r9677 compiled w/ gcc 4.8.0

=================================================================
==16772== ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x602c00073300
    #0 0x7f9581cc848a in free ??:0
    0000001 0xde0d9e in _vm_free(void*, char*, int) ??:0
    0000002 0x621ac0 in hud_close() /home/me/src/git-fs2_open/code/hud/hud.cpp:1307
    0000003 0x41f755 in game_shutdown() /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:7263
    0000004 0x41f090 in game_main(char*) /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:7040
    0000005 0x41f535 in main /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:7168
    0000006 0x7f957f76076c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
0x602c00073300 is located 0 bytes inside of 384-byte region [0x602c00073300,0x602c00073480)
allocated by thread T0 here:
    #0 0x7f9581cc495a in operator new(unsigned long) ??:0
    0000001 0x696363 in load_gauge_messages(int, int, int, SCP_vector<int>*, color*) /home/me/src/git-fs2_open/code/hud/hudparse.cpp:6300
    0000002 0x662bde in load_gauge(int, int, int, int, SCP_vector<int>*, color*) /home/me/src/git-fs2_open/code/hud/hudparse.cpp:871
    0000003 0x660905 in load_missing_retail_gauges() /home/me/src/git-fs2_open/code/hud/hudparse.cpp:490
    0000004 0x660712 in hud_positions_init() /home/me/src/git-fs2_open/code/hud/hudparse.cpp:467
    0000005 0x40f5d1 in game_init() /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:1968
    0000006 0x41ef77 in game_main(char*) /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:6977
    0000007 0x41f535 in main /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:7168
    0000008 0x7f957f76076c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
==16772== HINT: if you don't care about these warnings you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
==16772== ABORTING


SCP_vector<HudGauge*> default_hud_gauges;
...
...
...
    HudGaugeMessages* hud_gauge = new HudGaugeMessages();
...
...
...
    } else {
        default_hud_gauges.push_back(hud_gauge);
    }

and

    for(j = 0; j < num_gauges; j++) {
        vm_free(default_hud_gauges[j]);
        default_hud_gauges[j] = NULL;
    }
Revision 2013-05-16 05:22 by niffiwan
Description Reported by AddressSanitizer, a memory error detector for C/C++, in FS2Open builds based on trunk r9677 compiled w/ gcc 4.8.0

=================================================================
==16772== ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x602c00073300
    #0 0x7f9581cc848a in free ??:0
    0000001 0xde0d9e in _vm_free(void*, char*, int) ??:0
    0000002 0x621ac0 in hud_close() /home/me/src/git-fs2_open/code/hud/hud.cpp:1307
    0000003 0x41f755 in game_shutdown() /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:7263
    0000004 0x41f090 in game_main(char*) /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:7040
    0000005 0x41f535 in main /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:7168
    0000006 0x7f957f76076c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
0x602c00073300 is located 0 bytes inside of 384-byte region [0x602c00073300,0x602c00073480)
allocated by thread T0 here:
    #0 0x7f9581cc495a in operator new(unsigned long) ??:0
    0000001 0x696363 in load_gauge_messages(int, int, int, SCP_vector<int>*, color*) /home/me/src/git-fs2_open/code/hud/hudparse.cpp:6300
    0000002 0x662bde in load_gauge(int, int, int, int, SCP_vector<int>*, color*) /home/me/src/git-fs2_open/code/hud/hudparse.cpp:871
    0000003 0x660905 in load_missing_retail_gauges() /home/me/src/git-fs2_open/code/hud/hudparse.cpp:490
    0000004 0x660712 in hud_positions_init() /home/me/src/git-fs2_open/code/hud/hudparse.cpp:467
    0000005 0x40f5d1 in game_init() /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:1968
    0000006 0x41ef77 in game_main(char*) /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:6977
    0000007 0x41f535 in main /home/me/src/git-fs2_open/code/freespace2/freespace.cpp:7168
    0000008 0x7f957f76076c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
==16772== HINT: if you don't care about these warnings you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
==16772== ABORTING


    HudGaugeMessages* hud_gauge = new HudGaugeMessages();
...
...
...
    } else {
        default_hud_gauges.push_back(hud_gauge);
    }

and

    for(j = 0; j < num_gauges; j++) {
        vm_free(default_hud_gauges[j]);
        default_hud_gauges[j] = NULL;
    }