Python terminating early with exit value of -1073741819

3020
8
Jump to solution
12-15-2015 04:47 AM
LarryMcEvoy
New Contributor III

Hi, I have a fairly simple script which searches  a network location looking for mxd's it then checks the data sources and writes a csv of any data sources owned by the DBO schema. It works fine in most instances and has trawled through several large directories without issue but one mxd in particular is causing it to terminate with an exit value: -1073741819. I can't seem to catch any error in a try except block as it seems to close python without any kind of control the file causing the problem opens fine in arcmap and only has 1 broken data source in it.

source code is attached any suggestions would be welcome

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

What version of ArcGIS are you running?  The machine I am working on this morning has a beta build of the upcoming release, and it processed the attached MXD using the attached Python code without any issues.  I ended up with the following being printed out to console along with an entry in a csv file:

not sde
completed

If I get a chance later today, I will get on a machine with ArcGIS 10.3.1 and try it there as well.

Have you tried walking through the code with an IDE to see exactly which call is causing Python to crash?

View solution in original post

8 Replies
MichaelVolz
Esteemed Contributor

Have you tried to open the mxd to see if it might be corrupt?

Maybe try Mxd Doctor as well

I have placed exceptions into my python code to bypass files I know are corrupt, but I'm not sure whether or not the end users still need the file so my python code does not get interrupted.

0 Kudos
LarryMcEvoy
New Contributor III

Have opened mxd in arcmap and all works as expected script has encountered other corrupt files but the error is being caught in the try except blocks but for some reason the minute it hits this file it terminates in an extremely ungraceful way, I can hardcode it to ignore thi file but would prefer to  find a more reliable solution in case there is more than 1 file causing an issue

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

If you run the code only on the problem MXD does it crash, or does it crash only when it finds it after processing other MXDs?  If the former, can you attach the MXD by chance?

0 Kudos
LarryMcEvoy
New Contributor III

The crash does occur when just ran on the mxd (attached)

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

What version of ArcGIS are you running?  The machine I am working on this morning has a beta build of the upcoming release, and it processed the attached MXD using the attached Python code without any issues.  I ended up with the following being printed out to console along with an entry in a csv file:

not sde
completed

If I get a chance later today, I will get on a machine with ArcGIS 10.3.1 and try it there as well.

Have you tried walking through the code with an IDE to see exactly which call is causing Python to crash?

LarryMcEvoy
New Contributor III

I'm back at version 10.2.2 running on a 64bit machine so suspect that there some corruption in the mxd where its trying to access protected memory. The result you got was exactly what I would have expected. I have stepped through the code alright and the crash happens in _base.py in the class _BaseArcObject(object): as such rather than waste any more of your or my time I will bypass that file and close this on the basis that it will work on 10.3 if I hit many more files like this I will just rewrite the code to keep account of files that have caused a crash thanks for your help

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Coincidentally, another script I was working on came across the attached MXD that I downloaded and it crashed.  When I ran the code earlier, it was in the interactive Python window.  When I ran the code again through a stand-alone interactive Python session, it crashed.  Also, I tried to run MXD Doctor on it, and it crashed MXD Doctor.  I tried running ArcGIS Document Defragmenter, and it opens it but just hangs.

I have run into this before, i.e., where an MXD will open in ArcMap but basically crashes when trying to open it any other way.  The file is definitely corrupt, although it is frustrating because finding out why or fixing it appears to be impossible.

It is frustrating, for sure, when code finds these kinds of MXDs because error trapping doesn't work so everything bombs.  I guess flagging it and avoiding it are the best you can hope for at this point.

LarryMcEvoy
New Contributor III

I usually use Apatana studio when writing python purely for the ease of debugging, it never even occurred to me to run the code in the interactive python window I just did and it worked, Thanks again as the next file I hit seems to have the a similar issue and running in inside ArcMap will save me having to rewrite the code to keep track of failures. 

0 Kudos