# Will it halt? (Robbers)

Your challenge is to crack a cop's submission by finding an input that makes it halt. You don't have to find out why, or all inputs that make it halt if there's more than one, or the input the cop intended, just one input will do.

Once you have cracked a submission, post a link to it in a comment or edit to the cop's post. You can also flag your submission for a mod to edit it in the cop's post. Also, post the input used and a link to the cop's post in an answer in this thread. The robber that cracks the most submissions wins.

Multiple people can post cracks to the same cop submission, as long as they are different.

(If SE converted your duplicate answer to a comment, you may want to vote on this feature request)

# Looking for uncracked submissions?

fetch("https://api.stackexchange.com/2.2/questions/135363/answers?order=desc&sort=activity&site=codegolf&filter=!.Fjs-H6J36vlFcdkRGfButLhYEngU&key=kAc8QIHB*IqJDUFcjEF1KA((&pagesize=100").then(x=>x.json()).then(data=>{var res = data.items.filter(i=>!i.body_markdown.toLowerCase().includes("cracked")).map(x=>{const matched = /^ ?##? ?(?:(?:(?:$|<a href ?= ?".*?">)([^$]+)(?:\]|<\/a>)(?:[$$$][a-z0-9/:\.]+[$$$])?)|([^, ]+)).*[^\d](\d+) ?$?(?:(?:byte|block|codel)s?)(?:$(?:$$.+$$)?)? ?(?:$$?(?!no[nt][ -]competing)$$?)?/gim.exec(x.body_markdown);if(!matched){return;}return {link: x.link, lang: matched[1] || matched[2], owner: x.owner}}).filter(Boolean).forEach(ans=>{var tr = document.createElement("tr");var add = (lang, link)=>{var td = document.createElement("td");var a = document.createElement("a");a.innerText = lang;a.href = link;td.appendChild(a);tr.appendChild(td);};add(ans.lang, ans.link);add(ans.owner.display_name, ans.owner.link);document.querySelector("tbody").appendChild(tr);});});
<html><body><h1>Uncracked Submissions</h1><table><thead><tr><th>Language</th><th>Author</th></tr></thead><tbody></tbody></table></body></html>

• Does different mean different inputs (say, all inputs ending with 2 crack the cop's post - can you different people post different numbers ending in 2?) or different families of inputs, or different types of inputs? – Stephen Jul 24 '17 at 17:03
• Multiple people can post cracks to the same cop submission... Please define different. – Dennis Jul 25 '17 at 13:41
• @NoOneIsHere codegolf.meta.stackexchange.com/q/13437/58826 – programmer5000 Jul 25 '17 at 15:26

# JavaScript, programmer5000

null


That's basically it.

• @programmer5000 Sorry, I didn't see the mistake when trying to FGITW – user41805 Jul 24 '17 at 17:47

# JavaScript, programmer5000

new Buffer(268435440)


Throws an error when it is coerced into a string.

Try it online!

Got it from this request for better error documentation.

• Woah! Nice job! – programmer5000 Jul 24 '17 at 19:14
• @programmer5000 thanks :P now go crack mine two newest ones, have fun :P – Stephen Jul 24 '17 at 19:15

# JavaScript (Node.js)

g("13")(13/321)


It works, apparently you can replace 13 with 33, 53, etc

• That's not what I had in mind, but good job getting around what I had in mind, because you would never have guessed it :P – Stephen Jul 24 '17 at 19:28

# Python 2, Foon

Crack or hack? I'm not sure which this is yet...

Windows:

exit()
<ctrl>C


Where <ctrl> is the actual key modifier. This will eval exit() in the first pass of the loop and catch the keyboard interrupt in the second. quit will work in place of exit too.

(Nix replace <ctrl>C with <ctrl>D ?)

# Python 3.5, Siphor

"\r def t():pass"


Calling f("\r def t():pass") will redefine the "inner" t to a function that does nothing prior to it being created inside the "outer" t.

# JavaScript by Grant Davis

({t:1,get x(){ return this.t--; }})


getter is powerful. you may also try Proxy.

• I used __proto__.defineGetter, but this is more elegant. This challenge has taught me a lot about JavaScript. – Grant Davis Jul 25 '17 at 3:27

# Bash, Dennis

//


Try it online.

# JavaScript (Node.js), tsh

code:

x=>{try{for(;!x||x!=0||x instanceof Object||typeof x!='object';);}catch(e){for(;;);}}


input:

{valueOf:g=>{Object=Number;return 0}}


Try it online!

!x: x resolves to true !true resolves to false

x!=0: valueOf is overridden and returns 0. 0!=0 is false Also sets Object to Number for next step

x instanceof Object: Object now points to Number and x is an Object not a Number so this resolves to false

typeof x!="object": x is an object so typeof x returns "object". "object"!="object" is false

• Good job. instanceof is just something too weak... – tsh Jul 25 '17 at 5:06
• @tsh Not hard to break things when one messes with prototypes and reassigns critical global variables. – Grant Davis Jul 25 '17 at 5:15

# JavaScript (Node.js), 36 bytes, tsh

1.00000001


Any value near 1 under the rounding threshold will make it.

Try it online!

• Wow, love it. although that is not what I want... – tsh Jul 25 '17 at 8:50

# JavaScript, Step Hen

" "


Try it online!

# Bash 4.2, Dennis

-9223372036854775808/-1


Why though, Dennis? y u do dis?

• Well done. I had 2**63%-1, which results in the same operation. – Dennis Jul 26 '17 at 2:49
• I assume this is a parsing or evaluation bug of some sort? What exactly causes it to fail? – Robert Fraser Jul 26 '17 at 7:51
• @RobertFraser It overflows! They're stored in small registers and the division generates a SIGFPE. – Veedrac Jul 26 '17 at 11:08
• It's somewhat ironic that (on most platforms, including x86) unless you on purpose unmask FP exceptions, the only thing that will normally raise SIGFPE is an integer division exception. (by zero, or overflow). But POSIX requires integer division to raise SIGFPE if it raises any signal at all: stackoverflow.com/questions/37262572/… – Peter Cordes Jul 27 '17 at 10:39

# Javascript (Node.js), programmer5000

Object.prototype


Object.prototype is the root prototype for all other objects, but it can't obviously have a prototype itself, because that would create a loop. Edit: I think this also works:

Object.create(null)


# Pyth, isaacg

Seems to halt every time. Input:

.q


Try it here!

• Two seconds faster, lol. – Veedrac Jul 26 '17 at 11:38

# Pyth, isaacg

.q


This quits the program.

Try it online.

1597463007 1065353216


Try it online.

This one was clever.

# Pyth, isaacg

exec(input())
__import__("os")._exit(1)


I call this "privilege escalation" :P.

# C++, ecatmur

struct C { int m; };
int C::* t = &C::m;


Try it online!

For some reasons, default initialization of pointer-to-member make that -1, which become true when cast to bool.

# R, Jarko Dubbeldam

"unlist"

Though it's just one more function that could be added to the exceptions - I doubt it's the intended solution.

Two more cracks: 'is.vector' and 'return'. These both work on the modified (list(0)) version.

• you're right, not intended, but good solution! Instead of turning a fix into a new post, do you mind if I change list(1) to list(0)? :D – JAD Jul 27 '17 at 20:35
• Sounds good to me :) – Gregor Thomas Jul 27 '17 at 20:54
• @JarkoDubbeldam See edits for two more cracks that work on the list(0) version. 'return' seems like it might even be the intended solution. – Gregor Thomas Jul 27 '17 at 21:00
• Getting closer, but not the intended solution. – JAD Jul 28 '17 at 4:42
• A few more cracks for the new version: "NROW", "NCOL", and "lengths" – Gregor Thomas Jul 28 '17 at 6:16

# JavaScript, iovoid

this.constructor.constructor("return process")().exit()


Try it online!

## JavaScript (Node.js) by Alex Varga

Updated with what I'd intended to post, thanks to Patrick Roberts' comment!

{valueOf:_=>process.exit(0)}


Try it online!

• Technically that terminates the program before even entering the function, as the process.exit() is invoked inside the call rather than the body. However, changing to {valueOf(){process.exit()}} would be sufficient. – Patrick Roberts Jul 28 '17 at 7:05
• @PatrickRoberts yeah, that's what I'd intended to post... Not sure how I posted the wrong one. I validated it entered the loop on my system, but clearly missed that.. otherwise, I guess I could have just added process.exit(0) on its own, which kinda misses the point of the challenge really. Thanks for the nod! – Dom Hastings Jul 28 '17 at 7:47
• Also, the username typically links to their cop answer, not their account page, while you're editing. – Patrick Roberts Jul 28 '17 at 7:49

# Python, Alex Hall

"%307d"%1


This creates a truthy string consisting of 306 spaces followed by 1.

# JavaScript (Node.js >= 6.0), Patrick Roberts

{__proto__:Function,toString:_=>process.kill(0)}


This probably isn't the intended answer, but it does work. It kills the process without giving either the exit handler or the exception handler a chance to run. Sending to PID 0 is shorter than to process.pid and sends the signal to all processes in the current process group.

• Ah, unfortunate... Interesting object literal though, can't say I've ever seen one with a __proto__ attribute in it. And no, this wasn't quite it, but it was indeed creative, and probably more efficient than my answer. – Patrick Roberts Jul 31 '17 at 3:21

# Python 2, by veedrac

import os, functools
class A:__int__ = os.abort
k(functools.partial(int, A()))

• Nice effort; I see your solution to mine is very similar to my solution to yours. This wasn't the intended solution, but I only just figured out partial can be used like this so fair play. I'll probably add a revision that bans functools.partial, but I'll leave that for another day. – Veedrac Jul 31 '17 at 3:01

# Python 3, Alex Hall

1<<1017


Try it online!

# Python 3, E.D. (Fixed)

The input 0526315789473684210344827586206896551724137931020408163265306122448979591836734693877551 halts the fixed program. Since each of the three chunks are separate from each other, you can compute them individually, then combine them together. A coworker of mine figured out the logic and wrote the script to generate this answer.

Also, the fix didn't entirely work as an input of "0"*88+"1" will halt the program as well, since the check for a nonzero n checks the whole string, while only n[:88] is used in the calculations. So, any input of the form "0"*88+A where A is a string where all elements are digits, and at least one is nonzero, will cause the program to halt.

Try it online!

# JavaScript (ES6), programmer5000

"Infinity"


The condition first tests if the input has a .slice method (aka if it's a string or an array) and gets the absolute value of the numeric representation of the string/array. This is then added to 0 and checked against Infinity.

Try it online!

• :( I thought mine would last longer! Nice Job! – programmer5000 Jul 24 '17 at 18:07
• @programmer5000 thanks :) – Stephen Jul 24 '17 at 18:08
• [Infinity] also works. – Cristian Lupascu Jul 25 '17 at 13:41
• @w0lf also ["Infinity"] – Stephen Jul 25 '17 at 13:45

The empty input. The answer is pretty pointless, since it never runs in an infinite loop.

Try it online!

# Node.JS, programmer5000

x = {}
x.constructor = false
f(x)


We define an object where x.constructor is false so it terminates immediately

TIO

# Python 3, Erik Brody Dreyer

While error raising cracks are 10 a penny, a simple non-erroring one is just 88 zeros in a row:

def fun(n):
while not (int(n[17]+n[:17])==2*int(n[:18]) and int(n[45]+n[18:45])==3*int(n[18:46]) and int(n[87]+n[46:87])==5*int(n[46:88])):
print("Ha")
fun("0"*88)
print("halted and did not error")


Try it online!

# JavaScript (Node.js), programmer5000

Object.defineProperty(a={},"__proto__",{value:false,writable:false})


Try it online!

Simple enough. A truthy object who's __proto__ is defined to be false permanently.