Opened 11 years ago

Closed 11 years ago

#43353 closed defect (fixed)

clang-3.4: error: 'assertion_failed__839' declared as an array with a negative size

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: jeremyhu (Jeremy Huddleston Sequoia)
Priority: Normal Milestone:
Component: ports Version: 2.2.1
Keywords: leopard Cc: cooljeanius (Eric Gallager)
Port: clang-3.4

Description

clang-3.4 fails to build for me on Leopard i386. This is the first error:

/opt/local/var/macports/build/_Users_rschmidt_macports_dports_lang_llvm-3.4/clang-3.4/work/llvm-3.4/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:839:1: error: 'assertion_failed__839' declared as an array with a negative size
CHECK_SIZE_AND_OFFSET(dirent, d_ino);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_Users_rschmidt_macports_dports_lang_llvm-3.4/clang-3.4/work/llvm-3.4/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:984:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *) NULL)->MEMBER) == \
--
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_Users_rschmidt_macports_dports_lang_llvm-3.4/clang-3.4/work/llvm-3.4/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:257:57: note: expanded from macro 'IMPL_COMPILER_ASSERT'
    typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
                                                        ^~~~~~~~~~~~~~~

Attachments (4)

leopard-i386-main.log.bz2 (78.3 KB) - added by ryandesign (Ryan Carsten Schmidt) 11 years ago.
thing_to_attach (117.7 KB) - added by ryandesign (Ryan Carsten Schmidt) 11 years ago.
preprocessed source
thing_to_attach.2 (96.9 KB) - added by ryandesign (Ryan Carsten Schmidt) 11 years ago.
preprocessed source with -dM
cdefs.h (18.4 KB) - added by ryandesign (Ryan Carsten Schmidt) 11 years ago.

Download all attachments as: .zip

Change History (27)

Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Attachment: leopard-i386-main.log.bz2 added

comment:1 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

sanitizer_platform_limits_posix.cc:839 is:

CHECK_SIZE_AND_OFFSET(dirent, d_ino);
#define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER)                       \
  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *) NULL)->MEMBER) == \
                 sizeof(((CLASS *) NULL)->MEMBER));                \
  COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==          \
                 offsetof(CLASS, MEMBER))

so... __sanitizer_dirent doesn't match up with dirent.

Can you attach the preprocessed source?

Last edited 11 years ago by jeremyhu (Jeremy Huddleston Sequoia) (previous) (diff)

comment:2 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

  struct __sanitizer_dirent {
    unsigned long long d_ino;
    unsigned long long d_seekoff;
    unsigned short d_reclen;
    // more fields that we don't care about
  };
#if !__DARWIN_64_BIT_INO_T
struct dirent {
        ino_t d_ino;                    /* file number of entry */
        __uint16_t d_reclen;            /* length of this record */
        __uint8_t  d_type;              /* file type, see below */
        __uint8_t  d_namlen;            /* length of string in d_name */
        char d_name[__DARWIN_MAXNAMLEN + 1];    /* name must be no longer than this */
};
#endif /* !__DARWIN_64_BIT_INO_T */

...

#define __DARWIN_STRUCT_DIRENTRY { \
        __uint64_t  d_ino;      /* file number of entry */ \
        __uint64_t  d_seekoff;  /* seek offset (optional, used by servers) */ \
        __uint16_t  d_reclen;   /* length of this record */ \
        __uint16_t  d_namlen;   /* length of string in d_name */ \
        __uint8_t   d_type;     /* file type, see below */ \
        char      d_name[__DARWIN_MAXPATHLEN]; /* entry name (up to MAXPATHLEN bytes) */ \
}

#if __DARWIN_64_BIT_INO_T
struct dirent __DARWIN_STRUCT_DIRENTRY;
#endif /* __DARWIN_64_BIT_INO_T */

I wonder if you're getting the old legacy dirent for some reason...

Last edited 11 years ago by jeremyhu (Jeremy Huddleston Sequoia) (previous) (diff)

comment:3 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Odd. This is on Leopard? I see '-mmacosx-version-min=10.6' ...

comment:4 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Actually, asan isn't even supposed to be building on leopard... hrm...

comment:5 Changed 11 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:6 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Same issue on Leopard PPC, FYI.

Where / what is preprocessed source?

comment:7 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Take the compilation line, replace the -c with -E and change the output file (argument of -o) to ~/Desktop/thing_to_attach. Run the command from the appropriate directory within the workdir. You will likely get errors that certain arguments are not valid with -E, remove them and try again. Attach the result.

Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Attachment: thing_to_attach added

preprocessed source

comment:8 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to jeremyhu@…:

Odd. This is on Leopard? I see '-mmacosx-version-min=10.6' ...

Yes, it's Leopard. Yes, it says 10.6 on that line. Other lines say 10.5 or 10.4.

Replying to jeremyhu@…:

Take the compilation line, replace the -c with -E and change the output file (argument of -o) to ~/Desktop/thing_to_attach. Run the command from the appropriate directory within the workdir. You will likely get errors that certain arguments are not valid with -E, remove them and try again. Attach the result.

I've attached the file. It contains this line:

typedef char assertion_failed__839[2*(int)(sizeof(((__sanitizer_dirent *) __null)->d_ino) == sizeof(((dirent *) __null)->d_ino))-1]; typedef char assertion_failed__839[2*(int)(__builtin_offsetof(__sanitizer_dirent, d_ino) == __builtin_offsetof(dirent, d_ino))-1];

comment:9 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Yep, you're getting the legacy struct

952	 struct dirent {
953	 ino_t d_ino;
954	 __uint16_t d_reclen;
955	 __uint8_t d_type;
956	 __uint8_t d_namlen;
957	 char d_name[255 + 1];
958	};

comment:10 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

So I ran the exact same thing on my system and compared the preprocessed results. Modulo the working dir, this is the full set of changes:

--- Desktop/mine	2014-04-17 21:49:44.000000000 -0700
+++ Downloads/thing_to_attach	2014-04-17 21:50:54.000000000 -0700
@@ -468,9 +468,9 @@ typedef __uint32_t __darwin_gid_t;
 typedef __uint32_t __darwin_id_t;
 typedef __uint64_t __darwin_ino64_t;
 
-typedef __darwin_ino64_t __darwin_ino_t;
 
 
+typedef __uint32_t __darwin_ino_t;
 
 typedef __darwin_natural_t __darwin_mach_port_name_t;
 typedef __darwin_mach_port_name_t __darwin_mach_port_t;
@@ -947,10 +947,18 @@ typedef __darwin_ino_t ino_t;
 
 
 #pragma pack(4)
-# 101 "/usr/include/sys/dirent.h" 3 4
+
+
+struct dirent {
+ ino_t d_ino;
+ __uint16_t d_reclen;
+ __uint8_t d_type;
+ __uint8_t d_namlen;
+ char d_name[255 + 1];
+};
+
+
 #pragma pack()
-# 115 "/usr/include/sys/dirent.h" 3 4
-struct dirent { __uint64_t d_ino; __uint64_t d_seekoff; __uint16_t d_reclen; __uint16_t d_namlen; __uint8_t d_type; char d_name[1024]; };
 # 67 "/usr/include/dirent.h" 2 3 4
 
 struct _telldir;
@@ -971,25 +979,25 @@ typedef struct {
 # 102 "/usr/include/dirent.h" 3 4
 extern "C" {
 
-int alphasort(const void *, const void *) __asm("_" "alphasort" "$INODE64");
+int alphasort(const void *, const void *) __asm("_" "alphasort") ;
 
 int closedir(DIR *) __asm("_" "closedir" "$UNIX2003");
 
 int getdirentries(int, char *, int, long *);
 
-DIR *opendir(const char *) __asm("_" "opendir" "$INODE64" "$UNIX2003");
+DIR *opendir(const char *) __asm("_" "opendir" "$UNIX2003") ;
 
-DIR *__opendir2(const char *, int) __asm("_" "__opendir2" "$INODE64" "$UNIX2003");
+DIR *__opendir2(const char *, int) __asm("_" "__opendir2" "$UNIX2003") ;
 
-struct dirent *readdir(DIR *) __asm("_" "readdir" "$INODE64");
-int readdir_r(DIR *, struct dirent *, struct dirent **) __asm("_" "readdir_r" "$INODE64");
-void rewinddir(DIR *) __asm("_" "rewinddir" "$INODE64" "$UNIX2003");
+struct dirent *readdir(DIR *) __asm("_" "readdir") ;
+int readdir_r(DIR *, struct dirent *, struct dirent **) __asm("_" "readdir_r") ;
+void rewinddir(DIR *) __asm("_" "rewinddir" "$UNIX2003") ;
 
 int scandir(const char *, struct dirent ***,
-    int (*)(struct dirent *), int (*)(const void *, const void *)) __asm("_" "scandir" "$INODE64");
+    int (*)(struct dirent *), int (*)(const void *, const void *)) __asm("_" "scandir") ;
 
-void seekdir(DIR *, long) __asm("_" "seekdir" "$INODE64" "$UNIX2003");
-long telldir(DIR *) __asm("_" "telldir" "$INODE64" "$UNIX2003");
+void seekdir(DIR *, long) __asm("_" "seekdir" "$UNIX2003") ;
+long telldir(DIR *) __asm("_" "telldir" "$UNIX2003") ;
 }
 # 24 "/opt/local/var/macports/build/_Users_jeremy_src_macports_trunk_dports_lang_llvm-3.4/clang-3.4/work/llvm-3.4/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc" 2
 # 1 "/usr/include/errno.h" 1 3 4
