Bug #8375

TRACE_n() macros don't check for nil/undef vars

Added by alef over 5 years ago. Updated over 5 years ago.

Status:Closed Start date:01/21/2010
Priority:Normal Due date:
Assignee:killswitch % Done:

100%

Category:-
Target version:v0.3.1
Component: Affected Version:
Close Reason:

Description

TRACE_n() macros simply do 1 str(argument). If an argument is undefined/nil, dereferencing it halt the execution with "Error Undefined variable in expression":

This doesn't happen if the arg is the word nil itself: 1 TRACE_1("message",nil)

1 if(isNil {A}) then {"nil"} else {str(A)} in the macros could help.

Associated revisions

Revision 8d294426
Added by killswitch over 5 years ago

ADDED: 'RETNIL' macro per Alef's suggestion. Fixes #8375 and #8514

Revision 8d294426
Added by killswitch over 5 years ago

ADDED: 'RETNIL' macro per Alef's suggestion. Fixes #8375 and #8514

History

Updated by killswitch over 5 years ago

I can't reproduce this, ie I cannot get the TRACE macros to generate such an error. Can you give us an example?

Feeding the result of str(A) for an undefined "A" into the TRACE macro should be safe as far as I can tell.

Updated by alef over 5 years ago

killswitch wrote:

Can you give us an example?

(untested)
1 _undefined=nil; TRACE_1("msg",_undefined);
There are other "1 nil" issues in functions and macros, but I'll post more reproducible tickets about later.

Updated by alef over 5 years ago

I propose to add the macro
1 #define STRNIL(x) call{if(isNil{x})then{"nil"}else{x}}
and change 1 TRACE_n() macros to use 1 STRNIL(x) in place of 1 str(x).

I've tested this and does work.

Updated by killswitch over 5 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Updated by killswitch over 5 years ago

  • Assignee set to killswitch
  • Target version set to v0.3.x

Updated by Sickboy over 5 years ago

  • Status changed from Resolved to Closed

Updated by Sickboy over 5 years ago

  • Target version changed from v0.3.x to v0.3.1

Also available in: Atom PDF