none
Stack around Variable 'XXXX' corrupt RRS feed

  • Question

  • I got the following error when I tried to run a stored procedure and retrieve an output value.
    "Stack around the variable 'scriptFile' corrupt."
    I tried printing the value onto the console and that is where i get this error..

    The stored procedure accesses a few tables and creates and array in a CSV String and this has been marked as an OUTPUT parameter in the Stored Proc..

    Some specifics about the stored proc and my ODBC setting:

    CREATE PROCEDURE getBucketDetails
    (
        @installedVersion varchar(20),
        @scriptFileCollection varchar(100) OUTPUT
    )             

    ...
    ...
    SET @scriptFileCollection = ''

     WHILE  PATINDEX('%'+@seperator+'%',@scriptListIterator) <> 0
        BEGIN
             ...
             ...
             SET @scriptFileCollection = @scriptFileCollection + '|' + @scriptFileName
            ...
            ...
        END

    SET @scriptFileCollection = SUBSTRING(@scriptFileCollection,2,LEN(@scriptFileCollection))
    PRINT ' Final String :' + @scriptFileCollection

    This runs fine when I use Query Analyser.
    And the SQLBindParameter line goes like this.

    SQLCHAR scriptList[1000];
    SQLINTEGER _scriptList = SQL_NTS;

    rc = SQLBindParameter(hQuery, 2, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_CHAR, 1000, 0,scriptList, 2000, &_scriptList);

    And I know that for this particular input I am trying to run, the scriptFileCollection is never more than 20 characters.
    Tuesday, July 3, 2007 4:19 PM

All replies

  • That 2000 does not seem to make sense.  I would suggest modifying your SQLBindParameter to be:

     

    rc = SQLBindParameter(hQuery, 2, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_CHAR, 1000, 0,scriptList, 1000, &_scriptList);

    You are binding a SQL_C_CHAR which is an ascii character, so it will try to copy up to 2000 ascii characters to your parameter, which is 1000 characters long -- resulting in stack corruption.  Realistically, this seems impossible based on the size of your output parameter, so there may be more issues going on here than what you have shown us, but let's start by fixing that call and if you could, please send:

     

    all your variable length declarations

    all calls you make that alter these variable length data members

     

    SQLBindParameter doesn't really do anything to your data member, so we really only see the setup right now.  Can we see what you are doing with this thing after it is bound?

     

    Thanks,

     

    John

    Tuesday, July 3, 2007 5:50 PM