46
\$\begingroup\$

This is the robbers' thread. The cops' thread is here.

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>

\$\endgroup\$
  • 2
    \$\begingroup\$ 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? \$\endgroup\$ – Stephen Jul 24 '17 at 17:03
  • 1
    \$\begingroup\$ Multiple people can post cracks to the same cop submission... Please define different. \$\endgroup\$ – Dennis Jul 25 '17 at 13:41
  • \$\begingroup\$ @NoOneIsHere codegolf.meta.stackexchange.com/q/13437/58826 \$\endgroup\$ – programmer5000 Jul 25 '17 at 15:26

139 Answers 139

2
\$\begingroup\$

JavaScript, programmer5000

null

That's basically it.

\$\endgroup\$
  • \$\begingroup\$ @programmer5000 Sorry, I didn't see the mistake when trying to FGITW \$\endgroup\$ – Kritixi Lithos Jul 24 '17 at 17:47
2
\$\begingroup\$

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.

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

JavaScript (Node.js)

g("13")(13/321)

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

\$\endgroup\$
  • 1
    \$\begingroup\$ 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 \$\endgroup\$ – Stephen Jul 24 '17 at 19:28
2
\$\begingroup\$

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 ?)

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

JavaScript by Grant Davis

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

getter is powerful. you may also try Proxy.

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

Bash, Dennis

//

Try it online.

\$\endgroup\$
2
\$\begingroup\$

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

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

JavaScript (Node.js), 36 bytes, tsh

1.00000001

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

Try it online!

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

JavaScript, Step Hen

" "

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Bash 4.2, Dennis

-9223372036854775808/-1

Why though, Dennis? y u do dis?

\$\endgroup\$
  • 1
    \$\begingroup\$ Well done. I had 2**63%-1, which results in the same operation. \$\endgroup\$ – Dennis Jul 26 '17 at 2:49
  • \$\begingroup\$ I assume this is a parsing or evaluation bug of some sort? What exactly causes it to fail? \$\endgroup\$ – Robert Fraser Jul 26 '17 at 7:51
  • 1
    \$\begingroup\$ @RobertFraser It overflows! They're stored in small registers and the division generates a SIGFPE. \$\endgroup\$ – Veedrac Jul 26 '17 at 11:08
  • 1
    \$\begingroup\$ 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/… \$\endgroup\$ – Peter Cordes Jul 27 '17 at 10:39
2
\$\begingroup\$

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)
\$\endgroup\$
2
\$\begingroup\$

Pyth, isaacg

Seems to halt every time. Input:

.q

Try it here!

\$\endgroup\$
  • 1
    \$\begingroup\$ Two seconds faster, lol. \$\endgroup\$ – Veedrac Jul 26 '17 at 11:38
2
\$\begingroup\$

Pyth, isaacg

.q

This quits the program.

Try it online.

\$\endgroup\$
2
\$\begingroup\$

C, Steadybox

1597463007 1065353216

Try it online.

This one was clever.

\$\endgroup\$
2
\$\begingroup\$

Pyth, isaacg

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

I call this "privilege escalation" :P.

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
  • 2
    \$\begingroup\$ 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 \$\endgroup\$ – JAD Jul 27 '17 at 20:35
  • \$\begingroup\$ Sounds good to me :) \$\endgroup\$ – Gregor Jul 27 '17 at 20:54
  • 1
    \$\begingroup\$ @JarkoDubbeldam See edits for two more cracks that work on the list(0) version. 'return' seems like it might even be the intended solution. \$\endgroup\$ – Gregor Jul 27 '17 at 21:00
  • \$\begingroup\$ Getting closer, but not the intended solution. \$\endgroup\$ – JAD Jul 28 '17 at 4:42
  • 1
    \$\begingroup\$ A few more cracks for the new version: "NROW", "NCOL", and "lengths" \$\endgroup\$ – Gregor Jul 28 '17 at 6:16
2
\$\begingroup\$

JavaScript, iovoid

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

Try it online!

\$\endgroup\$
2
\$\begingroup\$

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!

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Patrick Roberts Jul 28 '17 at 7:05
  • \$\begingroup\$ @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! \$\endgroup\$ – Dom Hastings Jul 28 '17 at 7:47
  • \$\begingroup\$ Also, the username typically links to their cop answer, not their account page, while you're editing. \$\endgroup\$ – Patrick Roberts Jul 28 '17 at 7:49
2
\$\begingroup\$

Python, Alex Hall

"%307d"%1

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

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Patrick Roberts Jul 31 '17 at 3:21
2
\$\begingroup\$

Python 2, by veedrac

import os, functools
class A:__int__ = os.abort
k(functools.partial(int, A()))
\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Veedrac Jul 31 '17 at 3:01
2
\$\begingroup\$

Python 3, Alex Hall

1<<1017

Try it online!

\$\endgroup\$
2
\$\begingroup\$

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!

\$\endgroup\$
1
\$\begingroup\$

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!

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

Add++, caird coinheringaahing

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

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Node.JS, programmer5000

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

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

TIO

\$\endgroup\$
1
\$\begingroup\$

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!

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.