Export to GitHub

shedskin - issue #204

__wrap causes core dump instead of 'index out of range' on empty list


Posted on Sep 3, 2014 by Quick Horse

Not restricted to a cygwin-32 installation on Win7/64, but that's my setup with shedskin-0.9.4.exe. To work around compilation issues just $ touch execinfo.h You will loose debugging possibilities but get it to work.

$ cat > wrap_check.py << EOF l = [] print l[-1] EOF $ shedskin wrap_check.py $ make $ ./wrap_check Segmentation fault (core dumped)

This is expected: $ ./wrap_check.exe IndexError: index out of range

The bug is easy to fix in site-packages/shedskin/lib/builtin.hpp:__wrap template<class T> static inline int __wrap(T a, int i) { #ifndef __SS_NOWRAP - if(i<0) return len(a)+i; + if(i<0) i += len(a); #endif #ifndef __SS_NOBOUNDS if(i<0 || i>= len(a)) __throw_index_out_of_range(); #endif return i; }

This way the bounds checking is still done.

Comment #1

Posted on Sep 4, 2014 by Happy Camel

good catch, thanks a lot :)

please let me know under which name to commit your patch.

Comment #2

Posted on Sep 4, 2014 by Quick Horse

You're welcome. Please use 'Joerg Stippa '.

And if I can be of any help for getting shedskin to work under cygwin let me know. It just doesn't work out of the box :)

Comment #3

Posted on Sep 6, 2014 by Happy Camel

okay committed. thanks again! I hope to do another (very minor) release in a few weeks.

please note that in issue 193, another user is working on running shedskin under cygwin. if you'd be interested perhaps you could join forces..?

Status: Fixed

Labels:
Type-Defect Priority-Medium