tanrj / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

crash while trying to run a query against a SQL 2008 R2 server (Mac OSX) #155

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.  The function below is run in a loop, it runs successfully 14 times, then 
the crash below happens

What is the expected output? 
Checking staging table to see if we have already started downloading 
Answers.ask.com...
   9263 pages and 926268 rows previously read
Domain: Answers.ask.com, Markets: set([u'Answerbag']), Names: 
set([u'Answers.ask.com'])
Saving to: ccinterface.txt
Received 926200/926268 rows, page 9263
Answers.ask.com Already read all 926268 rows
2011-02-07 15:55:00.772270: Completed Answers.ask.com

What do you see instead?
Checking staging table to see if we have already started downloading 
THISNEXT.COM...
Python(36888,0x7fff70eb9ca0) malloc: *** error for object 0x102402890: 
incorrect checksum for freed object - object was probably modified after being 
freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap

What version of the product are you using? On what operating system?
I have Python 2.7.1 installed, pyodbc-2.1.8, Actual Technologies "Actual SQL 
Driver".   OS is Mac OS X 10.6.6 (10J567).  I realize that this could be a 
driver problem, but would like to confirm that this is not a known pyodbc 
issue.  Dump info is attached.

Please provide any additional information below.

def get_highest_page_number(cxn, competitor):
    querytxt = """SELECT MAX(Page) AS max_page_number
                  , MAX(RowNumber) AS max_row_number
                  FROM dbo.StagingCCInterface WHERE TargetDomain = CAST(? AS NVARCHAR(MAX))"""
    max_page_number = 0
    max_row_number = 0
    try:
        cursor = cxn.cursor()
        cursor.execute(querytxt, ( competitor ))
        row = cursor.fetchone()
        if (row != None):
            max_page_number, max_row_number = row.max_page_number, row.max_row_number
            if ( max_page_number == None ):
                max_page_number = 1
            if ( max_row_number == None):
                max_row_number = 0
        else:
            max_page_number, max_row_number = 1, 0
    except Exception, x:
        print 'Failed to execute query:\n{0}\n----Error: {1}'.format(querytxt,x.message)
        exit(-1)
    finally:
        if (cursor != None):
            cursor.nextset()
            cursor.close()
    return max_page_number, max_row_number

Original issue reported on code.google.com by amsi...@gmail.com on 8 Feb 2011 at 12:21

Attachments:

GoogleCodeExporter commented 8 years ago
Doh!  Still getting used to Python and its garbage collector.  I altered the 
function slightly to have the variable "cursor" assume a value of "None" before 
the try block.  This seems to have resolved the issue, presumably because it is 
no longer dropping out of scope at the time the "finally" block executes. 

Original comment by amsi...@gmail.com on 8 Feb 2011 at 12:40

GoogleCodeExporter commented 8 years ago
I'm glad you found a work around.  (Actually, not just a work around - you 
would need that change for memory, presumably.)

I hate to point fingers, but from the dump I'm suspecting a FreeTDS issue.  I'm 
going to close this for now, but please let me know if you see any new issues.  
Thanks for the report.

Original comment by mkleehammer on 28 Feb 2011 at 12:35