Hi Tom,
I recompiled the code you've listed above with a just a very minor change (no web server):
Code: Select all
#include <stdio.h>
#include <autoupdate.h>
#include <ip.h>
//#include <http.h>
#include <dhcpclient.h>
#include <taskmon.h>
#include <smarttrap.h>
#include <math.h>
void UserMain(void * pd)
{
InitializeStack();
GetDHCPAddressIfNecessary();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();
//StartHTTP();
EnableTaskMonitor();
#ifndef _DEBUG
EnableSmartTraps();
#endif
iprintf("Application started\n");
while (1)
{
printf("Infinity: %g\r\n", infinity());
OSTimeDly(TICKS_PER_SECOND);
}
}
This is the output:
Waiting 2sec to start 'A' to abort
Configured IP = 192.168.1.230
Configured Mask = 255.255.255.0
MAC Address= 00:03:f4:09:39:51
Application started
No modifications to the kernel.
The function infinity() is not the important important part, it's just that the infinity case is NOT handled in nbfloatprint.cpp. the NaN case, however, IS handled.
When a float is printed to the screen, there are several functions which have while loops with no error checks:
Code: Select all
int Get_f_len(double d, pfstate & pfs)
...
while ( fi > 0xFFFFFFFFFFFFFFFFULL )
{
l++;
fi /= 10.0;
}
...
int OutputFFloat(PutCharsFunction * pf, void * data, double d, pfstate & pfs)
...
while ( fi > 0xFFFFFFFFFFFFFFFFULL )
{
fi /= 10.0;
exp++;
}
...
int OutputEFloat(PutCharsFunction * pf, void * data, double d, pfstate & pfs, char e_or_E)
...
while ( d >= 10.0 )
{
d /= 10.0;
exp++;
}
...
since no check for infinity is done before these calls are made, gcc throws an internal exception when fi (or d) are divided by 10.0, and the original value of fi and d are maintained at infinity, hence the loops run forever.
handing the Inf case, in the same location as the NaN case is currently handled, solves the problem. This non-handling of printing infinities exists in NNDK 2.8.1, 2.8.5 and 2.8.7 (though I assume this exists since these files were introduced).
In my case, the software is performing logarithm calculations and at some point tries to take the logf(0.0), which results in Infinity, and when printing this back to a web page, the HTTP task gets stuck in this infinite loop.