Блог пользователя Little_Sheep_Yawn

Автор Little_Sheep_Yawn, история, 12 месяцев назад, По-английски

In recent competitions, I came across this type of RUNTIME ERROR. Here's the thing:

I wrote a program like this:

def main():
    k = 15
    m = 3
    
    for a in range(k + 1):
        for b in range(k + 1):
            for c in range(min(m, k) + 1):
                for d in range(min(m, k) + 1):
                    continue
    return

t = 1
for _ in range(t):
    main() 

But in Atcoder, it showed something like this: (Sorry that the picture isn't clear enough)

It really bothered me and I wonder if anyone could be so kind as to help me with this issue.

(p.s. The RUNTIME ERROR doesn't show in Codeforces, so I'm really confused)

Here are some codes that don't show RUNTIME ERROR:

Code 1:

k = 15
m = 3

for a in range(k + 1):
    for b in range(k + 1):
        for c in range(min(m, k) + 1):
            for d in range(min(m, k) + 1):
                pass

Code 2:

def main():
    k = 15
    m = 3
    
    for a in range(k + 1):
        for b in range(k + 1):
            for c in range(min(m, k) + 1):
                for d in range(min(m, k) + 1):
                    print(d)
    return

t = 1
for _ in range(t):
    main()
  • Проголосовать: нравится
  • +45
  • Проголосовать: не нравится

»
12 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I would also be very grateful if anyone could help me propose an issue to Pypy through this website: https://foss.heptapod.net/pypy/pypy/-/issues. (according to this: https://www.pypy.org/contact.html) (I couldn't get access to the issue tracker)

  • »
    »
    12 месяцев назад, # ^ |
      Проголосовать: нравится +9 Проголосовать: не нравится

    Did you try reproducing this error locally? Pinging our resident Python expert pajenegod as he might be interested and able to help, since he's quite active there (sorry for the ping if this is not the case).

    • »
      »
      »
      12 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Thanks a lot! In my computer, this program also terminated with abnormally and there wasn't any error messages printed. But some of my friends didn't see that and the program worked out just fine.

      So I think it might have something to do with what kind of system you run the program on.

»
12 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I can reproduce this with PyPy 7.3.13 on Linux. The program triggers a segmentation fault.

I've posted the program on their issue tracker.

»
12 месяцев назад, # |
Rev. 3   Проголосовать: нравится +26 Проголосовать: не нравится

I'm also able to reproduce this segfault locally on my Windows computer. Even something as simple as this segfaults

def f():
    m = 3
    for a in range(100):
        for b in range(m + 1):
            for c in range(m + 1):
                pass
f() 

It is impressive how such a simple piece of Python code can cause a segfault. Probably it is triggering some bug in PyPy's JIT.