Skip to content

3C should not exit when encountering conflicting declarations #283

@sroy4899

Description

@sroy4899

The following two files:
file1.c:

typedef long unsigned int size_t;
extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
     __attribute__ ((__nothrow__ )) __attribute__ ((__nonnull__ (2))) ; 

and file2.c:

typedef long unsigned int size_t; 
extern int strerror_r (int __errnum, char *__buf, size_t __buflen) __asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__ )) __attribute__ ((__nonnull__ (2))); 

cause the following crash, only when file1 comes before file2:

0  cconv-standalone         0x0000000104266bca llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 58
1  cconv-standalone         0x0000000104267139 PrintStackTraceSignalHandler(void*) + 25
2  cconv-standalone         0x000000010426503b llvm::sys::RunSignalHandlers() + 123
3  cconv-standalone         0x000000010426b18f SignalHandler(int) + 207
4  libsystem_platform.dylib 0x00007fff6d4e65fd _sigtramp + 29
5  libsystem_platform.dylib 0x00007fc50cb09a58 _sigtramp + 18446743822980494456
6  cconv-standalone         0x00000001046fe4b8 FunctionVariableConstraint::mergeDeclaration(ConstraintVariable*, ProgramInfo&) + 216
....

Interactive debugging revealed that the issue is in PVC's mergeDeclaration's assumption that the number of atoms match:

 PVConstraint *From = dyn_cast<PVConstraint>(FromCV);
  std::vector<Atom *> NewVatoms;
  CAtoms CFrom = From->getCvars();
  CAtoms::iterator I = vars.begin();
  CAtoms::iterator J = CFrom.begin();
  while (I != vars.end()) {
    Atom *IAt = *I;
    Atom *JAt = *J;                                           //FAILS HERE

This is likely due to incompatible types (char * vs int)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions