Summary: | cannot build world with ASAN enabled | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Mark Johnston <markj> | ||||||||
Component: | bin | Assignee: | freebsd-toolchain (Nobody) <toolchain> | ||||||||
Status: | Closed FIXED | ||||||||||
Severity: | Affects Only Me | CC: | dim | ||||||||
Priority: | --- | ||||||||||
Version: | 15.0-CURRENT | ||||||||||
Hardware: | Any | ||||||||||
OS: | Any | ||||||||||
Attachments: |
|
Description
Mark Johnston
2024-08-19 22:28:07 UTC
Created attachment 252937 [details]
reproducer script
Attached the reproducer generated by clang.
This is still broken with LLVM 19. Dmitry, do you have any pointers on how to reduce this to a useful test case that we could submit in an upstream bug report? I don't have much experience with that. (In reply to Mark Johnston from comment #2) Sorry, Dimitry* (In reply to Mark Johnston from comment #3) This fell completely through the cracks for me, sorry! I'll take a look at that reproducer. (In reply to Dimitry Andric from comment #4) Eh Mark, do you also happen to have the preprocessed source file? It should have been dumped in /tmp, similar to the shell script. Created attachment 254508 [details]
reproducer script from llvm 19
Created attachment 254509 [details]
reproducer source from llvm 19
(In reply to Dimitry Andric from comment #5) Woops. I reproduced the problem and attached both files this time. In the mean time I had run a build somewhere on a universe machine, and ran into the same assertion. So it looks like this regressed with https://github.com/llvm/llvm-project/commit/llvmorg-18-init-16766-g51fbab134560 ("[asan] Enable StackSafetyAnalysis by default"), and it still crashes with very recent main, i.e. llvmorg-20-init-09245-g0850e721ab1. One workaround would be to use -asan-use-stack-safety=0 for this one particular troublesome source file, but I'm unsure if that will allow the rest of world to build. Simultaneously, I think it is good to report a bug upstream, but I'll have to reduce the test case. Right, I knew I had seen this before: https://github.com/llvm/llvm-project/issues/87923 [After 7740565f56ce, "Assertion failed: (isa<Function>(Callee) || isa<GlobalAlias>(Callee)), function analyzeAllUses" with -asan-use-stack-safety] This looks like the same sort of thing. The minimized test case I arrived at now was slightly different: typedef int uint32_t; void sysarch(int, void *); #define DEFINE_UIFUNC(qual, ret_type, name, args) \ ret_type name args __attribute__((ifunc(#name "_resolver"))); \ ret_type(*name##_resolver(uint32_t cpu_feature2)) args int __fillcontextx2_xfpu() { int xfpu; sysarch(2, &xfpu); return 0; } int __fillcontextx2_noxfpu(); DEFINE_UIFUNC(, int, __fillcontextx2, (char *)) { return cpu_feature2 ? __fillcontextx2_xfpu : __fillcontextx2_noxfpu; } void __fillcontextx(char *ctx) { __fillcontextx2(ctx); } I'll need do ping the assignee of the upstream bug again. A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f3457ed94241be9d4c2c3ab337c9086d5c45c43f commit f3457ed94241be9d4c2c3ab337c9086d5c45c43f Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-10-28 17:33:49 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-10-28 17:34:58 +0000 Tentatively merge llvm fix for buildworld WITH_ASAN Building world using WITH_ASAN results in an assertion when compiling certain source files referencing ifuncs: Assertion failed: (isa<Function>(Callee) || isa<GlobalAlias>(Callee)), function analyzeAllUses, file /root/freebsd/contrib/llvm-project/llvm/lib/Analysis/StackSafetyAnalysis.cpp, line 514. This was already reported upstream a while ago, in <https://github.com/llvm/llvm-project/issues/87923>, but now there is finally a candidate fix, which seems trivial so I am importing it right away. Reported by: markj PR: 280936 Pull Request: https://github.com/llvm/llvm-project/pull/113841 MFC after: 3 days contrib/llvm-project/llvm/lib/Analysis/StackSafetyAnalysis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (In reply to commit-hook from comment #11) Thanks, but I think something is still missing. A "make buildworld WITH_CLEAN= WITH_ASAN=" still crashes the same way as before. Yeah, you need to rebuild the compiler first, using MK_SYSTEM_COMPILER=no. I think I might need to bump FreeBSD_cc_version, but I really don't want to force everybody to rebuild all of llvm-project _again_. :) (In reply to Dimitry Andric from comment #13) Woops, you're right, thanks. I even thought of that before commenting, but then failed to actually try it. A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=17d39df524a5003131398bc9fbdf8c9fef043d05 commit 17d39df524a5003131398bc9fbdf8c9fef043d05 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-10-28 17:33:49 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-11-02 19:37:27 +0000 Tentatively merge llvm fix for buildworld WITH_ASAN Building world using WITH_ASAN results in an assertion when compiling certain source files referencing ifuncs: Assertion failed: (isa<Function>(Callee) || isa<GlobalAlias>(Callee)), function analyzeAllUses, file /root/freebsd/contrib/llvm-project/llvm/lib/Analysis/StackSafetyAnalysis.cpp, line 514. This was already reported upstream a while ago, in <https://github.com/llvm/llvm-project/issues/87923>, but now there is finally a candidate fix, which seems trivial so I am importing it right away. Reported by: markj PR: 280936 Pull Request: https://github.com/llvm/llvm-project/pull/113841 MFC after: 3 days (cherry picked from commit f3457ed94241be9d4c2c3ab337c9086d5c45c43f) contrib/llvm-project/llvm/lib/Analysis/StackSafetyAnalysis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=814ddb3c8cda06686c5fe10f67b63bc2457e97b5 commit 814ddb3c8cda06686c5fe10f67b63bc2457e97b5 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-10-28 17:33:49 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-11-02 19:37:33 +0000 Tentatively merge llvm fix for buildworld WITH_ASAN Building world using WITH_ASAN results in an assertion when compiling certain source files referencing ifuncs: Assertion failed: (isa<Function>(Callee) || isa<GlobalAlias>(Callee)), function analyzeAllUses, file /root/freebsd/contrib/llvm-project/llvm/lib/Analysis/StackSafetyAnalysis.cpp, line 514. This was already reported upstream a while ago, in <https://github.com/llvm/llvm-project/issues/87923>, but now there is finally a candidate fix, which seems trivial so I am importing it right away. Reported by: markj PR: 280936 Pull Request: https://github.com/llvm/llvm-project/pull/113841 MFC after: 3 days (cherry picked from commit f3457ed94241be9d4c2c3ab337c9086d5c45c43f) contrib/llvm-project/llvm/lib/Analysis/StackSafetyAnalysis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Mark, have you been able to check this, so we can close this bug? For me it all built successfully. However, some runtime testing might also be nice :) (In reply to Dimitry Andric from comment #17) Some basic testing indicates it works, thanks! I tried booting a VM image entirely built with ASAN enabled, and /bin/sh crashes pretty early due to what looks like a false positive, but I think it's a separate problem. |