Opened 4 years ago

Closed 3 years ago

#38 closed defect (fixed)

Resolver error with strdup from string.h

Reported by: ajbeach Owned by:
Priority: minor Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

So really hard to track down error.

This crashes:

#include <string.h>

void num_error_msg() {
    strdup( "" );
}

But if I replace the include with a forward declaration of strdup it works:

extern "C" {
extern char *strdup (const char *__s)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__))
__attribute__ ((__nonnull__ (1)));
}

I did everything I could to revert back to the standard case, but we still were unable to track down exactly what the problem was. I ran it on p1g2 with gcc 6.3 and gcc 4.9.

And for those who want further reading, the crash message:

/u/ajbeach/cfa-cc/bin/cfa   -g -Wall -Wno-unused-function -quiet    -g -O2 except-2.c -o except-2
*CFA runtime error* program cfa-cpp terminated with segment fault.
Stack back trace for: /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp
(0) /lib/x86_64-linux-gnu/libc.so.6 : (/*unknown*/)+0x354b0 [0x7f339ef154b0]
(1) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::adjustExprType(Type*&, ResolvExpr::TypeEnvironment const&, SymTab::Indexer const&)+0x41 [0x5c4641]
(2) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::AlternativeFinder::find(Expression*, bool, bool)+0x9c [0x5b156c]
(3) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::AlternativeFinder::visit(ConditionalExpr*)+0x210 [0x5b6440]
(4) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::AlternativeFinder::find(Expression*, bool, bool)+0x44 [0x5b1514]
(5) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::AlternativeFinder::visit(ConditionalExpr*)+0x15f [0x5b638f]
(6) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::AlternativeFinder::find(Expression*, bool, bool)+0x44 [0x5b1514]
(7) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::AlternativeFinder::visit(CastExpr*)+0xe1 [0x5b2cd1]
(8) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::AlternativeFinder::find(Expression*, bool, bool)+0x44 [0x5b1514]
(9) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::resolveInVoidContext(Expression*, SymTab::Indexer const&, ResolvExpr::TypeEnvironment&)+0x90 [0x5b2800]
(10) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::findVoidExpression(Expression*, SymTab::Indexer const&)+0x46 [0x5c51e6]
(11) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::Resolver::visit(ExprStmt*)+0x1d [0x5c524d]
(12) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : SymTab::Indexer::visit(CompoundStmt*)+0x52 [0x5d9cf2]
(13) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : SymTab::Indexer::visit(FunctionDecl*)+0x7e [0x5d9fbe]
(14) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::Resolver::visit(FunctionDecl*)+0x4f [0x5c6d6f]
(15) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : ResolvExpr::resolve(std::__cxx11::list<Declaration*, std::allocator<Declaration*> >)+0x7a [0x5c536a]
(16) /u/ajbeach/cfa-cc/lib/cfa/cfa-cpp : main(/*unknown*/)+0x68c [0x4b25ac]
make: *** [Makefile:832: except-2] Error 1

Change History (1)

comment:1 Changed 3 years ago by Thierry Delisle

Resolution: fixed
Status: newclosed

This does not crash anymore.

Note: See TracTickets for help on using tickets.