FIX: SQLAgent Exception Occurs when the System Maintains 613, 2661 or 4709 Jobs
Symptoms
The SQLAgent process may terminate with with following error messages:
2001-01-14 19:21:11 – ! [LOG] Exception 5 caught at line 335 of file ..\src\job.c.SQLServerAgent initiating self-termination
2001-01-14 19:21:29 – + [098] SQLServerAgent terminated (forcefully)
Resolution
SQLAgent creates a memory structure to support the xp_sqlagent_enum_jobs action. With SQL Server 2000 the structure is 588 bytes plus 4 bytes for overhead. However, an incorrect CAST to a LPTSTR, instead of a LPBYTE, results in an incorrect 4 byte shift.
When the (number of created jobs on the system * 588) + 4 = NT Page boundary the incorrect 4 byte cast results in the exception.
