MEMCPY.ASM bug

Chazcon

Prince
Joined
Feb 16, 2006
Messages
476
Location
Left Coast
I get a crash and this error when interacting with Zulu Impi units - specifically when I attack them in a city - any thoughts?

> msvcr71.dll!memmove(unsigned char * dst=0x323ed358, unsigned char * src=0x323ed35c, unsigned long count=4294967292) Line 171 Asm

Chunk of ASM code, error line in bold:

CopyUp:
test edi,11b ;U - destination dword aligned?
jnz short CopyLeadUp ;V - if we are not dword aligned already, align

shr ecx,2 ;U - shift down to dword count
and edx,11b ;V - trailing byte count

cmp ecx,8 ;U - test if small enough for unwind copy
jb short CopyUnwindUp ;V - if so, then jump

rep movsd ;N - move all of our dwords

jmp dword ptr TrailUpVec[edx*4] ;N - process trailing bytes
 
I have no idea where you would get an assembler dump, with comments. "memmove" is a very low level operating system routine. Are you getting this crash with a pure vanilla game? If not what mods are you using? Do you see the crash every time you attack an Impi in a city, and no other time?
 
Yes, this is a modded game and is not repeatable in vanilla. I realize I have a coding error somewhere.

It does only happen when attacking Impi in a city so far, still testing through all units &etc.

I have added "Defensive Fire" which allows flagged missile units to fire a volley at incoming attackers before they close in melee combat. I suspect this is throwing the error, although it has only just occurred after hundreds of play test games and then only with these Impi units.

When Civ crashes it allows debug via VS 2003 and provides the assembler dump. Windows 7 OS.

Odd that it does not point to a C++ source or header file , but gives me this:

First-chance exception at 0x2110fee4 in Civ4Warlords.exe: 0xC0000005: Access violation reading location 0x0000010a.
Unhandled exception at 0x2110fee4 in Civ4Warlords.exe: 0xC0000005: Access violation reading location 0x0000010a.
 
Upon further testing:

1) My saved game crashes 100/100 when I attack a city containing the (2) Skirmishers.

2) I notice that one of the enemy Skirmishers has the blue glow of being ready for a promotion.

3) If I use World Builder, delete the (2) Skirmishers, and then put (2) new Skirmishers there, the game does not crash when I attack the city.

4) If I use World Builder, delete (1) Skirmisher, (the one without the blue promotion glow) and then put (1) new Skirmishers there, the game does not crash when I attack the city.

4) This crash has happened twice before when attacking a city with Skirmishers in it (different games).

So there is something odd about the Skirmisher unit, when it is replaced all is well. Really weird. The blue promotion glow is not a factor.
 
5) You have two 4s. :p

6) What happens if you delete the Skirmisher with the blue promotion highlight?

7) What happens if you promote the Skirmisher instead of deleting either?

8) Does this happen with Impis as you originally wrote, Skirmishers, or both?

9) Can you post the code that you added, at least the part that is responsible for the pre-first strike? Can you give a brief technical description of how you implemented this defensive strike?

10) You don't see any source code because we were not given the source code to the EXE.
 
My apologies for the inconsistencies.

I can't delete only the Skirmisher with the blue highlight. However I don't think this is causing the crash because deleting the other Skirmisher allows me to attack the city without a crash.

I can't promote the unit as it is an AI unit. Can we promote AI units in World Builder?

The unit that caused the crash is a Skirmisher, not an Impi. My bad.

My source code (for the whole mod) is located here. Code tag is // Chazcon - Defensive Fire

I was referring to the C++ source and header files for CvGameCoreDLL.dll, not the EXE
 
count parameter looks uninitialised to me (it's huge). And the buffers overlap which is
normally a bad sign (however that's ok for memmove, memcpy can't cope with that).

Using a deleted object could be the cause.
 
Thanks PS I'll look into it tonight.
 
Back
Top Bottom