Compiler crash in AnalyseExpressionsTransform

673 views
Skip to first unread message

Prashant

unread,
Mar 23, 2011, 12:59:36 AM3/23/11
to cython...@googlegroups.com
Hi,

Python 2.6.2
cython 0.14.1
xp 32 bit

I am compiling a python module (aes encryption) using cython for speed gain. You
can find more about this algorithm here:
http://wiki.birth-online.de/snippets/python/aes-rijndael

The code is using a line:
urs( int( float(b+1)/0x100000000-1 ), c*8) & 0xff

Cython's compiler is getting crashed while converting this line.

Any pointers for solving this problem?

Prashant

Stefan Behnel

unread,
Mar 23, 2011, 3:55:57 AM3/23/11
to cython...@googlegroups.com
Prashant, 23.03.2011 05:59:

> Python 2.6.2
> cython 0.14.1
> xp 32 bit
>
> I am compiling a python module (aes encryption) using cython for speed gain.
> You
> can find more about this algorithm here:
> http://wiki.birth-online.de/snippets/python/aes-rijndael
>
> The code is using a line:
> urs( int( float(b+1)/0x100000000-1 ), c*8)& 0xff

>
> Cython's compiler is getting crashed while converting this line.
>
> Any pointers for solving this problem?

First of all: please always provide the stack trace when reporting compiler
crashes. Then, please add a ticket for this to the bug tracker.

Thanks,

Stefan

Prashant

unread,
Mar 26, 2011, 6:33:17 AM3/26/11
to cython...@googlegroups.com, Stefan Behnel
Here is the stack trace:

ModuleNode.body = StatListNode(aes.py:11:0)
StatListNode.stats[17] = StatListNode(aes.py:187:0)
StatListNode.stats[0] = DefNode(aes.py:187:0,
    modifiers = [...]/0,
    name = u'decrypt',
    num_required_args = 3,
    reqd_kw_flags_cname = '0')
File 'Nodes.py', line 343, in analyse_expressions: StatListNode(aes.py:188:4)
File 'Nodes.py', line 4293, in analyse_expressions: ForInStatNode(aes.py:213:4)
File 'Nodes.py', line 343, in analyse_expressions: StatListNode(aes.py:214:8)
File 'Nodes.py', line 4293, in analyse_expressions: ForInStatNode(aes.py:215:8)
File 'Nodes.py', line 343, in analyse_expressions: StatListNode(aes.py:215:93)
File 'Nodes.py', line 3269, in analyse_expressions: SingleAssignmentNode(aes.py:
215:93)
File 'Nodes.py', line 3360, in analyse_types: SingleAssignmentNode(aes.py:215:93
)
File 'ExprNodes.py', line 5173, in analyse_types: IntBinopNode(aes.py:215:93,
    infix = True,
    operator = u'&',
    use_managed_ref = True)
File 'ExprNodes.py', line 2708, in analyse_types: SimpleCallNode(aes.py:215:53,
    use_managed_ref = True)
File 'ExprNodes.py', line 3778, in analyse_types: TupleNode(aes.py:215:53,
    is_sequence_constructor = 1,
    use_managed_ref = True)
File 'ExprNodes.py', line 3574, in analyse_types: TupleNode(aes.py:215:53,
    is_sequence_constructor = 1,
    use_managed_ref = True)
File 'ExprNodes.py', line 2708, in analyse_types: SimpleCallNode(aes.py:215:58,
    use_managed_ref = True)
File 'ExprNodes.py', line 3778, in analyse_types: TupleNode(aes.py:215:58,
    is_sequence_constructor = 1,
    use_managed_ref = True)
File 'ExprNodes.py', line 3574, in analyse_types: TupleNode(aes.py:215:58,
    is_sequence_constructor = 1,
    use_managed_ref = True)
File 'ExprNodes.py', line 5173, in analyse_types: SubNode(aes.py:215:82,
    infix = True,
    operator = u'-',
    use_managed_ref = True)
