Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uncaught exception reached top of stack #4588

Open
jacob-carlborg opened this issue Feb 29, 2024 · 4 comments
Open

uncaught exception reached top of stack #4588

jacob-carlborg opened this issue Feb 29, 2024 · 4 comments

Comments

@jacob-carlborg
Copy link
Contributor

jacob-carlborg commented Feb 29, 2024

When I run the tests for DStep, one of them crashes with the following output:

rt/dwarfeh.d:369: uncaught exception reached top of stack
This might happen if you're missing a top level catch in your fiber or signal handler
dstep.translator.Translator.TranslationException@dstep/translator/Context.d(253): /var/folders/l4/_1qyvxps69s_0bg2g89q1mdw0000gp/T/dstepTQJPWVTBJOwXKs6g.h:1:6: error: a type name 'foo' collides with the symbol declared in /var/folders/l4/_1qyvxps69s_0bg2g89q1mdw0000gp/T/dstepTQJPWVTBJOwXKs6g.h:3:6
----------------
??:? object.Throwable.TraceInfo core.runtime.defaultTraceHandler(void*) [0x1035adcb3]
~/development/d/dstep/dstep/translator/Context.d:299 immutable(char)[] dstep.translator.Context.Context.translateTagSpelling(clang.Cursor.Cursor) [0x10082f1ab]
~/development/d/dstep/dstep/translator/Enum.d:267 void dstep.translator.Enum.translateEnumDef(dstep.translator.Output.Output, dstep.translator.Context.Context, clang.Cursor.Cursor) [0x10083aabb]
~/development/d/dstep/dstep/translator/Enum.d:318 void dstep.translator.Enum.translateEnum(dstep.translator.Output.Output, dstep.translator.Context.Context, clang.Cursor.Cursor) [0x10083523f]
~/development/d/dstep/dstep/translator/Translator.d:192 void dstep.translator.Translator.Translator.translate(dstep.translator.Output.Output, clang.Cursor.Cursor, clang.Cursor.Cursor) [0x100834387]
~/development/d/dstep/dstep/translator/Translator.d:139 void dstep.translator.Translator.Translator.translateInGlobalScope(dstep.translator.Output.Output, clang.Cursor.Cursor, clang.Cursor.Cursor) [0x1008338db]
~/development/d/dstep/dstep/translator/Translator.d:106 int dstep.translator.Translator.Translator.translateCursors().__foreachbody3(ref clang.Cursor.Cursor, ref clang.Cursor.Cursor) [0x1008335f3]
~/development/d/dstep/clang/Visitor.d:168 int function(ref clang.Cursor.Cursor, ref clang.Cursor.Cursor) clang.Visitor.InOrderVisitor.opApply(int delegate(ref clang.Cursor.Cursor, ref clang.Cursor.Cursor)).__foreachbody11 [0x1008f4eff]
~/development/d/dstep/clang/Visitor.d:66 extern (C) clang.c.Index.CXChildVisitResult clang.Visitor.Visitor.visitorFunction(clang.c.Index.CXCursor, clang.c.Index.CXCursor, void*) [0x1008f4873]
??:? clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) [0x101098213]
??:? clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) [0x101099e2b]
??:? clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) [0x101099eff]
??:? clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) [0x101098beb]
??:? clang_visitChildren [0x1010a5bdb]
~/development/d/dstep/clang/Visitor.d:35 int clang.Visitor.Visitor.opApply(int delegate(ref clang.Cursor.Cursor, ref clang.Cursor.Cursor)) [0x10088124f]
~/development/d/dstep/clang/Visitor.d:146 int clang.Visitor.InOrderVisitor.opApply(int delegate(ref clang.Cursor.Cursor, ref clang.Cursor.Cursor)) [0x10083336b]
~/development/d/dstep/dstep/translator/Translator.d:93 dstep.translator.Output.Output dstep.translator.Translator.Translator.translateCursors() [0x100832fff]
~/development/d/dstep/dstep/translator/Translator.d:125 immutable(char)[] dstep.translator.Translator.Translator.translateToString() [0x10081a62f]
~/development/d/dstep/tests/unit/Common.d:147 immutable(char)[] Common.translate(clang.TranslationUnit.TranslationUnit, dstep.translator.Options.Options) [0x10081a47f]
~/development/d/dstep/tests/unit/Common.d:188 void Common.assertTranslates(immutable(char)[], clang.TranslationUnit.TranslationUnit, dstep.translator.Options.Options, bool, immutable(char)[], ulong) [0x10081aa4b]
~/development/d/dstep/tests/unit/Common.d:235 void Common.assertTranslates(immutable(char)[], immutable(char)[], dstep.translator.Options.Options, bool, immutable(char)[], ulong) [0x10080424b]
~/development/d/dstep/tests/unit/UnitTests.d:931 pure @nogc @safe void UnitTests.__unittest_L924_C5().__dgliteral2() [0x100809207]
~/.dvm/compilers/ldc-1.37.0-beta1/bin/../import/std/exception.d:294 pure @safe void std.exception.assertThrown!(dstep.translator.Translator.TranslationException, void).assertThrown(lazy void, immutable(char)[], immutable(char)[], ulong) [0x10080906f]
~/development/d/dstep/tests/unit/UnitTests.d:931 void UnitTests.__unittest_L924_C5() [0x10080902f]
~/development/d/dstep/tests/unit/UnitTests.d UnitTests.__unittest [0x10080962f]
??:? _d_run_main [0x1035b652f]
~/.dvm/compilers/ldc-1.37.0-beta1/bin/../import/core/internal/entrypoint.d:42 main [0x100803f53]
??:? start [0x189da10df]
??:? 0x0 [0x6f20ffffffffffff]
Error Program exited with code -6

