Shortest Code to Legitimately Slack Off

146

24

I'm a developer, and I don't feel like doing my work. I know from XKCD that the best excuse for slacking off is that your code's compiling. Because of this, I think I need some code that will compile forever! And because I'm lazy and don't want to have to type much, this has to be done with the shortest code possible.

So, your task is to write a program that is syntactically valid, but will cause the compiler to enter an infinite loop.

Specifications

  • You must use a language that has a compiler, obviously.
  • Specify the implementation used in each solution.
  • This is , so the shortest valid solution (in bytes) wins.
  • The compiler can terminate from running out of memory or stack space.

Esolanging Fruit

Posted 2017-02-16T01:17:06.577

Reputation: 13 542

1@obarakon I disagree. Code from the other challenge cannot be ported to this challenge with any ease. The challenges while the both involve infinite looping are fundamentally different. – Post Rock Garf Hunter – 2017-02-16T01:22:08.857

1

@obarakon Not a dupe of this question either, as it's not code-golf.

– Esolanging Fruit – 2017-02-16T01:24:33.570

2Related – Post Rock Garf Hunter – 2017-02-16T01:25:11.097

Does JIT compilation count as compilation? – Downgoat – 2017-02-16T03:19:33.223

@Downgoat I'd say so. – Esolanging Fruit – 2017-02-16T03:29:14.927

Related – R. Kap – 2017-02-16T05:23:56.447

Are answers valid which terminate eventually because the compiler runs out of memory/recursion depth? – Martin Ender – 2017-02-16T08:43:34.487

@MartinEnder Yes, edited. – Esolanging Fruit – 2017-02-16T08:47:33.270

1

I'm not sure it fits this challenge (and even if it does it would score terribly), but for those interested here's how I would do it in Java : define an annotation processor(ideone snippet) which you'll use when invoking javac with its -processor option. It makes the compilation of any class hang forever.

– Aaron – 2017-02-16T09:59:48.443

@Aaron there's shorter in vanilla Java 5+ without any custom annotation processor ;) – Olivier Grégoire – 2017-02-16T12:19:03.817

6For the answers that result in crashing the compiler: For the purpose of slacking, I would think you still want it to take as long as you can to crash. – GuitarPicker – 2017-02-16T17:43:47.707

1

If you want something minimal to tie up your printer as long as possible, try sending instructions to generate the mandlebrot set to your printer: https://www.mitchr.me/SS/exampleCode/postscript/mandelbrot.ps.html

– rjmunro – 2017-02-20T12:14:57.907

Must the implementation exist before this question? – PyRulez – 2017-06-27T00:52:35.970

@PyRulez Yes, as is standard with code-golf. If it did not, you must mark your answer as non-competing. – Esolanging Fruit – 2017-06-27T06:22:57.520

Answers

16

Japt, 2 bytes

