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

[SR-10341] Crash in "Reflection/typeref_decoding_asan.swift" after changes to 'ReflectionContext' #52741

Open
swift-ci opened this issue Apr 9, 2019 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 9, 2019

Previous ID SR-10341
Radar None
Original Reporter stamba (JIRA User)
Type Bug

Attachment: Download

Environment

PPC64LE

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: a73b01fa4e9adb8eb64fe8f63bc5ccfe

Issue Description:

The following new errors are seen in test case "Reflection/typeref_decoding_asan.swift" on PPC64LE while building latest Apple Swift 5 toolchain:-

==================================================================================================
FAIL: Swift(linux-powerpc64le) :: Reflection/typeref_decoding_asan.swift (9703 of 11813)

                    • TEST 'Swift(linux-powerpc64le) :: Reflection/typeref_decoding_asan.swift' FAILED ********************
                      Script:

                      : 'RUN: at line 2'; rm -rf "/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/test-linux-powerpc64le/Reflection/Output/typeref_decoding_asan.swift.tmp" && mkdir -p "/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/test-linux-powerpc64le/Reflection/Output/typeref_decoding_asan.swift.tmp"
                      : 'RUN: at line 3'; /home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swiftc -target powerpc64le-unknown-linux-gnu -module-cache-path '/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/swift-test-results/powerpc64le-unknown-linux-gnu/clang-module-cache' -swift-version 4 /home/sar/swift-source/swift/test/Reflection/Inputs/ConcreteTypes.swift /home/sar/swift-source/swift/test/Reflection/Inputs/GenericTypes.swift /home/sar/swift-source/swift/test/Reflection/Inputs/Protocols.swift /home/sar/swift-source/swift/test/Reflection/Inputs/Extensions.swift /home/sar/swift-source/swift/test/Reflection/Inputs/Closures.swift -parse-as-library -emit-module -emit-library -module-name TypesToReflect -sanitize=address -o /home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/test-linux-powerpc64le/Reflection/Output/typeref_decoding_asan.swift.tmp/libTypesToReflect.so
                      : 'RUN: at line 4'; /home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump -arch powerpc64le -binary-filename /home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/test-linux-powerpc64le/Reflection/Output/typeref_decoding_asan.swift.tmp/libTypesToReflect.so | '/usr/bin/python' '/home/sar/swift-source/swift/utils/PathSanitizingFileCheck' --sanitize BUILD_DIR='/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le' --sanitize SOURCE_DIR='/home/sar/swift-source/swift' --use-filecheck '/home/sar/swift-source/build/buildbot_linux/llvm-linux-powerpc64le/bin/FileCheck' /home/sar/swift-source/swift/test/Reflection/typeref_decoding_asan.swift

                      Exit Code: 2

Command Output (stderr):

terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Stack dump:
0. Program arguments: /home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump -arch powerpc64le -binary-filename /home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/test-linux-powerpc64le/Reflection/Output/typeref_decoding_asan.swift.tmp/libTypesToReflect.so
#0 0x0000000010180a88 PrintStackTraceSignalHandler(void*) (/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump+0x10180a88)
#1 0x000000001017dd28 llvm::sys::RunSignalHandlers() (/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump+0x1017dd28)
#2 0x0000000010181238 SignalHandler(int) (/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump+0x10181238)
#3 0x00003fff7d3704d8 0x4d8 gsignal
#4 0x00003fff7d3704d8 /build/glibc-ZFwvyp/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00003fff7d3704d8 abort /build/glibc-ZFwvyp/glibc-2.23/stdlib/abort.c:74:0
#6 0x00003fff7cd3ec90 **gnu_cxx::_verbose_terminate_handler() (/lib/powerpc64le-linux-gnu/libc.so.6+0x3ec90)
#7 0x00003fff7cd411f4 (/lib/powerpc64le-linux-gnu/libc.so.6+0x411f4)
#8 0x00003fff7cfac324 std::terminate() (/usr/lib/powerpc64le-linux-gnu/libstdc++.so.6+0xac324)
#9 0x00003fff7cfa8b54 __cxa_throw (/usr/lib/powerpc64le-linux-gnu/libstdc++.so.6+0xa8b54)
#10 0x00003fff7cfa8c10 std::
_throw_logic_error(char const*) (/usr/lib/powerpc64le-linux-gnu/libstdc++.so.6+0xa8c10)
#11 0x00003fff7cfa9054 bool swift::reflection::ReflectionContext<swift::External<swift::RuntimeTarget<8u> > >::readELFSections<(anonymous namespace)::ELFTraits<(unsigned char)2> >(swift::remote::RemoteAddress)::'lambda'(std::**cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::operator()(std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) const (/usr/lib/powerpc64le-linux-gnu/libstdc++.so.6+0xa9054)
#12 0x00003fff7cfe08a4 swift::reflection::ReflectionContext<swift::External<swift::RuntimeTarget<8u> > >::addImage(swift::remote::RemoteAddress) (/usr/lib/powerpc64le-linux-gnu/libstdc++.so.6+0xe08a4)
#13 0x00000000100157ec main (/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump+0x100157ec)
#14 0x000000001000d9f8 generic_start_main /build/glibc-ZFwvyp/glibc-2.23/csu/../csu/libc-start.c:291:0
#15 0x000000001000b26c __libc_start_main /build/glibc-ZFwvyp/glibc-2.23/csu/../sysdeps/unix/sysv/linux/powerpc/libc-start.c:116:0
/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump[0x10180a88]
/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump[0x1017dd28]
/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump[0x10181238]
[0x3fff7d3704d8]
/lib/powerpc64le-linux-gnu/libc.so.6(gsignal+0x40)[0x3fff7cd3ec90]
/lib/powerpc64le-linux-gnu/libc.so.6(abort+0x2b4)[0x3fff7cd411f4]
/usr/lib/powerpc64le-linux-gnu/libstdc+.so.6(ZN9gnu_cxx27_verbose_terminate_handlerEv+0x204)[0x3fff7cfac324]
/usr/lib/powerpc64le-linux-gnu/libstdc+.so.6(+0xa8b54)[0x3fff7cfa8b54]
/usr/lib/powerpc64le-linux-gnu/libstdc++.so.6(_ZSt9terminatev+0x20)[0x3fff7cfa8c10]
/usr/lib/powerpc64le-linux-gnu/libstdc++.so.6(
_cxa_throw+0xb4)[0x3fff7cfa9054]
/usr/lib/powerpc64le-linux-gnu/libstdc++.so.6(ZSt19_throw_logic_errorPKc+0x64)[0x3fff7cfe08a4]
/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump[0x100157ec]
/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump[0x1000d9f8]
/home/sar/swift-source/build/buildbot_linux/swift-linux-powerpc64le/bin/swift-reflection-dump[0x1000b26c]
/lib/powerpc64le-linux-gnu/libc.so.6(+0x2309c)[0x3fff7cd2309c]
/lib/powerpc64le-linux-gnu/libc.so.6(__libc_start_main+0xb8)[0x3fff7cd23298]
FileCheck error: '-' is empty.
FileCheck command line: /home/sar/swift-source/build/buildbot_linux/llvm-linux-powerpc64le/bin/FileCheck /home/sar/swift-source/swift/test/Reflection/typeref_decoding_asan.swift

--

********************

This particular test case was passing in earlier builds until a few days back.

Analysing the stack dump, figured out that the issue might be in "swift/include/swift/Reflection/ReflectionContext.h".
This file has been changed recently around the code which fails above:-
#23633
#23769

I see that these changes were done in order to correctly calculate the references (relative pointers) when ReflectionContext was parsing the image of a binary.

@compnerd @alexshap can you please check this out and confirm if this is the issue?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Apr 9, 2019

Comment by Sarvesh Tamba (JIRA)

@compnerd Please check this.

@swift-ci
Copy link
Collaborator Author

Comment by Sarvesh Tamba (JIRA)

@compnerd Any thoughts on this one?

@swift-ci
Copy link
Collaborator Author

Comment by Sarvesh Tamba (JIRA)

CC:- @dcci @jckarter
Maybe you could help?

@compnerd
Copy link
Collaborator

Hmm, the stack trace doesn't really help. It does seem that something is trying to create a `std::string` from a nullptr, but, the stack trace wont help - this will require being able to run this under the debugger to figure out what is being constructed and why.

@swift-ci
Copy link
Collaborator Author

Comment by Sarvesh Tamba (JIRA)

Hi @compnerd

I have built swift toolchain in release mode as debug build runs out of space (needs more than 80GB space and 6 hrs of build time).
However I did manage to debug to a certain extent using print statements in file ReflectionContext.h and this is what I found:-

  • The code flow crashes while accessing 'StrTab' variable at the following statement while constructing std::string in file 'ReflectionContext.h:455' inside "function bool readELFSections(RemoteAddress ImageStart)":-
    "auto SecName = std::string(StrTab + Offset);"
  • Following is the error thrown:-
    terminate called after throwing an instance of 'std::logic_error'
    what(): basic_string::_M_construct null not valid
  • I tried printing the value of StrTab, however as expected, it crashes at that step too.

  • "StrTabBuf.get()" which is used to construct variable 'StrTab' prints 0

  • Although crude, attached are the raw values of different variables used in the function which I could trace.

Can anyone explain what this piece of code is trying to do? I tried going through the code in the stack trace, however I am not well versed with the finer details of the code and will require help from swift community. Anyone you could point me to who can guide me on this and help fix this issue?

values.txt

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants