The attached program demonstrates an unexpected crash when using the new Lambda function capability. It seems to happen when using a locally declared variable within a static method context. The program is a bit convoluted, and a simpler demonstration may exist, but this isolates what happens in a much larger program. In fact, when the larger program crashes, Ox does not print out a nice error message, so tracking this down was not easy.
The program computes a parameter in a model that is a function of data (stored in static G::x) and coefficients (stored in static G::b). The parameter is a probability so it is specified as prob = exp(x*b)/(1+exp(x*b)). Because b can change, prob needs to be a function, either a static method of G or a Lambda function defined inside a static method of G.
As written the program uses a Lambda function and it runs and prints out the value:
--------------- Ox at 10:13:29 on 27-Mar-2015 ---------------
prob=
0.57444
Remove the comments at Step 1 to use the local variable v0 to avoid two exp() calls and the program crashes:
--------------- Ox at 10:25:24 on 27-Mar-2015 ---------------
Runtime error: 'missing lambda return' fatal error
Runtime error occurred in ? (28), call trace:
(28): ?
The issue is with using the local variable not the reference to static members of the Lambda context.
Remove the comments at Step 2 to use a static method instead of the Lambda function and the program runs (not surprising).
|