View Issue Details

IDProjectCategoryView StatusLast Update
0002836FSSCPpublic2013-04-04 06:05
ReporterEchelon9 Assigned ToEchelon9  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.19 
Target Version3.7.0 
Summary0002836: AddressSanitizer: global-buffer-overflow in ai_fire_from_turret() aiturret.cpp:2528
DescriptionReported by AddressSanitizer, a memory error detector for C/C++, in FS2Open builds based on trunk r9620 + BP.patch in WiH1.

ERROR: AddressSanitizer: global-buffer-overflow on address 0x000105028f78 at pc 0x100462e8d bp 0x7fff5fbf84b0 sp 0x7fff5fbf84a8
READ of size 4 at 0x000105028f78 thread T0
    #0 0x100462e8c in ai_fire_from_turret aiturret.cpp:2528
    0000001 0x1005c8dab in process_subobjects aicode.cpp:10923
    0000002 0x10060a71e in ai_frame aicode.cpp:13792
    0000003 0x10060ccd8 in ai_process aicode.cpp:13875
    0000004 0x1020dbb5a in ship_process_post ship.cpp:8418
    0000005 0x101a74f85 in obj_move_all_post object.cpp:1232
    0000006 0x101a79282 in obj_move_all object.cpp:1454
    0000007 0x1002ef18d in game_simulation_frame freespace.cpp:4113
    0000008 0x1002f3de1 in game_frame freespace.cpp:4506
    0000009 0x1002f95cb in game_do_frame freespace.cpp:4917
    0000010 0x10030512a in game_do_state freespace.cpp:6592
    #11 0x100904a59 in gameseq_process_events gamesequence.cpp:405
    0000012 0x10030b9a8 in game_main freespace.cpp:7159
    0000013 0x10030d016 in SDL_main freespace.cpp:7293
    ...

if(!something_was_ok_to_fire)
        {
            mprintf(("nothing ok to fire\n"));
            //Impose a penalty on turret accuracy for losing site of its goal, or just not being able to fire.
            turret_update_enemy_in_range(ss, -4*Weapon_info[ss->turret_best_weapon].fire_wait); <====
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 WiH1, progress to flight in 'The Cost of War' mission 2.
Additional InformationERROR: AddressSanitizer: global-buffer-overflow on address 0x000105028f78 at pc 0x100462e8d bp 0x7fff5fbf84b0 sp 0x7fff5fbf84a8
READ of size 4 at 0x000105028f78 thread T0
    #0 0x100462e8c in ai_fire_from_turret aiturret.cpp:2528
    0000001 0x1005c8dab in process_subobjects aicode.cpp:10923
    0000002 0x10060a71e in ai_frame aicode.cpp:13792
    0000003 0x10060ccd8 in ai_process aicode.cpp:13875
    0000004 0x1020dbb5a in ship_process_post ship.cpp:8418
    0000005 0x101a74f85 in obj_move_all_post object.cpp:1232
    0000006 0x101a79282 in obj_move_all object.cpp:1454
    0000007 0x1002ef18d in game_simulation_frame freespace.cpp:4113
    0000008 0x1002f3de1 in game_frame freespace.cpp:4506
    0000009 0x1002f95cb in game_do_frame freespace.cpp:4917
    0000010 0x10030512a in game_do_state freespace.cpp:6592
    #11 0x100904a59 in gameseq_process_events gamesequence.cpp:405
    0000012 0x10030b9a8 in game_main freespace.cpp:7159
    0000013 0x10030d016 in SDL_main freespace.cpp:7293
    0000014 0x100002dfa in -[SDLMain applicationDidFinishLaunching:] SDLMain.m:300
    0000015 0x7fff9502aed9 in _CFXNotificationPost (in CoreFoundation) + 2553
    0000016 0x7fff8b00de25 in -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation) + 63
    0000017 0x7fff9096f55c in -[NSApplication _postDidFinishNotification] (in AppKit) + 291
    0000018 0x7fff9096f295 in -[NSApplication _sendFinishLaunchingNotification] (in AppKit) + 215
    0000019 0x7fff9096c481 in -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] (in AppKit) + 565
    0000020 0x7fff9096c07b in -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] (in AppKit) + 350
    0000021 0x7fff8b02770a in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] (in Foundation) + 307
    0000022 0x7fff8b02756c in _NSAppleEventManagerGenericHandler (in Foundation) + 105
    0000023 0x7fff933f0077 in aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) (in AE) + 306
    0000024 0x7fff933efed8 in dispatchEventAndSendReply(AEDesc const*, AEDesc*) (in AE) + 36
    0000025 0x7fff933efd98 in aeProcessAppleEvent (in AE) + 317
    0000026 0x7fff8db58708 in AEProcessAppleEvent (in HIToolbox) + 99
    0000027 0x7fff90968865 in _DPSNextEvent (in AppKit) + 1455
    0000028 0x7fff90967e21 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit) + 127
    0000029 0x7fff9095f1d2 in -[NSApplication run] (in AppKit) + 516
    0000030 0x100004f13 in CustomApplicationMain SDLMain.m:227
    0000031 0x100004990 in main SDLMain.m:377
    0000032 0x100001b63 in start (in FS2_Open (debug)) + 51
    0000033 0x0 in 0x0
0x000105028f78 is located 258776 bytes to the right of global variable 'Weapons' from 'fs2open/trunk/fs2_open/projects/Xcode4/../../code/weapon/weapons.cpp' (0x104ea1aa0) of size 1344000
Shadow bytes around the buggy address:
  0x100020a05190: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x100020a051a0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x100020a051b0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x100020a051c0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x100020a051d0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
=>0x100020a051e0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9[f9]
  0x100020a051f0:f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x100020a05200: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x100020a05210: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x100020a05220: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x100020a05230: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
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
==3469==ABORTING
TagsNo tags attached.

Activities

Echelon9

2013-04-04 06:05

developer   ~0014884

Fix committed to trunk@9621.

Related Changesets

fs2open: trunk r9621

2013-04-04 02:53

Echelon9


Ported: N/A

Details Diff
Fix Mantis 2836: AddressSanitizer: global-buffer-overflow in ai_fire_from_turret() aiturret.cpp:2528 Affected Issues
0002836
mod - /trunk/fs2_open/code/ai/aiturret.cpp Diff File

Issue History

Date Modified Username Field Change
2013-04-04 05:42 Echelon9 New Issue
2013-04-04 05:42 Echelon9 Status new => assigned
2013-04-04 05:42 Echelon9 Assigned To => Echelon9
2013-04-04 06:05 Echelon9 Changeset attached => fs2open trunk r9621
2013-04-04 06:05 Echelon9 Note Added: 0014884
2013-04-04 06:05 Echelon9 Status assigned => resolved
2013-04-04 06:05 Echelon9 Resolution open => fixed