mnba / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

itertools.permutations() segfault #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I tried to compile this simple program, which is (I guess), the simplest
case possible of using permutations:

from itertools import permutations

l = [1, 2, 3]
for x in permutations(l):
    print x[0]

It compiles without warnings, but segfaults at the "print x[0]" line. I
tried debugging it with gdb, but it wasn't much help because when it
segfaults the x object is already compromised. I hope someone can at least
reproduce it and it's not some sort of problem on my machine...

Original issue reported on code.google.com by fet...@gmail.com on 9 May 2010 at 1:12

GoogleCodeExporter commented 9 years ago
Hi, thanks for reporting.

Unfortunately, I cannot reproduce the crash on my current machine, so I'll try 
again
at the end of the week on another computer.

What version of shedskin do you use? Did you try the latest svn version?

Best regards,

Original comment by arkanosis on 11 May 2010 at 11:41

GoogleCodeExporter commented 9 years ago
I can't reproduce it here either (64-bit ubuntu 10.04).. this at least works 
fine
(identical results):

import random
random.seed(42)

from itertools import permutations

for x in range(1000000):
    l = range(random.randrange(5))
    for y in permutations(l):
        print y

Original comment by mark.duf...@gmail.com on 11 May 2010 at 12:57

GoogleCodeExporter commented 9 years ago
Oh well, after a lot of debugging, I found what the problem was:

template<class T> T __iter<T>::__get_next() {
    try {
        __result = this->next();
        return __result;
    }
    catch (StopIteration *) {
        __stop_iteration = true;
    }   
}

Moving the "return __result" line off the try block did the trick, although I 
think
both code snippets should be functionally equivalent -- probably a compiler 
error.
Anyway, it's not a SS problem, so you can close this...

Original comment by fet...@gmail.com on 11 May 2010 at 6:03

GoogleCodeExporter commented 9 years ago
woah, thanks for looking into this! I will make sure the next shedskin release 
for
windows is based on a more recent MinGW, so hopefully this problem will be 
gone..

jeremie, can I close this issue..?

Original comment by mark.duf...@gmail.com on 11 May 2010 at 7:05

GoogleCodeExporter commented 9 years ago
Thanks fetofs !

Yeah, it looks like the problem is the C++ compiler so the issue may be closed 
:-)

Best regards,

Original comment by arkanosis on 12 May 2010 at 9:08

GoogleCodeExporter commented 9 years ago
thanks guys

Original comment by mark.duf...@gmail.com on 12 May 2010 at 9:11