Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Random Crashes

Guest
Jan 19, 2011 Jan 19, 2011

For some time now I have been seeing an error appear in the Coldfusion 9 error log. I have had clients call up about a GSD from this error. The error is as follows:

"Error","jrpp-14143","01/18/11","07:38:06","XXX","The value '' cannot be converted to a number. The specific sequence of files included or processed is: C:\Inetpub\wwwroot\www.XXX.com\XXXXX.cfm, line: 256 "

coldfusion.runtime.Cast$NumberConversionException: The value '' cannot be converted to a number.

This most of the time is not a problem and the program runs flawlessly. It is at random times that this error occurs and there is no way to reproduce this error in the test environment or in production. The line it points to are all variables that are set to literals or in a CFLOOP. They are all set by the server, not a human. I am having problems trying to figure this one out.

code:

<table id="2R-#count#" <cfif count LTE RmaxFirstShow OR ( count NEQ (RmaxFirstShow+1) AND ( StructFind( Evaluate(XXX) , "XXX#count#" ) NEQ "" OR

( count GT 2 AND

StructFind( Evaluate(XXX) , "XXX#count-1#" ) EQ "") ) )>style="display:none;"</cfif>>

Every variable here, with the exception of the struct in the session, are set by the code and not any human. They are all integers.

Any help on this would be much appreciated.

EDIT: Correcting code. Adding in ")" that was missing but actually in the working template.

1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2011 Jan 19, 2011

Start by looking at lline 256 and see what variable is supposed to be converted to a number.  Then determine how that variable gets it's value. 

If possible, get any input parameters from the victims.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2011 Jan 19, 2011

I have looked at that line, like previously stated, all values are set by the code and not any user input. These variables have nothing to do with the data from my client, they are just controls on the display of the data. How many input box sets to show when. Everything that would be converted to a number is tightly controlled by the code. No user error possible.

Oh, and it will crash on a file but if you refresh the crash goes away. That is a sign it is user data independent.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2011 Jan 19, 2011
The value '' cannot be converted to a number.

In my experience, that error message usually shows up where you attempt to use '' as an operand in an arithmetic operation. The line of code you've shown contains two operations, namely

RmaxFirstShow+1
count-1

I would therefore conclude that the error is caused by either RmaxFirstShow or count taking the value ''. Put the following just before that line, and examine the log file.

<cflog file="debugBlankString" text="RmaxFirstShow=#RmaxFirstShow#;count=#count#"><cfabort>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2011 Jan 19, 2011

Regarding:

In my experience, that error message usually shows up where you attempt to use '' as an operand in an arithmetic operation. The line of code you've shown contains two operations, namely

In my experience, it's caused by receiving a null value from a numeric field in a database record.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2011 Jan 19, 2011

The data base field that is pulled in is defaulted to 3 and nulls are not allowed.

Up above this line there is the following code:

<cfset RmaxCount = 10>

<cfset RmaxFirstShow = 3>

<cfquery name="GetXXX" datasource="#XXX#">

SELECT XXX1

FROM XXX2 WITH ( NOLOCK )

WHERE XXX3 = '#ATTRIBUTES.XXX3#'

</cfquery>

<cfif GetXXX.XXX1LT RmaxFirstShow>

<cfset RmaxFirstShow = GetXXX.XXX1>

</cfif>

<cfloop from="1" to="#RmaxCount#" index="count">

Edit: And why would from one moment the database return a null value, and next return a number value? There is no place in this section of the code that would change that field.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2011 Jan 19, 2011

ChDangerfield wrote:

The data base field that is pulled in is defaulted to 3 and nulls are not allowed.

Up above this line there is the following code:

<cfset RmaxCount = 10>

<cfset RmaxFirstShow = 3>

<cfquery name="GetXXX" datasource="#XXX#">

SELECT XXX1

FROM XXX2 WITH ( NOLOCK )

WHERE XXX3 = '#ATTRIBUTES.XXX3#'

</cfquery>

<cfif GetXXX.XXX1LT RmaxFirstShow>

<cfset RmaxFirstShow = GetXXX.XXX1>

</cfif>

<cfloop from="1" to="#RmaxCount#" index="count">

Edit: And why would from one moment the database return a null value, and next return a number value? There is no place in this section of the code that would change that field.

Combine what Dan and I have said, and there's your answer! One of the values GetXXX.XXX1 is "". This leads to a value of "" for RmaxFirstShow, which causes an error when ColdFusion attempts to evaluate RmaxFirstShow+1. Log the value as I described earlier, and you should see this.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2011 Jan 19, 2011

GetXXX.XXX1 cannot be '' because none of the fields in that column are ''. The database table is set to not allow NULLs in that column.

The following SQL:

SELECT DISTINCT XXX1

FROM XXX2

Returns:

XXX1

7

5

3

9

1

There are none that are NULL or ''

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2011 Jan 19, 2011
LATEST

I think placing the following line before the code block is the better test

<cflog file="debugBlankString" text="RmaxFirstShow=#RmaxFirstShow#;count=#count#"><cfabort>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2011 Jan 19, 2011

[post deleted: came in too late]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources