C99 VLA bug?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

C99 VLA bug?

Andy Wick
C99 VLA bug? Thanks for all the hard work, I didn’t see this in bugzilla but maybe a known issue.  The typedef seems to cause the issue, and unfortunately we use thru out our project.  I’m using svn 92284

The file:
#include <string.h>
typedef unsigned char Byte;
void doit (char *data, int len) {
    if (len) {
        Byte buf[len];
        memcpy(buf, data, len);
    }
}


Compiled with “clang --analyze t.c”

Gives me:
clang: ASTContext.cpp:2377: clang::QualType clang::ASTContext::getUnqualifiedArrayType(clang::QualType, clang::Qualifiers&): Assertion `T.isCanonical() && "Only operates on canonical types"' failed.
0  clang           0x000000000141b61f
1  clang           0x000000000141be21
2  libpthread.so.0 0x0000002a9567f160
3  libc.so.6       0x0000002a95d5f745 gsignal + 69
4  libc.so.6       0x0000002a95d60eb3 abort + 467
5  libc.so.6       0x0000002a95d58dc9
6  clang           0x000000000084cb06
7  clang           0x000000000084c9ea
8  clang           0x00000000006bc472
9  clang           0x000000000067d86f
10 clang           0x0000000000677124
11 clang           0x000000000067d99b
12 clang           0x0000000000677124
13 clang           0x000000000067608a
14 clang           0x0000000000676fd4
15 clang           0x000000000067dfe1
16 clang           0x000000000066c068
17 clang           0x000000000066c2d2
18 clang           0x00000000004d8b97
19 clang           0x00000000004d7530
20 clang           0x00000000004d7a15
21 clang           0x00000000006e0136
22 clang           0x00000000004345e0
23 clang           0x0000000000437661 main + 1585
24 libc.so.6       0x0000002a95d4d1d7 __libc_start_main + 215
25 clang           0x000000000043246a
Stack dump:
0.    Program arguments: /usr/local/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -main-file-name t.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -warn-dead-stores -warn-security-syntactic -checker-cfref -analyzer-eagerly-assume -warn-objc-methodsigs -warn-objc-unused-ivars -analyzer-output plist -mrelocation-model static -mdisable-fp-elim -munwind-tables -target-cpu x86-64 -v -resource-dir /usr/local/lib/clang/1.1 -fmessage-length 138 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o t.plist -x c t.c
1.    <eof> parser at end of file
2.    t.c:6:9: Error evaluating statement
3.    t.c:6:9: Error evaluating statement
4.    t.c:6:16: Error evaluating statement
5.    t.c:6:16: Error evaluating statement
clang: error: analyzer command failed due to signal 6 (use -v to see invocation)

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: C99 VLA bug?

Chris Lattner

On Dec 30, 2009, at 3:44 AM, Andy Wick wrote:

Thanks for all the hard work, I didn’t see this in bugzilla but maybe a known issue.  The typedef seems to cause the issue, and unfortunately we use thru out our project.  I’m using svn 92284

This looks like a bug in the static analyzer, please file a bugzilla, thanks!

-Chris
 

The file:
#include <string.h>
typedef unsigned char Byte;
void doit (char *data, int len) {
    if (len) {
        Byte buf[len];
        memcpy(buf, data, len);
    }
}


Compiled with “clang --analyze t.c”

Gives me:
clang: ASTContext.cpp:2377: clang::QualType clang::ASTContext::getUnqualifiedArrayType(clang::QualType, clang::Qualifiers&): Assertion `T.isCanonical() && "Only operates on canonical types"' failed.
0  clang           0x000000000141b61f
1  clang           0x000000000141be21
2  libpthread.so.0 0x0000002a9567f160
3  libc.so.6       0x0000002a95d5f745 gsignal + 69
4  libc.so.6       0x0000002a95d60eb3 abort + 467
5  libc.so.6       0x0000002a95d58dc9
6  clang           0x000000000084cb06
7  clang           0x000000000084c9ea
8  clang           0x00000000006bc472
9  clang           0x000000000067d86f
10 clang           0x0000000000677124
11 clang           0x000000000067d99b
12 clang           0x0000000000677124
13 clang           0x000000000067608a
14 clang           0x0000000000676fd4
15 clang           0x000000000067dfe1
16 clang           0x000000000066c068
17 clang           0x000000000066c2d2
18 clang           0x00000000004d8b97
19 clang           0x00000000004d7530
20 clang           0x00000000004d7a15
21 clang           0x00000000006e0136
22 clang           0x00000000004345e0
23 clang           0x0000000000437661 main + 1585
24 libc.so.6       0x0000002a95d4d1d7 __libc_start_main + 215
25 clang           0x000000000043246a
Stack dump:
0.    Program arguments: /usr/local/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -main-file-name t.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -warn-dead-stores -warn-security-syntactic -checker-cfref -analyzer-eagerly-assume -warn-objc-methodsigs -warn-objc-unused-ivars -analyzer-output plist -mrelocation-model static -mdisable-fp-elim -munwind-tables -target-cpu x86-64 -v -resource-dir /usr/local/lib/clang/1.1 -fmessage-length 138 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o t.plist -x c t.c
1.    <eof> parser at end of file
2.    t.c:6:9: Error evaluating statement
3.    t.c:6:9: Error evaluating statement
4.    t.c:6:16: Error evaluating statement
5.    t.c:6:16: Error evaluating statement
clang: error: analyzer command failed due to signal 6 (use -v to see invocation)
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: C99 VLA bug?

Zhongxing Xu
In reply to this post by Andy Wick
I committed a tentative fix in r92318. Chris, could you please review it? Thanks.

2009/12/30 Andy Wick <[hidden email]>
Thanks for all the hard work, I didn’t see this in bugzilla but maybe a known issue.  The typedef seems to cause the issue, and unfortunately we use thru out our project.  I’m using svn 92284

The file:
#include <string.h>
typedef unsigned char Byte;
void doit (char *data, int len) {
    if (len) {
        Byte buf[len];
        memcpy(buf, data, len);
    }
}


Compiled with “clang --analyze t.c”

Gives me:
clang: ASTContext.cpp:2377: clang::QualType clang::ASTContext::getUnqualifiedArrayType(clang::QualType, clang::Qualifiers&): Assertion `T.isCanonical() && "Only operates on canonical types"' failed.
0  clang           0x000000000141b61f
1  clang           0x000000000141be21
2  libpthread.so.0 0x0000002a9567f160
3  libc.so.6       0x0000002a95d5f745 gsignal + 69
4  libc.so.6       0x0000002a95d60eb3 abort + 467
5  libc.so.6       0x0000002a95d58dc9
6  clang           0x000000000084cb06
7  clang           0x000000000084c9ea
8  clang           0x00000000006bc472
9  clang           0x000000000067d86f
10 clang           0x0000000000677124
11 clang           0x000000000067d99b
12 clang           0x0000000000677124
13 clang           0x000000000067608a
14 clang           0x0000000000676fd4
15 clang           0x000000000067dfe1
16 clang           0x000000000066c068
17 clang           0x000000000066c2d2
18 clang           0x00000000004d8b97
19 clang           0x00000000004d7530
20 clang           0x00000000004d7a15
21 clang           0x00000000006e0136
22 clang           0x00000000004345e0
23 clang           0x0000000000437661 main + 1585
24 libc.so.6       0x0000002a95d4d1d7 __libc_start_main + 215
25 clang           0x000000000043246a
Stack dump:
0.    Program arguments: /usr/local/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -main-file-name t.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -warn-dead-stores -warn-security-syntactic -checker-cfref -analyzer-eagerly-assume -warn-objc-methodsigs -warn-objc-unused-ivars -analyzer-output plist -mrelocation-model static -mdisable-fp-elim -munwind-tables -target-cpu x86-64 -v -resource-dir /usr/local/lib/clang/1.1 -fmessage-length 138 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o t.plist -x c t.c
1.    <eof> parser at end of file
2.    t.c:6:9: Error evaluating statement
3.    t.c:6:9: Error evaluating statement
4.    t.c:6:16: Error evaluating statement
5.    t.c:6:16: Error evaluating statement
clang: error: analyzer command failed due to signal 6 (use -v to see invocation)

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev