access violation error in filegdb.dll from my script!

537
5
09-23-2011 06:14 AM
EvanFedorko
New Contributor
so... I have a relatively simple script I wrote that does what it's supposed to do, but, after processing ~20 features, pythonwin dies and generates the following details:


Description:
  Stopped working

Problem signature:
  Problem Event Name: APPCRASH
  Application Name: pythonw.exe
  Application Version: 0.0.0.0
  Application Timestamp: 4ba3e4e2
  Fault Module Name: FileGDB.dll
  Fault Module Version: 10.0.0.2414
  Fault Module Timestamp: 4bf445c7
  Exception Code: c0000005
  Exception Offset: 0006a45f
  OS Version: 6.1.7601.2.1.0.272.7
  Locale ID: 1033

I have no idea why this is happening. Google searches and forum searches have produced nothing. This is almost certainly not a permissions issue as I am running the script as an administrator and all data is local. besides, it runs through part of the data. I've attached the script. any help would be GREATLY appreciated!

yrs-
Evan!
Tags (2)
0 Kudos
5 Replies
StacyRendall1
Occasional Contributor III
It's hard to tell what is actually happening, as pythonwin getting in the way...

Try saving your file to the location of python.exe (typically C:\Python26\ArcGIS10.0\), then use command prompt to navigate there and run it with:
python summits.py


This will (probably) still crash, but it ought to at least give you a line number to work from. Otherwise it will crash the whole command window, which leaves us where we are at the moment, but with a few possibilities eliminated...

Let me know how you get on!
0 Kudos
EvanFedorko
New Contributor
It's hard to tell what is actually happening, as pythonwin getting in the way...

Try saving your file to the location of python.exe (typically C:\Python26\ArcGIS10.0\), then use command prompt to navigate there and run it with:
python summits.py


This will (probably) still crash, but it ought to at least give you a line number to work from. Otherwise it will crash the whole command window, which leaves us where we are at the moment, but with a few possibilities eliminated...

Let me know how you get on!


same thing happened - same error window and everything.

yrs-
Evan!
0 Kudos
StacyRendall1
Occasional Contributor III
I took a look at your code, the two SearchCursors on the same feature class (finalElevRow and finalElevRow2) kind of worry me. I think you should either:

  1. delete the first one after using it to get the row count; i.e. insert del row, finalElevRow at line 99

  2. preferred option: reset the search cursor; i.e. never create finalElevRow2, insert finalElevRow.reset() at what was line 99, then use finalElevRow instead of finalElevRow2 from there on out (see below)

Here is your line 85 onward, using option 2 above:
            ## select from previously selected records the record(s) with the max elevation value
            whereClause = "RASTERVALU = "+(str(localMax)).strip()
            ## search cursor result for counting
            finalElevRow = arcpy.SearchCursor("selectedFeatures_lyr", whereClause)

            ## check the number of records we just selected and assign a null value if we selected more than 1 record 
            count = 0
            rowcount = 0
            for row in finalElevRow:
                rowcount += 1
            print "I found the following number of local elevation features with that value: "
            print rowcount
            finalElevRow.reset()
            if rowcount == 1:
                for row in finalElevRow:
                    currentElevId = row.ORIG_FID
                    print "This is the ID of the new summit feature: "
                    print currentElevId
            else:
                currentElevId = -9999
                print "This is the ID of the new summit feature: "
                print currentElevId
0 Kudos
EvanFedorko
New Contributor
thanks for your help!

here is what I did.

1. I tried inserting .reset statements where needed and removing redundant cursors. this didn't work.
2. I switched to deleting cursors and then re-establishing them. this still didn't work, but it got me thinking...
3. ultimately, I stuck with deleting and re-establishing cursors, but I also changed the name of each iterator. so, this is how the code ended up looking and working where I needed to loop through a single cursor twice:

          
 
            finalElevRow = arcpy.SearchCursor("selectedFeatures_lyr", whereClause)
            rowcount = 0
            for thing in finalElevRow:
                rowcount += 1
            print "I found the following number of local elevation features with that value: "
            print rowcount

            del finalElevRow

            finalElevRow = arcpy.SearchCursor("selectedFeatures_lyr", whereClause)

            if rowcount == 1:
                for glob in finalElevRow:
                    currentElevId = glob.ORIG_FID
                    print "This is the ID of the new summit feature: "
                    print currentElevId
            else:
                currentElevId = -9999
                print "This is the ID of the new summit feature: "
                print currentElevId

            del finalElevRow


I'm going to try it, but I think using .reset AND changing the name of the iterator might do the trick. thanks so much for your help!

yrs-
Evan!
0 Kudos
StacyRendall1
Occasional Contributor III
Glad to hear it, Evan!

Interesting that reset() command didn't work - I've never had to use it... You shouldn't have to change the name of your iterated item, especially when that makes it loose meaning - that could make your code pretty confusing to come back to in the future. However, it couldn't hurt to delete references to the iterated item as well (i.e. del row), like so:
 
            finalElevRow = arcpy.SearchCursor("selectedFeatures_lyr", whereClause)
            rowcount = 0
            for row in finalElevRow:
                rowcount += 1
            print "I found the following number of local elevation features with that value: "
            print rowcount

            del finalElevRow, row

            finalElevRow = arcpy.SearchCursor("selectedFeatures_lyr", whereClause)

            if rowcount == 1:
                for row in finalElevRow:
                    currentElevId = glob.ORIG_FID
                    print "This is the ID of the new summit feature: "
                    print currentElevId
            else:
                currentElevId = -9999
                print "This is the ID of the new summit feature: "
                print currentElevId

            del finalElevRow, row
0 Kudos