jackpoz / BotFarm

Application used to spawn WoW automated players compatible with 3.3.5a version only.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AccessViolationException

xTurinx opened this issue · comments

commented

If the BotsFactory is going to initialize it will throw a AccessViolationException. I've built the CLI branch of your TC Fork in Debug and in Release for 64 bit architecture. Both do not work.

I use VS2013 Ultimate.

Any idea? Do you need more information?

did you build botfarm for x64 bit too ? can you start it from VS and post a stacktrace of the crash ?

commented

Yes I did build the botfarm for x64 bit.

Stacktrace:

System.AccessViolationException wurde nicht behandelt.
HResult=-2147467261
Message=Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.
Source=BotFarm
StackTrace:
bei BotFarm.BotFactory..ctor()
bei BotFarm.Program.Main(String[] args)
bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException:

commented

crashing while processing BotsFactory constructor on executing
DetourCLI.Detour.Initialize(Settings.Default.MMAPsFolderPath);

which Visual Studio version are you using ? You can find Visual Studio 2013 libraries at https://github.com/jackpoz/BotFarm/tree/boost-profiling/BotFarm/lib , try with those

commented

I'm running

Microsoft Visual Studio Ultimate 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

I'll try it using your build

commented

Still the same exception. The problem seems to be on the setup of my pc isn't it?

Did you configure the BotFarm.exe.config file with the correct directories ?

http://1drv.ms/1Oy17PA contains the binaries I use, they are built for x64 platform. Give them a try.

Your OS is 64 bit, right ?

commented

Yes my OS is 64 bit. I configured the configuration file with the correct directories (using the absolute path). To be sure I've inserted an assertion like "System.Diagnostics.Debug.Assert(System.IO.Directory.Exists(...))". I'll try your binaries when I'm back home. I'm currently at work.

commented

I'm at home and I've tested your build but it still doesn't work.
Here my configuration file http://pastebin.com/jfE78Qe6

I've also added your cli.dll to my visual studio project and started it from the IDE and I got the same exception.

This is really strange :/

please add a "" at the end of your directory paths, like "C:\Users\mynotebook\335\mmaps" , and see if that changes anything.

The remaining thing to do is to build cli in debug, botfarm in debug and start botfarm from vs to execute it line by line and see which variable can cause the crash (not sure if by default VS allows to debug both managed and unmanaged code)

