Re: [cdt-dev] Infinite loop problem

Example of code from zend_API.c, line 3606:
property_info = pemalloc(sizeof(zend_property_info), 1); // <- This line causes a infinite loop!

#define pemalloc(size, persistent) ((persistent)?__zend_malloc(size):emalloc(size))

# define ZEND_ALLOCATOR(size) \
ZEND_MM_BINS_INFO(_ZEND_BIN_ALLOCATOR_SELECTOR_START, size, y) \
((size <= ZEND_MM_MAX_LARGE_SIZE) ? _emalloc_large(size) : _emalloc_huge(size)) \
ZEND_MM_BINS_INFO(_ZEND_BIN_ALLOCATOR_SELECTOR_END, size, y)

# define _emalloc(size) \
(__builtin_constant_p(size) ? \
ZEND_ALLOCATOR(size) \
: \
_emalloc(size) \
)

/* num, size, count, pages */
#define ZEND_MM_BINS_INFO(_, x, y) \
_( 0,    8,  512, 1, x, y) \
_( 1,   16,  256, 1, x, y) \
_( 2,   24,  170, 1, x, y) \
_( 3,   32,  128, 1, x, y) \
_( 4,   40,  102, 1, x, y) \
_( 5,   48,   85, 1, x, y) \
_( 6,   56,   73, 1, x, y) \
_( 7,   64,   64, 1, x, y) \
_( 8,   80,   51, 1, x, y) \
_( 9,   96,   42, 1, x, y) \
_(10,  112,   36, 1, x, y) \
_(11,  128,   32, 1, x, y) \
_(12,  160,   25, 1, x, y) \
_(13,  192,   21, 1, x, y) \
_(14,  224,   18, 1, x, y) \
_(15,  256,   16, 1, x, y) \
_(16,  320,   64, 5, x, y) \
_(17,  384,   32, 3, x, y) \
_(18,  448,    9, 1, x, y) \
_(19,  512,    8, 1, x, y) \
_(20,  640,   32, 5, x, y) \
_(21,  768,   16, 3, x, y) \
_(22,  896,    9, 2, x, y) \
_(23, 1024,    8, 2, x, y) \
_(24, 1280,   16, 5, x, y) \
_(25, 1536,    8, 3, x, y) \
_(26, 1792,   16, 7, x, y) \
_(27, 2048,    8, 4, x, y) \
_(28, 2560,    8, 5, x, y) \
_(29, 3072,    4, 3, x, y)
....

2015-11-25 13:38 GMT-02:00 Alisson Linhares :
Hi guys, I am having a strange behavior with CDT. The method getExpressionType, in CASTUnaryExpression.java, is entering into an infinite loop for some complex expressions.

To see this behavior, you can use PHP project, more precisely this file: https://github.com/php/php-src/blob/master/Zend/zend_API.c#L3606 and put this line inside the getExpressionType method: System.out.println( this.getRawSignature() );

This is my visitor:
public class DemoVisitor extends ASTVisitor {
public Demo() {
shouldVisitExpressions = true;
}

public int visit( IASTExpression _expression_ ) {
System.out.println( _expression_.getExpressionType() ); // Prints the type of an _expression_
return PROCESS_CONTINUE;
}
}

ps.: I think this problem may be related to C/C++ macro expansions, because it only happens when we try to parse complex macro "expressions". Has anyone ever had a similar problem?