@@ -2691,20 +2699,44 @@ struct ostat {
  __uint32_t st_flags;
  __uint32_t st_gen;
 };
-# 224 "/usr/include/sys/stat.h" 3 4
-struct stat { dev_t st_dev; mode_t st_mode; nlink_t st_nlink; __darwin_ino64_t st_ino; uid_t st_uid; gid_t st_gid; dev_t st_rdev; struct timespec st_atimespec; struct timespec st_mtimespec; struct timespec st_ctimespec; struct timespec st_birthtimespec; off_t st_size; blkcnt_t st_blocks; blksize_t st_blksize; __uint32_t st_flags; __uint32_t st_gen; __int32_t st_lspare; __int64_t st_qspare[2]; };
-# 261 "/usr/include/sys/stat.h" 3 4
+# 228 "/usr/include/sys/stat.h" 3 4
+struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+
+ struct timespec st_atimespec;
+ struct timespec st_mtimespec;
+ struct timespec st_ctimespec;
+# 248 "/usr/include/sys/stat.h" 3 4
+ off_t st_size;
+ blkcnt_t st_blocks;
+ blksize_t st_blksize;
+ __uint32_t st_flags;
+ __uint32_t st_gen;
+ __int32_t st_lspare;
+ __int64_t st_qspare[2];
+};
+
+
+
+
+
 struct stat64 { dev_t st_dev; mode_t st_mode; nlink_t st_nlink; __darwin_ino64_t st_ino; uid_t st_uid; gid_t st_gid; dev_t st_rdev; struct timespec st_atimespec; struct timespec st_mtimespec; struct timespec st_ctimespec; struct timespec st_birthtimespec; off_t st_size; blkcnt_t st_blocks; blksize_t st_blksize; __uint32_t st_flags; __uint32_t st_gen; __int32_t st_lspare; __int64_t st_qspare[2]; };
 # 422 "/usr/include/sys/stat.h" 3 4
 extern "C" {
 
 int chmod(const char *, mode_t) __asm("_" "chmod" "$UNIX2003");
 int fchmod(int, mode_t) __asm("_" "fchmod" "$UNIX2003");
-int fstat(int, struct stat *) __asm("_" "fstat" "$INODE64");
-int lstat(const char *, struct stat *) __asm("_" "lstat" "$INODE64");
+int fstat(int, struct stat *) __asm("_" "fstat") ;
+int lstat(const char *, struct stat *) __asm("_" "lstat") ;
 int mkdir(const char *, mode_t);
 int mkfifo(const char *, mode_t);
-int stat(const char *, struct stat *) __asm("_" "stat" "$INODE64");
+int stat(const char *, struct stat *) __asm("_" "stat") ;
 int mknod(const char *, mode_t, dev_t);
 mode_t umask(mode_t);
 
@@ -2718,13 +2750,13 @@ int chflags(const char *, __uint32_t);
 int chmodx_np(const char *, filesec_t);
 int fchflags(int, __uint32_t);
 int fchmodx_np(int, filesec_t);
-int fstatx_np(int, struct stat *, filesec_t) __asm("_" "fstatx_np" "$INODE64");
+int fstatx_np(int, struct stat *, filesec_t) __asm("_" "fstatx_np") ;
 int lchflags(const char *, __uint32_t);
 int lchmod(const char *, mode_t);
-int lstatx_np(const char *, struct stat *, filesec_t) __asm("_" "lstatx_np" "$INODE64");
+int lstatx_np(const char *, struct stat *, filesec_t) __asm("_" "lstatx_np") ;
 int mkdirx_np(const char *, filesec_t);
 int mkfifox_np(const char *, filesec_t);
-int statx_np(const char *, struct stat *, filesec_t) __asm("_" "statx_np" "$INODE64");
+int statx_np(const char *, struct stat *, filesec_t) __asm("_" "statx_np") ;
 int umaskx_np(filesec_t);
 
 int fstatx64_np(int, struct stat64 *, filesec_t);
@@ -3856,11 +3888,37 @@ struct searchstate {
 typedef struct fsid { int32_t val[2]; } fsid_t;
 # 111 "/usr/include/sys/mount.h" 3 4
 struct statfs64 { uint32_t f_bsize; int32_t f_iosize; uint64_t f_blocks; uint64_t f_bfree; uint64_t f_bavail; uint64_t f_files; uint64_t f_ffree; fsid_t f_fsid; uid_t f_owner; uint32_t f_type; uint32_t f_flags; uint32_t f_fssubtype; char f_fstypename[16]; char f_mntonname[1024]; char f_mntfromname[1024]; uint32_t f_reserved[8]; };
+# 122 "/usr/include/sys/mount.h" 3 4
+struct statfs {
+ short f_otype;
+ short f_oflags;
+ long f_bsize;
+ long f_iosize;
+ long f_blocks;
+ long f_bfree;
+ long f_bavail;
+ long f_files;
+ long f_ffree;
+ fsid_t f_fsid;
+ uid_t f_owner;
+ short f_reserved1;
+ short f_type;
+ long f_flags;
+ long f_reserved2[2];
+ char f_fstypename[15];
+ char f_mntonname[90];
+ char f_mntfromname[90];
+
+
+
+
+ char f_reserved3;
+ long f_reserved4[4];
+
+};
 
 
 
-struct statfs { uint32_t f_bsize; int32_t f_iosize; uint64_t f_blocks; uint64_t f_bfree; uint64_t f_bavail; uint64_t f_files; uint64_t f_ffree; fsid_t f_fsid; uid_t f_owner; uint32_t f_type; uint32_t f_flags; uint32_t f_fssubtype; char f_fstypename[16]; char f_mntonname[1024]; char f_mntfromname[1024]; uint32_t f_reserved[8]; };
-# 152 "/usr/include/sys/mount.h" 3 4
 #pragma pack(4)
 
 struct vfsstatfs {
@@ -3921,15 +3979,15 @@ typedef struct fhandle fhandle_t;
 
 extern "C" {
 int fhopen(const struct fhandle *, int);
-int fstatfs(int, struct statfs *) __asm("_" "fstatfs" "$INODE64");
+int fstatfs(int, struct statfs *) __asm("_" "fstatfs") ;
 int fstatfs64(int, struct statfs64 *);
 int getfh(const char *, fhandle_t *);
-int getfsstat(struct statfs *, int, int) __asm("_" "getfsstat" "$INODE64");
+int getfsstat(struct statfs *, int, int) __asm("_" "getfsstat") ;
 int getfsstat64(struct statfs64 *, int, int);
-int getmntinfo(struct statfs **, int) __asm("_" "getmntinfo" "$INODE64");
+int getmntinfo(struct statfs **, int) __asm("_" "getmntinfo") ;
 int getmntinfo64(struct statfs64 **, int);
 int mount(const char *, const char *, int, void *);
-int statfs(const char *, struct statfs *) __asm("_" "statfs" "$INODE64");
+int statfs(const char *, struct statfs *) __asm("_" "statfs") ;
 int statfs64(const char *, struct statfs64 *);
 int unmount(const char *, int);
 int getvfsbyname(const char *, struct vfsconf *);

Can you figure out why/where __DARWIN_64_BIT_INO_T or _DARWIN_NO_64_BIT_INODE are being defined for you? They're not on the command line.

comment:11 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

What is your environment when you ran that? (ie, the output of 'env')?

comment:12 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Also, can you re-run the preprocessing command but add -dM to the line? That will output all the set macros.

comment:13 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

And can you attach your /usr/include/sys/cdefs.h?

comment:14 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to jeremyhu@…:

Can you figure out why/where __DARWIN_64_BIT_INO_T or _DARWIN_NO_64_BIT_INODE are being defined for you? They're not on the command line.

The only possibly related thing I found was in projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc where it says:

// Use 64-bit inodes in file operations. ASan does not support OS X 10.5, so
// the clients will most certainly use 64-bit ones as well.
#ifndef _DARWIN_USE_64_BIT_INODE
#define _DARWIN_USE_64_BIT_INODE 1
#endif

Which leads us back to your earlier question of why this is trying to build on 10.5, if it doesn't support 10.5.

Replying to jeremyhu@…:

What is your environment when you ran that? (ie, the output of 'env')?

Should be pretty normal:

MANPATH=/opt/local/share/man:/usr/share/man:/usr/local/share/man:/usr/X11/man
TERM_PROGRAM=Apple_Terminal
TERM=xterm-color
SHELL=/bin/bash
TMPDIR=/var/folders/vA/vAgMe5ifFZKs1TQHIzYzYk+++TI/-Tmp-/
Apple_PubSub_Socket_Render=/tmp/launch-5iQtNV/Render
TERM_PROGRAM_VERSION=240.2
USER=rschmidt
COMMAND_MODE=unix2003
SSH_AUTH_SOCK=/tmp/launch-dzG5n5/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0:0
PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
PWD=/Users/rschmidt
DBUS_LAUNCHD_SESSION_BUS_SOCKET=/tmp/launch-MF5o0p/unix_domain_listener
LANG=en_US.UTF-8
SHLVL=1
HOME=/Users/rschmidt
LOGNAME=rschmidt
DISPLAY=/tmp/launch-AXBY5h/:0
SECURITYSESSIONID=920610
_=/usr/bin/env

Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Attachment: thing_to_attach.2 added

preprocessed source with -dM

Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Attachment: cdefs.h added

comment:15 in reply to:  13 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to jeremyhu@…:

Also, can you re-run the preprocessing command but add -dM to the line? That will output all the set macros.

Attached.

Replying to jeremyhu@…:

And can you attach your /usr/include/sys/cdefs.h?

Attached. Last modified March 24, 2008, well before this machine was set up.

comment:16 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

This is bizarre. You've got __DARWIN_64_BIT_INO_T defined to 0, but _DARWIN_NO_64_BIT_INODE is not defined.

The reason is your cdefs.h:

289	#if !defined(__DARWIN_64_BIT_INO_T)
290	#  if defined(_DARWIN_USE_64_BIT_INODE)
291	#    define __DARWIN_64_BIT_INO_T 1
292	#  elif defined(_DARWIN_NO_64_BIT_INODE) || defined(KERNEL)
293	#    define __DARWIN_64_BIT_INO_T 0
294	#  else /* default */
295	#    define __DARWIN_64_BIT_INO_T 0
296	#  endif
297	#endif /* !__DARWIN_64_BIT_INO_T */

The default is setting __DARWIN_64_BIT_INO_T to 0.

My /usr/include/sys/cdefs.h has:

#if !defined(__DARWIN_64_BIT_INO_T)
#  if defined(_DARWIN_USE_64_BIT_INODE)
#    define __DARWIN_64_BIT_INO_T 1
#  elif defined(_DARWIN_NO_64_BIT_INODE) || defined(KERNEL)
#    define __DARWIN_64_BIT_INO_T 0
#  else /* default */
#    define __DARWIN_64_BIT_INO_T 1
#  endif
#endif /* !__DARWIN_64_BIT_INO_T */
Last edited 11 years ago by jeremyhu (Jeremy Huddleston Sequoia) (previous) (diff)

comment:17 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

I probably edited my cdefs.h at some point because __DARWIN_64_BIT_INO_T=0 is ick.

comment:18 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

I'm going to deal with this by just disabling the ubsan builld on Leopard.

comment:19 in reply to:  17 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to jeremyhu@…:

I probably edited my cdefs.h at some point because __DARWIN_64_BIT_INO_T=0 is ick.

Is it last modified more recently?

comment:20 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Nope, same time as others in /usr/include/sys/cdefs.h

comment:21 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

r119148 for clang-3.4

comment:22 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Thanks; it builds (on i386; I'll try to build on ppc overnight).

comment:23 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: fixed
Status: newclosed

r119154 for clang-3.3

Note: See TracTickets for help on using tickets.