aras-p / ClangBuildAnalyzer

Clang build analysis tool using -ftime-trace
The Unlicense
969 stars 60 forks source link

../src/external/cute_files.h:427: int cf_dir_open(cf_dir_t*, const char*): Assertion `0' failed on ClangBuildAnalyzer --stop #57

Closed sigiesec closed 3 years ago

sigiesec commented 3 years ago

Recently, when trying to use ClangBuildAnalyzer to analyze a firefox build, I got the following error and assertion failure on ClangBuildAnalyzer --stop:

ERROR: Failed to open directory (obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/en-US/locale/en-US/mozapps/downloads/settingsChange.dtd): No such file or directory.
ClangBuildAnalyzer: ../src/external/cute_files.h:427: int cf_dir_open(cf_dir_t*, const char*): Assertion `0' failed.

obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/en-US/locale/en-US/mozapps/downloads/settingsChange.dtd exists, but is a symbolic link to a file, not a directory:

[simon@sigibln fuzzy]$ stat obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/en-US/locale/en-US/mozapps/downloads/settingsChange.dtd
  File: obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/en-US/locale/en-US/mozapps/downloads/settingsChange.dtd -> /home/simon/work/fuzzy/toolkit/locales/en-US/chrome/mozapps/downloads/settingsChange.dtd
  Size: 88              Blocks: 8          IO Block: 4096   symbolic link
Device: fd02h/64770d    Inode: 34560445    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1000/   simon)   Gid: ( 1000/   simon)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2020-10-21 18:42:33.948517287 +0200
Modify: 2020-10-14 18:48:03.012265746 +0200
Change: 2020-10-14 18:48:03.012265746 +0200
 Birth: 2020-10-14 18:48:03.012265746 +0200
[simon@sigibln fuzzy]$ stat /home/simon/work/fuzzy/toolkit/locales/en-US/chrome/mozapps/downloads/settingsChange.dtd
  File: /home/simon/work/fuzzy/toolkit/locales/en-US/chrome/mozapps/downloads/settingsChange.dtd
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: fd02h/64770d    Inode: 49026953    Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/   simon)   Gid: ( 1000/   simon)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2020-10-22 09:43:44.048022446 +0200
Modify: 2020-10-22 09:43:34.870015064 +0200
Change: 2020-10-22 09:43:34.870015064 +0200
 Birth: 2020-10-22 09:43:29.366010639 +0200
sigiesec commented 3 years ago

This is the backtrace of the assertion failure (when I re-ran this with a debug build, it apparently hits on a different file):

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50        return ret;
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7a7e895 in __GI_abort () at abort.c:79
#2  0x00007ffff7a7e769 in __assert_fail_base (fmt=0x7ffff7be6688 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5b04c1 "0", file=0x5b04a4 "../src/external/cute_files.h", line=427, function=<optimized out>) at assert.c:92
#3  0x00007ffff7a8c566 in __GI___assert_fail (assertion=0x5b04c1 "0", file=0x5b04a4 "../src/external/cute_files.h", line=427, function=0x5b0558 "int cf_dir_open(cf_dir_t*, const char*)") at assert.c:101
#4  0x000000000043eb45 in cf_dir_open (dir=0x7fffffff4dc0, path=0x7fffffff5210 "obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/toolkit/skin/classic/global/icons/error-16.png") at ../src/external/cute_files.h:427
#5  0x000000000043e69c in cf_traverse (path=0x7fffffff5210 "obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/toolkit/skin/classic/global/icons/error-16.png", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:239
#6  0x000000000043e78e in cf_traverse (path=0x7fffffff6040 "obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/toolkit/skin/classic/global/icons", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:252
#7  0x000000000043e78e in cf_traverse (path=0x7fffffff6e70 "obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/toolkit/skin/classic/global", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:252
#8  0x000000000043e78e in cf_traverse (path=0x7fffffff7ca0 "obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/toolkit/skin/classic", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:252
#9  0x000000000043e78e in cf_traverse (path=0x7fffffff8ad0 "obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/toolkit/skin", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:252
#10 0x000000000043e78e in cf_traverse (path=0x7fffffff9900 "obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome/toolkit", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:252
#11 0x000000000043e78e in cf_traverse (path=0x7fffffffa730 "obj-x86_64-pc-linux-gnu-trace/dist/bin/chrome", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:252
#12 0x000000000043e78e in cf_traverse (path=0x7fffffffb560 "obj-x86_64-pc-linux-gnu-trace/dist/bin", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:252
#13 0x000000000043e78e in cf_traverse (path=0x7fffffffc390 "obj-x86_64-pc-linux-gnu-trace/dist", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:252
#14 0x000000000043e78e in cf_traverse (path=0x6093e0 "obj-x86_64-pc-linux-gnu-trace", cb=0x440afc <JsonFileFinder::Callback(cf_file_t*, void*)>, udata=0x7fffffffd2f0) at ../src/external/cute_files.h:252
#15 0x000000000043f238 in ProcessJsonFiles (artifactsDir="obj-x86_64-pc-linux-gnu-trace", outFile="test.bin", startTime=1603352444, stopTime=1603353333) at ../src/main.cpp:160
#16 0x000000000043f731 in RunStop (argc=4, argv=0x7fffffffd578) at ../src/main.cpp:235
#17 0x0000000000440246 in ProcessCommands (argc=4, argv=0x7fffffffd578) at ../src/main.cpp:378
#18 0x0000000000440359 in main (argc=4, argv=0x7fffffffd578) at ../src/main.cpp:404
sigiesec commented 3 years ago

This is actually a bug in cute_file.h. I filed https://github.com/RandyGaul/cute_headers/pull/226 to fix it.

daverigby commented 3 years ago

I've also started to encounter this issue (intermittently).

If the only issue with the pull-request was the extension length change, I'm happy to upload another pull-request if @sigiesec is no longer working on this.

ice0 commented 3 years ago

@daverigby If I understand correctly, this is a problem with the file cute_files.h which is used by ClangBuildAnalyzer. @sigiesec has already fixed this issue in upstream. Just update this file from upstream and check if that solves the problem for you.

Upstream is located here: https://github.com/RandyGaul/cute_headers/blob/master/cute_files.h

daverigby commented 3 years ago

Can confirm that applying the upstream version of cute_files.h fixes the problem.

Would be great if this pull request could be merged so this is fixed locally.