View Issue Details

IDProjectCategoryView StatusLast Update
0002822FSSCPpublic2013-03-26 09:58
ReporterEchelon9 Assigned ToEchelon9  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.19 
Target Version3.7.0 
Summary0002822: ERROR: AddressSanitizer: global-buffer-overflow in hud_target_change_check() hudtarget.cpp:4459
DescriptionReported by AddressSanitizer, a memory error detector for C/C++, in FS2Open builds based on trunk r9596.

ERROR: AddressSanitizer: global-buffer-overflow on address 0x0001038e6f0c at pc 0x100ad3d93 bp 0x7fff5fbfc0b0 sp 0x7fff5fbfc0a8
READ of size 4 at 0x0001038e6f0c thread T0
    #0 0x100ad3d92 in hud_target_change_check hudtarget.cpp:4459
    0000001 0x100db0472 in hud_update_frame hud.cpp:1468
    0000002 0x1002ea4a1 in game_simulation_frame freespace.cpp:4025
    0000003 0x1002eed11 in game_frame freespace.cpp:4380
    0000004 0x1002f44fb in game_do_frame freespace.cpp:4791
    0000005 0x10030005a in game_do_state freespace.cpp:6466
    0000006 0x1008f19b9 in gameseq_process_events gamesequence.cpp:405
    0000007 0x1003068d8 in game_main freespace.cpp:7033
    0000008 0x100307f46 in SDL_main freespace.cpp:7167
    ...


void hud_target_change_check()
{
  ...
  current_speed = Objects[Player_ai->target_objnum].phys_info.speed; <=====
  ...
}
Steps To Reproduce1. Utilise a version of Clang that supports AddressSantizer (https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer [^] [^]).
2. Build with -fsanitize=address C/C++ flag
3. Run the game with mediavps 3.6.12, progress to flight in mission 1 "Surrender, Belisarious" or a SOC mission
Additional InformationERROR: AddressSanitizer: global-buffer-overflow on address 0x0001038e6f0c at pc 0x100ad3d93 bp 0x7fff5fbfc0b0 sp 0x7fff5fbfc0a8
READ of size 4 at 0x0001038e6f0c thread T0
    #0 0x100ad3d92 in hud_target_change_check hudtarget.cpp:4459
    0000001 0x100db0472 in hud_update_frame hud.cpp:1468
    0000002 0x1002ea4a1 in game_simulation_frame freespace.cpp:4025
    0000003 0x1002eed11 in game_frame freespace.cpp:4380
    0000004 0x1002f44fb in game_do_frame freespace.cpp:4791
    0000005 0x10030005a in game_do_state freespace.cpp:6466
    0000006 0x1008f19b9 in gameseq_process_events gamesequence.cpp:405
    0000007 0x1003068d8 in game_main freespace.cpp:7033
    0000008 0x100307f46 in SDL_main freespace.cpp:7167
    0000009 0x10000338a in -[SDLMain applicationDidFinishLaunching:] SDLMain.m:300
    0000010 0x7fff8ffe3ed9 in _CFXNotificationPost (in CoreFoundation) + 2553
    #11 0x7fff85fc6e25 in -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation) + 63
    0000012 0x7fff8b92855c in -[NSApplication _postDidFinishNotification] (in AppKit) + 291
    0000013 0x7fff8b928295 in -[NSApplication _sendFinishLaunchingNotification] (in AppKit) + 215
    0000014 0x7fff8b925481 in -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] (in AppKit) + 565
    0000015 0x7fff8b92507b in -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] (in AppKit) + 350
    0000016 0x7fff85fe070a in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] (in Foundation) + 307
    0000017 0x7fff85fe056c in _NSAppleEventManagerGenericHandler (in Foundation) + 105
    0000018 0x7fff8e3a9077 in aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) (in AE) + 306
    0000019 0x7fff8e3a8ed8 in dispatchEventAndSendReply(AEDesc const*, AEDesc*) (in AE) + 36
    0000020 0x7fff8e3a8d98 in aeProcessAppleEvent (in AE) + 317
    0000021 0x7fff88b11708 in AEProcessAppleEvent (in HIToolbox) + 99
    0000022 0x7fff8b921865 in _DPSNextEvent (in AppKit) + 1455
    0000023 0x7fff8b920e21 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit) + 127
    0000024 0x7fff8b9181d2 in -[NSApplication run] (in AppKit) + 516
    0000025 0x1000054a3 in CustomApplicationMain SDLMain.m:227
    0000026 0x100004f20 in main SDLMain.m:377
    0000027 0x1000020f3 in start (in FS2_Open (debug)) + 51
    0000028 0x0 in 0x0
0x0001038e6f0c is located 52 bytes to the left of global variable 'Player_obj' from 'fs2open/trunk/fs2_open/projects/Xcode4/../../code/object/object.cpp' (0x1038e6f40) of size 8
0x0001038e6f0c is located 76 bytes to the right of global variable 'obj_create_list' from 'fs2open/trunk/fs2_open/projects/Xcode4/../../code/object/object.cpp' (0x1038e6ca0) of size 544
Shadow bytes around the buggy address:
  0x10002071cd90: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002071cda0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002071cdb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002071cdc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002071cdd0: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 f9
=>0x10002071cde0: f9[f9]f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x10002071cdf0: 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x10002071ce00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002071ce10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002071ce20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002071ce30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable: 00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone: fa
  Heap righ redzone: fb
  Freed Heap region: fd
  Stack left redzone: f1
  Stack mid redzone: f2
  Stack right redzone: f3
  Stack partial redzone: f4
  Stack after return: f5
  Stack use after scope: f8
  Global redzone: f9
  Global init order: f6
  Poisoned by user: f7
  ASan internal: fe
==43848==ABORTING
TagsNo tags attached.

Activities

Echelon9

2013-03-24 03:25

developer   ~0014821

This is likely because Player_ai->target_objnum is either:

(1) Uninitialised value, having not yet been set at mission start, or
(2) -1, as this has been set as a default 'no target' value.

Both of which would cause an out of bounds read when using it as an offset into Objects[] array.

Echelon9

2013-03-26 09:58

developer   ~0014844

Fix committed to trunk@9604.

Related Changesets

fs2open: trunk r9604

2013-03-26 06:45

Echelon9


Ported: N/A

Details Diff
Fix Mantis 2822: AddressSanitizer: global-buffer-overflow in hud_target_change_check() hudtarget.cpp:4459 Affected Issues
0002822
mod - /trunk/fs2_open/code/hud/hudtarget.cpp Diff File

Issue History

Date Modified Username Field Change
2013-03-24 03:13 Echelon9 New Issue
2013-03-24 03:25 Echelon9 Note Added: 0014821
2013-03-24 03:26 Echelon9 Assigned To => Echelon9
2013-03-24 03:26 Echelon9 Status new => assigned
2013-03-26 09:25 Echelon9 Steps to Reproduce Updated
2013-03-26 09:58 Echelon9 Changeset attached => fs2open trunk r9604
2013-03-26 09:58 Echelon9 Note Added: 0014844
2013-03-26 09:58 Echelon9 Status assigned => resolved
2013-03-26 09:58 Echelon9 Resolution open => fixed