I just got a similar crash

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at VMapCLI.VMap.GetHeight(Single X, Single Y, Single Z, Int32 mapID) in d:\wow\trinitycore cli\src\cli\vmapcli.cpp:line 22
at MapCLI.Map.GetHeight(Single X, Single Y, Single Z, Int32 mapID) in d:\wow\trinitycore cli\src\cli\mapcli.cpp:line 32
at DetourCLI.Detour.FindPath(Single startX, Single startY, Single startZ, Single endX, Single endY, Single endZ, Int32 mapID, List`1& path) in d:\wow\trinity
core cli\src\cli\detourcli.cpp:line 106
at BotFarm.BotGame.MoveTo(Position destination) in D:\wow\BotFarm\BotFarm\BotGame.cs:line 213

building with VS2015, not sure if in my case it's caused by the new VS

commented

I'll download the new VS after work and try it for myself. Also I'll try to build and run the BotFarm project on my Win2008 home server.

"The remaining thing to do is to build cli in debug, botfarm in debug and start botfarm from vs to execute it line by line and see which variable can cause the crash (not sure if by default VS allows to debug both managed and unmanaged code)"

I built both in debug and started it from vs but if I execute the code line by line the debugger comes to using(var fac = new BotFactory()) and then if I hit F11 I'll instantly get an exception.

Normally the debugger should join the constructor of the botfactory class but it doesn't. If I make a simple class like

public class Test
{
public int a
{ get; set; }

public Test()
{
this.a = 1;
}
}

and set a breakpoint, I can debug this.

If I remove the three lines
DetourCLI.Detour.Initialize(Settings.Default.MMAPsFolderPath);
....
....
then the botfarm is working but on any movement the program will crash because the path calculation has failed.

I'm also able to debug the constructor of BotFactory class.

Possibly I have to change something in the vs configuration?
I'm working a lot with C# at work but mostly I'm using the Xamarin Studio IDE for Android and IOS development.

Feel free to stay on VS2013, that's what I used till last week and it always worked fine, never had any AccessViolationException. The strange thing happening now in my case is that sometimes it works fine, sometimes it crashes.

You need to enable Native debugging in the BotFarm project and remove "Just My Code" from Debug options of visual studio (Tools > Options).

The only things that changed lately are Windows Updates patches...

commented

Okay. I'll try debugging when I'm back at home.

It looks like AccessViolationException thrown by C++/CLI is usually just a NullReferenceException, I'll add some null checks, for example at https://github.com/jackpoz/TrinityCore/blob/CLI/src/cli/DetourCLI.cpp#L14 in case mmapsPath is null.
https://msdn.microsoft.com/en-us/library/system.accessviolationexception.aspx remarks section for reference.

commented

Oh very nice. Thank you. Let me know if I can help you.

please try with jackpoz/TrinityCore@56c431c and check if the exception changes

commented

The exception hasn't changed :(

Here the disambled code which caused the crash

using (BotFactory factory = new BotFactory())
000007FE8B5B3FF7 lea rcx,[7FE8B605B90h]
000007FE8B5B3FFE call 000007FEEAC027D0
000007FE8B5B4003 mov qword ptr [rbp+28h],rax
000007FE8B5B4007 mov rax,qword ptr [rbp+28h]
000007FE8B5B400B mov qword ptr [rbp+30h],rax
000007FE8B5B400F mov rcx,qword ptr [rbp+30h]

000007FE8B5B4013 call 000007FE8B49C9A8 <<<<<<<<< Here the program freezes and throws after 5 seconds the exception

000007FE8B5B4018 mov r11,qword ptr [rbp+30h]
000007FE8B5B401C mov qword ptr [rbp+98h],r11

I uninstalled VS2015 and re-installed VS2013 Update 4, BotFarm works fine now, http://1drv.ms/1LK9Hut link to the binaries. I removed some VS2015 related changes to the CLI TC branch, with VS2013 they are not required.
Not sure if all the issues I had are related to Boost not supporting VS2015 yet or VS2015 itself.

commented

Okay I'll try to reinstall VS and I'll rebuild the maps, vmaps and mmaps too (to be sure).

commented

But in general. Thank you for your implementation of SimpleWoW. It's very useful UnitTests :)

if you have empty maps/vmaps/mmaps folders they will not cause BotFarm to crash, if it crashes it's because of something else (still unknown)

commented

I was up the whole night and tried a lot of things. I've installed a Windows Server 2008 machine and all TrinityCore requirements (x64). After this I've built the CLI project and tried to start the BotFarm project but still no success :/

I read some topics on stackoverflow. At one topic a guy said, that the issue is related to the C++ compiler. Is this possible?

the binaries I posted plus https://www.microsoft.com/en-us/download/details.aspx?id=40784 plus .NET 4.5.1 should be enough to start botfarm

Hello there does this work with recent trinity core 3.3.5a ?
I downloaded the .zip and edited the config, but cannot seem to get any kind of connection to the server. I run the .exe in a command window and it just gives me another prompt with nothing happening. Im really interested to see this work!
Thanks! :)

Do you have a video on youtube of how it would look by any chance?

@wrathix don't hijack random GitHub issues with unrelated topics, create your own issue

@xTurinx any further feedback ?

having the same issues as @xTurinx
the precompiled binaries provided by you seem to have the same issue as when I'm compiling CLI and the Botfarm myself (AccessViolationException)
When starting the precompiled binaries only the command line window appears, though no further messages come (window stays empty) (CPU Usage 100%) this stays until terminated by me.

When running straight from VS2013 no matter which cli.dll I choose (whether my own compiled ones either debug or release) or the dll provided in your package, I always get the SystemAccessViolation.
No matter running as Debug or Release.

The problem is definetly caused by cli.dll
When I setup a tiny test project which literally just calls DetourCLI.Detour.Initialize(""); I also get:

A first chance exception of type 'System.AccessViolationException' occurred in Microsoft.VisualStudio.HostingProcess.Utilities.dll
An unhandled exception of type 'System.AccessViolationException' occurred in Microsoft.VisualStudio.HostingProcess.Utilities.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Running everything on x64
VS2013 (12.0.31101.00 Update 4)
.Net Framework 4.5.50938

Haven't figured out yet how the .pdb Symbols stuff works, but if I ever get that to work I might be able to tell what's causing this.

"You need to enable Native debugging in the BotFarm project and remove "Just My Code" from Debug options of visual studio (Tools > Options)." Doesn't seem to be the only option that needs to be changed.

@greeld which binaries are you using ? https://ci.appveyor.com/project/jackpoz/botfarm/build/artifacts has always the most update version

@jackpoz yes, I've been trying exactly those and after starting it only a empty command line prompt appears which just stays empty until terminated. I can't explain it to myself, tbh. The only reasons could be either my installation of the C++ Redistributable Packages or my .Net installation. Or could the configs play a role? Does the bot give out any message when starting?

@greeld : compare with my comments in issue #13 and see if you find anything useful in there.

@tkrokli No log files get ever created, meaning the problem appears earlier on. When I compile the Project as release myself and start it as a stand alone (without VS) I get the very same result of just a empty command line prompt that does nothing, which is weird since even in the release version the program will technically also try to access a Memory Part it doesn't own so it would get an exception which is unhandeld ergo it should crash but it doesn't. Never the less, this is not important since I'm fairly sure that the reason for this behavior in the release version is aswell the System Access Violation. I will try running it on another pc tomorrow to be certain that it actually just is this very pc I'm currently writing from (Win7 x64) and not a general problem.

OK, thanks for the feedback. Hope you will find some answers. Good luck, have fun! 👍

@greeld did you try building cli.dll too from https://github.com/jackpoz/BotFarm/blob/master/BotFarm/lib/README.md ? Try also with VS2015.

You might want to try building in Debug too.

@jackpoz : Please forgive me for intruding with a slightly different question in this thread: is your BotFarm source supposed to be equally possible to compile for 32bit (x86) as for 64bit (x64)? When I try to do it, it looks as if VS2013 warns me that the source is not written to support that architecture. Have you written anything about this elsewhere? :)

x86 BotFarm requires Win32 cli.dll, x64 BotFarm requires x64 cli.dll

Thanks for confirming. I guess I will have to try it again. I thought I had already compiled the CLI branch in Win32 and used the proper Win32 cli.dll, but still got the warnings about MSIS instead of x86 as the architecture name. Can't be 100% sure, so I better try it again and see if I am more successful this time.

@jackpoz when it works with VS2015 I don't really gain anything from it and I highly doubt that it would anyway since the standalone you provide doesn't even work... and yeah tried compiling it myself.
I don't have a lot of time currently so excuse me for the long waiting periods ;P I'm currently started creating 'my own' cli.dll which is basically a copy of the original but with less code, I just copy part after part from the original one over to my project and currently everything still works. As soon I hit the point when it doesn't work anymore I know which lines causes the problem... would be faster if VS could debug the dll right away but it's always not finding the src even though I don't move it :(

I don't even any problem debugging cli.dll from VS when running BotFarm, the whole point of the Unit Test https://github.com/jackpoz/BotFarm/blob/master/BotFarm%20UnitTests/Maps.cs#L13 is to be able to easily debug cli.dll and that test passes fine on my pc. Please check if that throws an exception to you.

That System.AccessViolationException doesn't give much info to work on and I don't use VS2013 anymore so I have no idea if that's a bug in C++/CLI of VS2013. I'll provide you VS2015 binaries so you can give them a try.

A tiny test project with just DetourCLI.Detour.Initialize(""); in its main already throws me the Exception

Tried on a Win2008 VM using the binaries and I got
image

Tried the same binaries on my Win10 machine and got
image

Your case of "AccessException" looks even different than the 2 above, right ?

Yes, I don't even get an error. It just doesn't do anything and cosumes unhealty amounts of CPU%

Ok with my custom made cli.dll it works now x) but I have no idea why. I used the very same source code. The only differences are I changed the namespace (so I don't get any duplication errors or whatever, just a precaution) and instead of referencing the other libs I linked them directly.
Must be some kind of Visual Studio hiccups since your code is completly fine it was just the way of building it.

Can you link your branch with those changes ? I'll see if I can merge them.
Good to hear you can use BotFarm now.

Yes I'm also very relieved I got this out of my way, it was bugging me for a whole week.
I'm not the kind of CMAKE person who can recreate my configs of VS in cmake again, after all CMAKE might be the origin of the problem by creating 'wrong' build files. Never the less the only file I can see you gaining something from is the Project File of the cli.dll remake I made (I called it stash.dll, dunno why) https://github.com/greeld/CLI-Stash-TrinityCore-/blob/master/stash/stash.vcxproj
But as I said, all libraries are directly linked by me and I didn't use the VS referencing feature (didn't work for me, always got a linker error). The source code is identical except for the namespace changes (which I also might reverse again to the original)

your project files have a lot of different values, it will take a while to figure out the required one(s) and implement them in cmake. Any further help is most welcome :)

@greeld how come there are no boost libraries listed in your project file https://github.com/greeld/CLI-Stash-TrinityCore-/blob/master/stash/stash.vcxproj ?
As soon as I link libboost_thread-vc140-mt-1_59.lib on a test I did it stops working.
I'm working to remove libboost_thread dependency to avoid the crashes.

@jackpoz
<AdditionalIncludeDirectories>C:\local\boost_1_59_0;
<AdditionalLibraryDirectories>C:\local\boost_1_59_0\lib64-msvc-12.0;
As I mentioned before, I linked them directly because the whole VS refernce feature didn't work for me.
If you want me to do any tests, I'll be glad to help you 😋

I'm waiting for TrinityCore/TrinityCore#15782 or any similar change to be merged, if it takes too long I'll apply those changes only in the CLI branch

@greeld I made some changes to the cli wrapper, removing TLS references. While at it I updated binaries from VS2013 to VS2015 so please make sure to install https://www.microsoft.com/en-US/download/details.aspx?id=48145 before testing https://ci.appveyor.com/project/jackpoz/botfarm/build/artifacts .
Those binaries work in a VM that was throwing errors before, please let me know if they work for you too.

@jackpoz Oh wow those binaries do work! Awesome 😄 I will try to build the unmodified src now and hope this will work aswell 👍