The test that is causing the crash is this [1]. The test uses assertThrown to verify that an exception is thrown. But assertThrown fails to catch the exception.

This seems to only happen using macOS ARM64. It doesn't happen on FreeBSD, Linux, macOS or Windows on x86-64. I haven't tested any other operating systems on ARM64, so it could be a problem with ARM64 in general.

I don't have a reduced test case. Throwing and catching an exception works fine in isolation. Any tips on how to debug this issue to be able to provide more information or come up with a reduced test case?

[1] https://github.com/jacob-carlborg/dstep/blob/55412291a9628299a17348b7462b80602411e4a2/tests/unit/UnitTests.d#L931

@kinke
Copy link
Member

kinke commented Feb 29, 2024

-link-defaultlib-debug links against unoptimized druntime/Phobos with debuginfos; I'd try that as first thing.

@JohanEngelen
Copy link
Member

Any tips on how to debug this issue to be able to provide more information or come up with a reduced test case?

If it reproduces, you can use dustmite (you'll have to write a simple script) and then just let the PC do the work for you (walk away from the machine ;)).

@jacob-carlborg
Copy link
Contributor Author

jacob-carlborg commented Mar 9, 2024

After 16+ hours dustmite finished. Unfortunately the reduced test case is for another exception, but the result is still the same: uncaught exception reached top of stack. It's still quite a large reduced test, which depends on libclang. The problem might be that it goes through a couple of C++ frames. If anyone wants to take a look at this, I've attached the result of dustmite as a zip file [1]. You need to link with libclang and the LLVM libraries. I've linked with the static libraries. Since the upstream releases don't ship with a static version of libclang I've compiled my own available here [2]. It should work to use the dynamic library as well. You need to either manually edit linker_flags.txt or run the configure script. Then to reproduce the actual issue run: dub --verror --config=test-unit.

I'll try to manually reduce it further.

[1] dstep.zip
[2] https://github.com/jacob-carlborg/clang-builder/releases/tag/v15.0.7%2B0.0.2-rc2

@jacob-carlborg
Copy link
Contributor Author

I've managed to reduce it further, but it still depends on libclang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants