Talk:Halt and catch fire

From Rosetta Code

A bit limited ?

Is this task to be taken literally - halt the CPU - and thus only be applicable to the handful of assembly languages with samples already provided ?
Or does it mean "crash the program" by e.g. dividing by zero or asserting a false condition or raising an unhandled exception or calling exit or...

Whilst reading about the fictitios HCF instruction was entertaining, do we want to encourage people to crash their CPUs ?

--Tigerofdarkness (talk) 21:02, 12 September 2021 (UTC)

I didn't see that the task was to   halt the CPU,   but to   crash the (computer) program.     -- Gerard Schildberger (talk) 21:09, 12 September 2021 (UTC)
Thanks Gerard. What does your impressively minimal REXX program do ? --Tigerofdarkness (talk) 17:24, 15 September 2021 (UTC)


It "crashes" the REXX interpreter,   the messages can vary from REXX to REXX, but for Regina REXX,   the output shown to my terminal   (a Windows DOS "boxed" screen)   is:
─────────────────────────────────────────────────────────────────────────────09/15/2021 13:21:27
c:\►regina haltfire
Error 35 running "c:\haltfire.rex", line 1: Invalid expression
Error 35.1: Invalid expression detected at "="

─────────────────────────────────────────────────────────────────────────────09/15/2021 13:21:29
c:\►

 

      ---  where the 1st two lines are a DOS prompt   (actually, it is one DOS prompt line that is wrapped into two lines)   and
      ---  lines 3 and 4 are the actual (two) error messages from Regina REXX,   
      ---  followed by the DOS prompt   (again, it looks like two lines, but it is a single long DOS prompt that wraps.
      ---  A different REXX interpreter should/may produce similar error messages(s). 
I could've chosen some other character, but a lone equal sign seemed (to me) a very succinct way to "crash" a REXX interpreter without use some other "special" character.       -- Gerard Schildberger (talk) 18:37, 15 September 2021 (UTC)

But... isn't that a compilation error, as opposed to a runtime "crash"? I suspect pretty much every programming language on rc (all 800+ of them) would trigger the same. I think the task is implicitly asking for something more akin to "if 2+2<>4 then = " to compile cleanly and not crash, but "if 2+2<>5 then = " to crash, (and again implicitly) at runtime. Obviously where (the condition and) "=" is language specific. --Pete Lomax (talk) 01:28, 16 September 2021 (UTC)
Well, perhaps one could think of it as a compiler (interpreter) error,   but it is more of an unexpected error that Regina REXX can't recover from.   There are other errors such as a source (REXX statement) that doesn't have a closing quote or comment delimiter,   or a "special" character that has no place in a REXX statement,   or an unexpected left/right parenthesis or comma,   no (closing)   END   for a   DO   or   SELECT   statement, etc.     But this task's requirement was to make the program as short as possible   (crash golf?).   I tried for a concise error that (the current) Regina REXX couldn't recover from and raise the "SYNTAX" error,   which a REXX program could recover from.   Note that REXX can trap and possibly recover from a (statement) syntax error,   and indeed, many REXX programs that have a good deal of boilerplate code that will do just that,   and issue informative error messages to the terminal stating which program was being executed, which statement number failed (and how it failed),   and perhaps what the particular error was (variable not defined, invalid syntax, division by zero, etc.).     However, program recovery wasn't the goal for this Rosetta Code task.     -- Gerard Schildberger (talk) 03:30, 16 September 2021 (UTC)
I also chose a brief syntax error for the Julia example. I think though that the original "halt and catch fire" used to mean exploit a bug in the underlying CPU microcode in order to crash the hardware by having it process an illegal instruction. If this was still possible even with executing raw machine code on recent CPU's I would hope the CPU maker might pay a bounty for information on such an exploit! --Wherrera (talk) 06:59, 16 September 2021 (UTC).
That sort of thing briefly crossed my mind too, but it would be hardware-specific as opposed to programming-language-specific, and therefore somewhat against the primary purpose of this whole site (albeit the op deals primarily in hardware-specific programming languages). Like most everyone else I just assumed we were looking for an emergency "panic" that could be inserted into any other program, and only triggered when some critical test failed, maybe the task should be changed to explicitly ask for that, eg
"It should be possible to insert [a specified subset of] your submission into another program [written in the same language], presumably to help debug it."
This sounds different from the original task. If the code just terminates the program, this is similar to the program termination task. I wonder if the only examples that completly fit the original task would be the 6502 and 68000 assembly ones, since those work by crashing the CPU, not just by a halt instruction or an exit with error code.--Wherrera (talk) 17:32, 21 September 2021 (UTC)
One difference in my mind is that Program_termination is a clean (quiet) shutdown, whereas this seems to ask for a (loud) bang. --Pete Lomax (talk)
The task also asks for the minimum number of lines rather than minimum number of characters, btw. --Pete Lomax (talk) 12:27, 16 September 2021 (UTC)

Syntax errors

The name of this task is not "Generate syntax error". Task description updated, four (out of 22) entries marked incorrect. --Pete Lomax (talk) 00:40, 19 September 2021 (UTC)
PS I am not sure whether the Perl entry is incorrect. I know that, for instance, JavaScript allows dummy(); and only complains that it is [still] undefined when it actually tries to execute that line. --Pete Lomax (talk)