Re: Tale of debugging and programming logic in c#/sql

From: clintonG (csgallagher_at_REMOVETHISTEXT@metromilwaukee.com)
Date: 05/02/04


Date: Sun, 2 May 2004 18:33:51 -0500

I've recently learned about NUnit.org. Learning to use it correctly
is the next objective.

-- 
<%= Clinton Gallagher
         A/E/C Consulting, Web Design, e-Commerce Software Development
         Wauwatosa, Milwaukee County, Wisconsin USA
         NET csgallagher@REMOVETHISTEXTmetromilwaukee.com
         URL http://www.metromilwaukee.com/clintongallagher/
"Irritable Bowel Syndrome" <jabailo@earthlink.net> wrote in message
news:J00lc.2737$V97.1353@newsread1.news.pas.earthlink.net...
>
> Just finished off a production .NET web application written in c#.
>
> I set up a error handler in the global.asax which is triggered to iterate
> through the error stack and send it and other information to me in an
> email.  This gives me logging and alerting and a record of usage ( by
> sending time ).
>
> After deploying the application I noticed intermittent errors in the Page
> Load event after the user logs on.   I wasn't every user, but the errors
> occurred all day long.   My error handler email shows two session
variables
> and the user name as well as the trace.  The error was: Object reference
> not set to an instance of an object.  If you've done any .NET, this can
> mean an uninitialized or null variable ( among other things) that is being
> used in a method or cast that a NULL cannot be used.
>
> I was puzzled.  This would have been the very first thing after Forms
> Authentication -- and obviously, I would run through that step many many
> times both in the VS IDE and in QA.   Occasionally my QA engineer would
see
> the problem, very infrequently, and report it to me.  But then I could
> never reproduce it.  And by the time I got back to him and asked him to
> show it to me, the problem didn't reappear.
>
> Then I noticed something.  All the user names were multiwords -- that is,
I
> was always testing with something like /jb/ or /jbailo/ as the user name.
> In the error messages, the user name was Mary S. Rutherford.   And the
spec
> said we would allow for a full name as the username. Aha!  I have found
the
> bug -- spaces and periods.  To test, I entered my name, John A. Bailo and
> it threw the error.  So I set up a parsing method to remove all
> non-alphanums from the user name.  Testing again, I saw that my fix worked
> and I pushed it to production.   I was anxious to find a fix, and I didn't
> do full testing.  The login page was written poorly -- it was from an
> earlier release of the web application -- but we didn't have time to
change
> it.  It used a composed String for the SQL command rather than a
> parameterized query.
>
> Waited a few hours and watched the errors.  Nope.  The production site was
> still generating errors.  What was it, what was it???  Finally, I loaded
up
> VS.2003 and set some breakpoints.  Instead of using my name, I used one of
> the names from the customers.   BOOM!  Now I saw it.  The login page does
a
> INSERT if its a new user ( and a lookup if its a returning user).  When
the
> INSERT statement ran with the user's name, it threw an error that said
> 'String or binary data may be truncated'.   That's it.   The spaces aren't
> the problem -- it was that the user name was TOO LONG!  Checking the
> database, I see that yes, the username field was nchar(10)!   Inserting a
> longer name threw the error.
>
> So what happened was:  there is a Session variable that is created once
the
> user authenticates or creates a new login name -- it is based on an ID
> number generated in the database once the user's name and password are
> inserted.   The INSERT never completed and so caused the session variable
> to be NULL and the first time it was accessed by another method -- it
threw
> the error.
>
> Why was I fooled?  Because John A. Bailo with the spaces and period
removed
> is JOHNABAILO -- 10 characters!!!  I /fixed/ the problem, but locally --
> not globally; only for people whose whole name is 10 chars or less after
> removing spaces and non-alphanums!
>
> Oh, and why didn't the error email show the actually error?   Because I
had
> used a try/catch block for the login INSERT statement -- and I didn't put
> tracing or logging in the catch -- thus the statement threw an exception
> and proceded on its merry way -- and later on in the code when the missing
> session variable threw an error -- I had no idea what the actual cause was
> -- though I spent a week trying to fix it with system level fixes such as
> explicit garbage collection and tweaking the IIS server.
>
> Oh -- the logic of programming... :D
>
> -- 
> W '04 <:> Open


Relevant Pages

  • Re: COBOLs Influence on C
    ... environment that relies on having scads of libraries that must be ... Deployment to production is controlled by a third group: ... Then fix the real problem rather than ranting about how it is everyone ... third party, which calls C from another third party. ...
    (comp.lang.cobol)
  • Tale of debugging and programming logic in c#/sql
    ... Just finished off a production .NET web application written in c#. ... I set up a error handler in the global.asax which is triggered to iterate ... My error handler email shows two session variables ... The login page was written poorly -- it was from an ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: PLEASE.....ANY HELP GREATLY APPRECIATED
    ... You will have to try to fix this from a second working Windows installation. ... "John John" wrote: ... I wanted to get rid of that annoying login screen on my home computer (which ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: WIN2K Pro cannot login to domain (In-place upgrade to 2003 R2 from NT4.0)
    ... Original PDC is in the production NW ... When you take TBDC offline and upgrade it to PDC, can all clients login ... WIN2K Pro cannot login to domain (In-place upgrade to 2003 R2 ...
    (microsoft.public.windows.server.migration)
  • Re: z/OS PTFs
    ... Meganen Naidoo - BCX - RO JHB wrote: ... We are currently running z/OS 1.7 service level 0705 on 11 production ... Lpars for different clients - not in a sysplex. ... use the 'fix on fail' approach if we require a fix. ...
    (bit.listserv.ibm-main)