File 'ExprNodes.py', line 5446, in analyse_types: DivNode(aes.py:215:70,
    infix = True,
    operator = u'/',
    use_managed_ref = True)
File 'ExprNodes.py', line 5173, in analyse_types: DivNode(aes.py:215:70,
    infix = True,
    operator = u'/',
    use_managed_ref = True)
File 'ExprNodes.py', line 5287, in analyse_c_operation: DivNode(aes.py:215:70,
    infix = True,
    operator = u'/',
    use_managed_ref = True)
File 'ExprNodes.py', line 807, in coerce_to: IntNode(aes.py:215:71,
    constant_result = 4294967296L,
    is_literal = 1,
    longness = '',
    unsigned = '',
    use_managed_ref = True,
    value = u'0x100000000')

Compiler crash traceback from this point on:
  File "C:\Python26\lib\site-packages\Cython\Compiler\ExprNodes.py", line 811, i
n coerce_to
    float_value = float(self.value)
ValueError: invalid literal for float(): 0x100000000
building 'aes' extension

Robert Bradshaw

unread,
Mar 27, 2011, 1:39:24 AM3/27/11
to cython...@googlegroups.com

Looks like a bug, but I'm unable to reproduce this, but don't know
what urs, b, or c are. could you whittle this down to a self-contained
snippet?

- Robert

Stefan Behnel

unread,
Mar 29, 2011, 2:58:34 AM3/29/11
to cython...@googlegroups.com
Prashant, 26.03.2011 11:33:

> Here is the stack trace:
>[...]

> File 'ExprNodes.py', line 807, in coerce_to: IntNode(aes.py:215:71,
> constant_result = 4294967296L,
> is_literal = 1,
> longness = '',
> unsigned = '',
> use_managed_ref = True,
> value = u'0x100000000')
>
> Compiler crash traceback from this point on:
> File "C:\Python26\lib\site-packages\Cython\Compiler\ExprNodes.py", line
> 811, i
> n coerce_to
> float_value = float(self.value)
> ValueError: invalid literal for float(): 0x100000000

Ok, this indicates that the crash is happening while coercing a hex integer
constant to a float value. Looking through the latest code, ISTM that this
has been fixed already. Could you try the latest github version?

Stefan

Prashant

unread,
Apr 7, 2011, 3:02:45 AM4/7/11
to cython...@googlegroups.com
Hi Robert,
Sorry for the delay. Here is the zip containing all the files.
pyAES.zip

Prashant

unread,
Apr 18, 2011, 6:09:59 AM4/18/11
to cython...@googlegroups.com
Ok, I found a solution:

1 Change this line:

urs( int( float(b+1)/0x100000000-1 ), c*8) & 0xff
into
urs( int( float(b+1)/5126-1 ), c*8) & 0xff

2. build module using cython. It'll build without any problem.

3. Open aes.c file generated during process

4. find "5126" in aes.c file

5. Change "5126" to "0x100000000LL".

6. build module using aes.c file

Hope you'll fix this in next version...:-). This is related to conversion of unsigned long int constant.

Prashant

Robert Bradshaw

unread,
Apr 18, 2011, 4:38:58 PM4/18/11
to cython...@googlegroups.com
On Mon, Apr 18, 2011 at 3:09 AM, Prashant <anima...@gmail.com> wrote:
> Ok, I found a solution:
>
> 1 Change this line:
> urs( int( float(b+1)/0x100000000-1 ), c*8) & 0xff
> into
> urs( int( float(b+1)/5126-1 ), c*8) & 0xff
>
> 2. build module using cython. It'll build without any problem.
>
> 3. Open aes.c file generated during process
>
> 4. find "5126" in aes.c file
>
> 5. Change "5126" to "0x100000000LL".
>
> 6. build module using aes.c file
>
> Hope you'll fix this in next version...:-).

IIRC, this was fixed. Could you try out the branch at
https://github.com/cython/cython/ and let us know if it works for you?

Thanks,
Robert

Reply all
Reply to author
Forward
0 new messages