cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
AlterEgo
Level III

Throw() with traceback flag within a sub-function crashes JMP

I 've encountered the following issue (minimal example below). Is this a bug or am I missing something?

(Windows 11, JMP 18.0)



The following script crashes JMP instead of simply throwing the error:

Names Default To Here(1);

f = Function( {}, { sub_f },

	sub_f = Function( {},
		If( 1, Throw( "thrown", 1 ) );			
		Return( "ok" )
	);
	
	Return( sub_f() )
);

f()

In contrast to the above, without the traceback flag, it normally throws the "thrown" error.

Names Default To Here(1);

f = Function( {}, { sub_f },

	sub_f = Function( {},
		If( 1, Throw( "thrown" ) );			
		Return( "ok" )
	);
	
	Return( sub_f() )
);

f()

Also, the crash is prevented by trapping the Return()  into Try().

Names Default To Here(1);

f = Function( {}, { sub_f },

	sub_f = Function( {},
		If( 1, Throw( "thrown", 1 ) );			
		Return( "ok" )
	);
	
	Try( Return( sub_f() ), Throw( "crash prevented" ) )
);

f()

 

1 REPLY 1
Craige_Hales
Super User

Re: Throw() with traceback flag within a sub-function crashes JMP

you've found a bug in JMP, I'm submitting a report pointing to this thread. You can work around it by commenting out the local variable for sub_f:

f = Function( {}, // { sub_f },

(Pretty sure this is a reasonably correct explanation...) By the time JMP catches the throw() the local variables are destroyed and the information for the traceback has been lost. The code that produces the traceback is unprepared for that and crashes with an invalid memory reference. When you added the try() inside the function, JMP catches the throw inside the function and the local has not been destroyed. Or, just keep the function in a global will also work.

 edit: TS-00250890

Craige

Recommended Articles