`ÿ

You can test this online here, but I wouldn't recommend it as it will freeze your browser.

Explanation

Japt uses the shoco library for compressing strings. A backtick tells the compiler to decompress everything until the next backtick or the end of the file. Each byte does the following:

  • 00-7F are left intact.
  • 80-BF each transform into a common lowercase two-letter pair (at, oo, th, etc.).
  • C0-DF each consume the next byte and transform into a common four-letter string.
  • E0-EF each consume the next three bytes and transform into a "common" eight-letter string (starting at Whererer and going downhill from there).
  • F0-F7 break the decompressor, though it still returns everything up to the breaking byte.
  • F8-FF cause the decompressor to enter into an infinite loop. I'm not sure why this is, as I'm not very familiar with the inner workings of the shoco library (and the JavaScript code is completely unreadable), but it's quite handy in this case.

I don't believe there is any other way to mess with the Japt compiler, but you never know...

ETHproductions

Posted 2017-02-16T01:17:06.577

Reputation: 47 880

10What do you mean it's unreadable. Clearly you just aren't trying hard enough. – fəˈnɛtɪk – 2017-02-16T20:02:40.473

I wish there was an emscripten decompiler... – tbodt – 2017-02-16T20:50:45.403

58

TikZ (pdfTeX 3.14159265-2.6-1.40.17), 85 79 74 24 22 21 bytes

A bunch of bytes saved thanks to wchargin

One byte saved thanks to Chris H

\input tikz
\tikz\pic

I actually encountered this one by accident when I was working on homework. I spent quite a while waiting for it to compile before I realized what was happening.

This has two parts:

\input tikz

This loads the TikZ package

and:

\tikz\pic

This starts a \tikz environment and a draw command.

What is going on

The pdflatex compiler has trouble with \tikz\pic, and enters interactive mode causing it to stall indefinitely.

Post Rock Garf Hunter

Posted 2017-02-16T01:17:06.577

Reputation: 55 382

(1/2) I can't reproduce this. I get "Runaway argument? \draw l\end {document} ! File ended while scanning use of \tikz@next." pdflatex 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian). tikz 2010/10/13 v2.10. This is standard apt install texlive-full on Ubuntu 14.04. – wchargin – 2017-02-16T04:28:32.253

(2/2) That said, this can be reduced to an equivalent TeX program by stripping off the LaTeX cruft: \input tikz newline \tikz\draw l\bye (29 bytes). Confirm by replacing with \tikz\draw (0, 0) -- (1, 1);\bye and inspecting the output. – wchargin – 2017-02-16T04:30:19.273

1@wchargin I am using the same version of pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016) and it does indeed loop indefinitely. Thanks for the tips. – Post Rock Garf Hunter – 2017-02-16T04:55:39.140

I love these recent TikZ submissions. – Ian – 2017-02-16T08:40:35.227

1You can save a byte by using \pic instead of \draw` -- exactly the same behaviour (tested using tikz 1.142) – Chris H – 2017-02-16T14:23:43.027

@ChrisH Thanks I was trying to think of a three letter TikZ command. – Post Rock Garf Hunter – 2017-02-16T14:57:52.637

@WheatWizard while I'd been waiting for an excuse to use \pic until a couple of days ago

– Chris H – 2017-02-16T15:38:45.033

3I can't believe I'm actually advocating not using TikZ, but surely the use of it is overkill here. What's wrong with the old \def\a{\a}\a (12 bytes)? Or, as this is code golf and ~ is active by default, \def~{~}~ (9 bytes)? – Loop Space – 2017-02-16T18:42:34.920

2@LoopSpace Nothing is wrong with them I just didn't know the existed. If you would like to make your own answer then feel free. – Post Rock Garf Hunter – 2017-02-16T18:44:02.110

@WheatWizard Done. I wasn't sure if TikZ and TeX were close enough that they should be the same or separate answers. Plus I've never posted to this SE before so wasn't sure of the etiquette. – Loop Space – 2017-02-16T18:56:11.657

There's no error here; TeX is just waiting for more input (it puts you at the interactive * prompt). What makes you think the compiler is going on compiling forever? It's actually done processing whatever you gave it, and is idly waiting for more. – ShreevatsaR – 2018-03-28T21:41:20.423

@ShreevatsaR Thanks! I've updated the answer to reflect this. – Post Rock Garf Hunter – 2018-03-28T22:13:23.933

40

C, 18 bytes

#include __FILE__

Compilers will usually give up after recursing about 200 times.

Does DOM construction count as a compilation step? If so, then x.htm:

<iframe src=x.htm>

Neil

Posted 2017-02-16T01:17:06.577

Reputation: 95 035

14I remember that recursive framesets used to crash IE4 so hard that it sometimes took down important OS components with it. So the HTML there probably counts. – None – 2017-02-16T15:26:55.220

10@ais523, that's because, in the IE4 days, Internet Explorer was an "important OS component". – Mark – 2017-02-16T19:07:35.440

2A bit of tweaking and it is valid PHP: <?include __FILE__;. – Ismael Miguel – 2017-02-16T20:39:39.660

6Can't post this answer because my rep isn't high enough, but two alternatives are: #include "/dev/zero" and #include "/dev/stdin" -- be careful running the first one!! – rrauenza – 2017-02-17T18:31:26.217

When a page includes iframe which the same src as itself then about:blank is loaded. This would work, but it not counts as "compilation step": <iframe src=# onload=onload=this.src='?'+Date.now()> – Gustavo Rodrigues – 2017-02-18T18:37:25.303

1@rrauenza So I don't have to do something potentially dangerous to satisfy my curiosity, what does #include "/dev/zero" do? – Sompom – 2017-02-19T19:13:10.200

2When I tried it gcc's memory usage began quickly growing without bound, the system became unresponsive, and my watchdog eventually kicked in and rebooted. It was fairly amusing :) – rrauenza – 2017-02-20T02:10:13.577

39

Java, 102 95 89 88 78 bytes

class A<T>{}class B<T>extends A<A<?super B<B<T>>>>{A<?super B<A>>a=new B<>();}

This terminates with a StackOverflowError which happens because the generic resolution system can't decide a root against which to resolve the other generics.

Credits where due.

What happens here?

  1. A<T> is just there to have a 1-letter parent. It's generic. I could have used List, but the imports and repetition of 4 letters are too long.
  2. B<T> declares a basic generic.
  3. B extends A is required to have a hierarchy between B and A.
  4. extends A<A> creates a self reference on A<T>.
  5. A<? super B> triggers the lookup for generics on A<T>
  6. B<B<T>> creates a self-reference on B<T>.
  7. A<...> a=new B<>() forces the usage of the generics, instead of simply the definition of those, forcing the resolution when compiling B, and not afterwards.
  8. A<?super B creates a non-self-reference, so we have both a reference to one type and to another in the generics of A.
  9. B<A> creates a non-self-reference, so we have both a reference to one type and to another in the generics of B.

Now, the type A has generics type A and B, but which is to be chosen? Forget about self, let's try to resolve B. Ping.

Okay, B has generics type A and B, but which is to be chosen? Forget about self, let's try to resolve A. Pong.

This kind of recursion can't really be avoided because there are legitimate cases like A<B<A<B<A<B<Object>>>>>>: for example a JSON object: List<Map<String,Map<String,List<Map<String,List<String>>>>>>.

Compilation result

$ javac NoCompile.java


The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
        at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3260)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2587)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2579)
        at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)
        at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3260)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2592)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2579)
        at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)

On my system, the stack trace stops after showing 1024 lines, which are actually the 4 same lines repeated 256 times, thus proving an infinite recursion. I'll spare you that whole trace.

Savings

  1. 102 → 95 bytes: replaced interface+implements with class+extends.
  2. 95 → 89 bytes: replaced Long with A (twice).
  3. 89 → 88 bytes: used diamond operator (new B<A>()new B<>()) .
  4. 88 → 78 bytes: moved the variable declaration to a class member, thanks to VoteToClose.

Olivier Grégoire

Posted 2017-02-16T01:17:06.577

Reputation: 10 647

2What am I looking at – Addison Crump – 2017-02-20T14:26:44.183

You can shorten this to 78 bytes with: class A<T>{}class B<T>extends A<A<?super B<B<T>>>>{A<?super B<A>>b=new B<>();} – Addison Crump – 2017-02-20T14:44:49.810

@VoteToClose You're looking at a prime example of undecidability in Java's generics. Each generic is supposed to be resolved against a common root to which is then a validated against. The thing here is that the generic of B contains a undecidable reference to the generic of A which in turn contains an undecidable reference to the generic of B. When the resolver can't decide, it checks included references, but here both generics refer to each other in an undecidable way (mostly thanks to self references and the super keyword. So the resolver actually ping-pongs between the two generics. – Olivier Grégoire – 2017-02-21T02:14:05.997

I was thinking about creating a compile-time problem with cyclical annotations: public @interface X {@X(x=X.class)Class<? extends X> x();}... But I quickly realized why that wouldn't work lol. – Magic Octopus Urn – 2017-05-16T18:35:37.413

34

GNU Makefile, 8 7 bytes

One byte saved thanks to KonradRudolph

Saved as Makefile and invoked by make:

x:;make

This will produce an infinite build recursion on the first target found "x".

Needless to say that you don't really want to run this fork bomb on your production server. :-)

make
make[1]: Entering directory `/path/to/my/dir'
make
make[2]: Entering directory `/path/to/my/dir'
make
make[3]: Entering directory `/path/to/my/dir'
make
make[4]: Entering directory `/path/to/my/dir'
make
make[5]: Entering directory `/path/to/my/dir'
make
make[6]: Entering directory `/path/to/my/dir'
make
make[7]: Entering directory `/path/to/my/dir'
make
...

Alternate version, 5 bytes

Suggested by KonradRudolph:

x:;$_

$_ is a reference to the last argument of the previous command. More specifically, it is resolved here as the absolute path to the command being executed -- which is make itself.

This should work fine in a genuine Bash environment, but not on Windows+MinGW.

Arnauld

Posted 2017-02-16T01:17:06.577

Reputation: 111 334

2Hmm, I don't think make does really compile the Makefile (it just interprets it). – zeppelin – 2017-02-16T08:44:10.360

3@zeppelin You're right, this is probably a borderline answer. That said, submissions that involved macro recursion at the preprocessor level will never start to compile any actual code either. – Arnauld – 2017-02-16T08:52:07.410

12It fits the intended goal: having an infinite build process. +1! – YSC – 2017-02-16T09:32:38.940

24

C++, 60 58

template<class T>class a{a<T*>operator->();};a<int>i=i->b;

This recursivly creates instances of class a with different template parameters. GCC 7.0 stops after 900 recursion levels with tons of errors about operator-> being private but for example ICC 17 and Microsoft (R) C/C++ Optimizing Compiler 19 time out on godbolt.

Problem with that is that probably all compilers will run out of memory at some point in time so even without recursion limits this will stop. The same probably applies to the Clojure answer, too.

Edit: 2 bytes saved by bolov - Thanks

Christoph

Posted 2017-02-16T01:17:06.577

Reputation: 1 489

1shorter: a<int>i=i->b; – bolov – 2017-02-16T09:45:23.430

Interestingly g++-6.3.1 fails painfully on this, but fails a lot more gracefully if you replace class with struct. – Pockets – 2017-02-19T05:55:20.530

1@Pockets like I stated in my answer that's because the operator-> is defaulted private within a class. Within a struct it's public and therefore i->b may access it. – Christoph – 2017-02-20T06:32:09.380

1gcc 4.4.7 seems to hang indefinitely here. Waiting for infinity or for it to show output, whichever comes first. Will update – osuka_ – 2017-05-17T06:21:55.797

1@osuka_ is it still running? – Christoph – 2018-02-13T07:07:17.920

1@Christoph nope, it crashed with a SIGSEGV after I left it running for a couple days. Forgot to update, though - thanks for the reminder! – osuka_ – 2018-02-13T07:18:20.060

23

Perl, 15 13 bytes

BEGIN{{redo}}

Try it online!

Now with 2 bytes saved: @Zaid reminded me of a terser way to do a loop in Perl.

This is pretty simple: it just installs a parser hook with an infinite loop in, making the code take infinitely long to parse. (Perl's nice in that it allows you to run arbitrary code in the middle of the parse; the parser hooks are specified in Perl itself, and frequently used to do things like import libraries or change the parsing rules for an identifier you want to treat like a keyword.) The Try it online! link above gives the -c option (to compile the code to verify the syntax for correctness, but not run it), to prove that the infinite loop happens at compile time.

In case you're wondering about "compile time" in a scripting language: Perl actually compiles to bytecode and then runs the bytecode, but this is a detail that's rarely relevant when programming it. The -MO= command line option family can be used to do things with the bytecode other than running it (although not with this program, as the infinite loop happens before the bytecode can be generated).

user62131

Posted 2017-02-16T01:17:06.577

Reputation:

1a:goto a looks nice too (same bytecount sadly). – Dada – 2017-02-16T08:14:01.453

3BEGIN{{redo}} will save you a few bytes – Zaid – 2017-02-16T11:38:50.723

20

C++, 37 30 29 bytes

int f(auto p){f(&p);},a=f(0);

It uses the future auto function parameter. It was proposed into C++17, but I don't think it made it. gcc however supports it as an extension.

Basically

void foo(auto p);

is equivalent to

template <class T>
void foo(T p);

The code tries to instantiate f recursively with different template arguments. gcc fails with

fatal error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum)

With -ftemplate-depth=10000 I got it to spit "Killed - processing time exceeded" on godbolt.

Check it on godbolt


1 byte saved by Quentin. Thank you.

bolov

Posted 2017-02-16T01:17:06.577

Reputation: 465

1One byte can be saved by using int as the return type :) – Quentin – 2017-02-16T15:46:23.797

Indeed, auto function parameters didn't make it into C++17; and also int f() { ... }, a; isn't a legal declaration last time I checked. (You can't mix function declarations with variable declarations like that.) What you've got here is an extremely GCC-specific dialect of C++. Not that there's anything wrong with that in this context. :) – Quuxplusone – 2017-02-20T09:30:15.770

19

Common Lisp, 8 bytes

#.(loop)

The compiler will try to read a form and will encounter the sharpsign-dot reader macro, which evaluates code at read time and uses its result as the form to compile. Here, the code being executed is an infinite loop.

coredump

Posted 2017-02-16T01:17:06.577

Reputation: 6 292

17

TeX, 9 bytes

\def~{~}~

TeX works by expanding macros. Most of the time, TeX's macros (also called control sequences) are of the form \name but it is also possible to define certain characters as macros, these are called active characters. The character ~ is active by default in plain TeX and so can be used as a macro name without further declaration. The \def~{~} in the above defines ~ so that it expands to ~. That is, whenever TeX encounters ~ then it replaces it by ~ and then re-examines the replacement, meaning that it encounters a wholly new occurrence of ~ and replaces that by ~. This defines the infinite loop. All that is then needed is to start the loop and that's what the final ~ does.


Added in edit

To make this properly compiled, invoke as:

pdftex -ini "&pdftex \def~{~}~"

The -ini flag says that pdftex should compile a new format file. This is a precompiled set of definitions which can be loaded when TeX is later invoked to speed up processing a document (LaTeX2e is an example of this). I guess that the &pdftex adds a few bytes, taking the total to 17.

Loop Space

Posted 2017-02-16T01:17:06.577

Reputation: 271

Does this happen at compile time? The question requires the infinite loop to happen while compiling, not when running. – None – 2017-02-16T19:21:33.443

@ais523 Hadn't fully thought about that bit. I was riffing off the TikZ answer. I've added an alternative that is definitely compiled, at the expense of a few more bytes. – Loop Space – 2017-02-16T19:41:26.150

2@ais523: As always, "compiling" and "running" are two sides of the same coin. Personally, I think of TeX source code as "compiling" into PDF documents (which are then "executed" by viewing), in the same way that C++ source code is "compiled" into .exe files (which are then "executed" by running). But you could also think of the pdftex program as "interpreting" TeX input to produce a PDF as "output" — in the same way that the g++ program "interprets" C++ input to produce an .exe file as "output". ;) – Quuxplusone – 2017-02-20T09:35:07.793

14

Haskell, 25+17=42 bytes

a= $(let a='a':a in[|a|])

A simple Haskell metaprogram which defines an infinite value and attempts to compute that value at compile time.

Invoke with ghc -XTemplateHaskell <file.hs> (+17 for the parameter to the compiler)

user2407038

Posted 2017-02-16T01:17:06.577

Reputation: 378

Does $(let a=a in a) not work (for 32 bytes)? – Ry- – 2017-02-20T03:45:09.007

1Nope! GHC is too smart. Any infinite loop of the form let a = a in a gets rewritten to an exception, which simply causes a compiler error as opposed to an infinite loop. (although perhaps this would work with a different Haskell compiler, but I don't have one on hand to try) – user2407038 – 2017-02-20T08:13:56.530

It works with runghc for me, so I’d say it’s valid. (Actually, it works with ghc, too. 8.0.1 here.) – Ry- – 2017-02-20T08:29:44.260

Really? I'm on ghc 8.0.1 as well - for me it gives Exception when trying to run compile-time code: <<loop>>, both in the interpreter and when compiling... technically the code above dies with an exception as well, but a stack overflow, which is explicitly allowed by the spec - and if you had infinite memory, it would really loop forever. The <<loop>> exception fires far before my machine runs out of memory. – user2407038 – 2017-02-20T08:39:32.177

12

gradle, 10 9 bytes

for(;;){}

with the above code placed in a build.gradle file. Gradle uses groovy as its base language so we are really talking about groovy here, but as the question was about build time I figured gradle would be more appropriate.

Running any gradle build commands with the above code prints the pointy-haired-boss-compatible build status line:

$ gradle tasks
> Configuring > 0/1 projects > root project

if you are aiming for a raise, add the debug -d flag for:

$ gradle -d tasks
14:56:25.522 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized native services in: .gradle/native
14:56:25.757 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Executing build 84908c0d-f28d-4c57-be61-40eaf0025e16.1 in daemon client {pid=27884}
14:56:25.761 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface tun0
14:56:25.762 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
14:56:25.762 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? false
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x:x:x:x:x:x:%tun0
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x.x.x.x
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface eth1
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? true
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x:x:x:x:x:x:%eth1
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x.x.x.x
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote multicast interface eth1
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface lo
<snip>
14:57:07.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
14:57:07.056 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
14:57:07.056 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
14:57:07.056 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
> Configuring > 0/1 projects > root project

which in addition to looking impressively complicated also updates with a new set of:

15:07:57.054 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
15:07:57.054 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:07:57.054 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.

status lines every 10 seconds making it look like the build is busy doing important technical...stuff.

Matias Bjarland

Posted 2017-02-16T01:17:06.577

Reputation: 420

8

SWI-Prolog, 34 bytes

term_expansion(_,_):-repeat,1=0.

Explanation

term_expansion/2 is something that gets called automatically by the compiler before actually compiling code to transform some terms in the source code into other terms.

Here, we introduce a new rule for term_expansion/2: repeat,1=0..

repeat/0 is a predicate which always succeeds, and provides an infinite number of choice points.

1=0 is trying to unify 1 with 0, which is always false. This will cause the compiler to backtrack to repeat (since it always provides a choice point) and try 1=0 again, etc.

Fatalize

Posted 2017-02-16T01:17:06.577

Reputation: 32 976

Doesn't work in GNU Prolog, so I'm assuming this is implementation-specific. You might want to put the name of a compiler in the heading. (I'm assuming SWI Prolog.) – None – 2017-02-16T15:25:47.413

@ais523 Thanks, didn't check on other distribs, but since compiler stuff is usually pretty specific, I should have known better... – Fatalize – 2017-02-16T15:28:03.903

@ais523 However according to this, you might be able to use expand_term instead (as it says term_expansion cannot be used like here in GNU Prolog). It doesn't work with expand_term on SWI though.

– Fatalize – 2017-02-16T15:30:07.057

7

GNU Make, 44

.PHONY:x
$(MAKEFILE_LIST):x;sleep 1;touch $@

I can't claim credit for this. It is derived from Robert Mecklenburg's book Managing Projects with GNU Make: The Power of GNU Make for Building Anything.

When make executes this makefile, it sees the makefile is out of date (because the .PHONY target is out of date, so it executes the touch command, which updates the timestamp of the makefile. Then make re-reads the file and discovers the makefile is out of date.... Well you get the idea.

I prefer this to the other Make answer because it does not use recursion. On my VM, the other Make answer continues forking processes and at somewhere around 7,000 deep, the VM grinds to an unresponsive halt. However, with this answer it is able to continue indefinitely without eating up system resources. You really will be able to slack off with this build. I've gone over 1,000,000 iterations with no apparent system degradation.

Note I had to add the sleep 1 so that the makefile timestamp is actually updated every time. You can change this to sleep 0.01 if you want it to burn through iterations a bit faster.

Digital Trauma

Posted 2017-02-16T01:17:06.577

Reputation: 64 644

6

GNU Forth, 15 bytes

Golfed

: : [do] [loop]

Re-defines (re-compiles) the word : and invokes an immediate infinite loop [do] [loop] inside the new definition (right at the compile time).

One category of words don't get compiled. These so-called immediate words get executed (performed now) regardless of whether the text interpreter is interpreting or compiling.

Try It Online !

zeppelin

Posted 2017-02-16T01:17:06.577

Reputation: 7 884

5

Clojure, 21 bytes

(defmacro a[]`(a))(a)

Ties up the compiler by defining a macro that repeatedly emits calls to itself.

On my phone, this causes the REPL to hang and lag the device. On my laptop, this fails outright with a StackOverflow.

Unfortunately the StackOverflow happens instantly, but it's still valid according to the rules.

Carcigenicate

Posted 2017-02-16T01:17:06.577

Reputation: 3 295

5

MSBuild, 130 bytes

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="X">
        <Exec Command="msbuild"/>
    </Target>
</Project>

Save this as a file with .proj extension, and run with msbuild from the command prompt. MSBuild will run its only target which simply spawns another msbuild process.

Danko Durbić

Posted 2017-02-16T01:17:06.577

Reputation: 10 241

Is the indentation required for this to work? What about the newlines? It's normally possible to golf out whitespace. – None – 2017-02-16T15:28:04.737

No, it's just easier to read. The character count doesn't include whitespace. – Danko Durbić – 2017-02-16T15:45:43.133

1Ah right. In that case you should probably mention that in the body of the post. – None – 2017-02-16T15:55:00.283

5

Haskell (GHC, without Template Haskell or custom rewrite rules), 138

{-#LANGUAGE FlexibleContexts,UndecidableInstances#-}
data A x=A
class C y where y::y
instance C(A(A x))=>C(A x)where y=A
main|A<-y=pure()

Theoretically, this enters an infinite loop in much the same way the C++ approach does: the polymorphic method y is instantiated to ever more convoluted types. In practice, the default allotted stack size actually overflows quickly:

$ ghc-7.10 wtmpf-file14146.hs 
[1 of 1] Compiling Main             ( wtmpf-file14146.hs, wtmpf-file14146.o )

wtmpf-file14146.hs:5:9:
    Context reduction stack overflow; size = 101
    Use -fcontext-stack=N to increase stack size to N
      C (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A t0))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
    In a stmt of a pattern guard for
                   an equation for ‘main’:
      A <- y
    In an equation for ‘main’: main | A <- y = pure ()

Credits to Luke Palmer.

ceased to turn counterclockwis

Posted 2017-02-16T01:17:06.577

Reputation: 5 200

5

C, 31 bytes

main[-1llu]={1};

Inspired by Digital Trauma. Compile with the -mcmodel=medium flag.

Good luck compiling this, you'll need 1.8 yottabytes of RAM and disk space.

MD XF

Posted 2017-02-16T01:17:06.577

Reputation: 11 605

4

Mathematica 33 Bytes

Compile[{},Evaluate@While[True,]]

The code will attempt to symbolically evaluate the argument prior to compilation, and the argument itself is an infinite loop. The While function has a null second argument since it's not important.

Kelly Lowder

Posted 2017-02-16T01:17:06.577

Reputation: 3 225

"prior to compilation" Yeah...no. – CalculatorFeline – 2017-05-22T23:28:50.380

Please provide a valid argument. https://reference.wolfram.com/language/tutorial/CompilingWolframLanguageExpressions.html

– Kelly Lowder – 2017-05-23T03:17:59.993

The question is, does the loop happen during the Compile call or before it? – CalculatorFeline – 2017-05-23T04:27:48.620

3

Rust, 18 bytes

include!(file!());

Classic self-include. Rustc is annoyingly sane though, and by default will bail out after 128 recursions, and it expands depth-first so exponential growth doesn't work either. The same applies to the C and C++ solutions though.

CensoredUsername

Posted 2017-02-16T01:17:06.577

Reputation: 951

2

Boo, 25 bytes

macro l:
 x=0 while 1>0
l

This defines a macro, which executes at compile time, which executes an infinite loop, and then invokes the macro.

Mason Wheeler

Posted 2017-02-16T01:17:06.577

Reputation: 1 254

1

Haskell (ghc), 32 + 2 = 34 bytes

{-#RULES""main=main#-}
main=main

run with ghc -O <file>. Triggers a rewrite rule for the main function which rewrites to the same thing. The only unfortunate feature is that ghc is smart enough to detect this and stop after 100 iterations. I don't know of an easy way to disable this behavior.

Program man

Posted 2017-02-16T01:17:06.577

Reputation: 531

1

PHP, 19 bytes

<?include __FILE__;

MD XF

Posted 2017-02-16T01:17:06.577

Reputation: 11 605

0

Factor, 29 16

<< [ t ] loop >>

The part between << >> is executed at parse time.

As for what [ t ] loop does, I'll let you guess...

You can put that in the Listener as is, or add it to any vocabulary or script file with the corresponding boilerplate stuff.

fede s.

Posted 2017-02-16T01:17:06.577

Reputation: 945