Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shortest program that will crash Mata or Stata?

    Dear Mata users:

    If you have nothing better to do on a Friday afternoon, or have something better to do, but don't want to do it, why not try to think of the shortest program that crashes Stata/Mata.

    This is the smallest one I can think of:
    Code:
    mata: void x(y) x(y)
    mata: x(1)
    Is it possible there is a shorter one?

    Best,

    Matt

  • #2
    Hi Matt
    I don't think I can do better (or worse)
    But I'm interested in short ways of writing simple functions.
    And your post inspired me to:
    Code:
    : mata clear
    : real f(x) (1/x)
    : f(0)
      .
    : f(2)
      .5
    Thank you
    Kind regards

    nhb

    Comment


    • #3
      @Matt: But in Stata 14, your code is not causing mata/Stata to crash. Instead I am getting a long list of:
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      x(): - function returned error
      <istmt>: - function returned error
      Anyways here's my code - bound to work:
      mata:
      while (1) {
      }

      Comment


      • #4
        Niels and Sarwik --

        First, it's nice to know other people think about these sorts of things too. I am curious why my code doesn't work on Stata 14 - I'm using Stata 12. A never-ending loop beats an infinite recursion in Stata 14.

        But here is an oddity - when I run Sarwik's code in Stata 12, Stata seizes, but doesn't crash. It just keeps going until I press break, while at the same time, my code causes Stata to crash and exit. I'm curious what is behind these subtle differences in the way Stata and Mata operate.

        Best,

        Matt

        Comment

        Working...
        X