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-13225] Linker fails with CodeView debug info enabled #55665

Open
lxbndr opened this issue Jul 15, 2020 · 1 comment
Open

[SR-13225] Linker fails with CodeView debug info enabled #55665

lxbndr opened this issue Jul 15, 2020 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself debug info Area → compiler → IRGen: Debug information emission Windows Platform: Windows

Comments

@lxbndr
Copy link
Contributor

lxbndr commented Jul 15, 2020

Previous ID SR-13225
Radar None
Original Reporter @lxbndr
Type Bug

Attachment: Download

Environment

Swift version 5.3-dev (LLVM 8cbcb68, Swift fc45397)
Target: x86_64-unknown-windows-msvc

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DebugInfo, Windows
Assignee None
Priority Medium

md5: cae9499a812e80c65bb24b71a5c5a084

relates to:

  • SR-10671 Windows, linker fails on specific code with CodeView debug info enabled

Issue Description:

Similar to SR-10671, but reproducible with different settings and code. Build configuration: Release with Debug Info.

Code contains infinite loop, but it is actually reduced from real-life example where loop contains reachable break:

struct S {
    func f() {
        let c = {
            while true {
            }
        }
        print(c)
    }
}

Compiler invocation:

%SWIFTC% -emit-library -O -g -debug-info-format=codeview sr13225.swift -o sr13225.dll

Output:

sr13225-1dece9.o : fatal error LNK1318: Unexpected PDB error; OK (0) ''
clang: error: linker command failed with exit code 1318 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1318 (use -v to see invocation)

UPD

Using lld-link (with assertions enabled) gives more informative output:

Assertion failed: indices.size() == 2, file D:\Development\swift-windows-gha\w\s\llvm-project\lld\COFF\PDB.cpp, line 731

The assertion is located in translateIdSymbols() function:

...
TypeIndex *ti =
    reinterpret_cast<TypeIndex *>(content.data() + refs[0].Offset);
// `ti` is the index of a FuncIdRecord or MemberFuncIdRecord which lives in
// the IPI stream, whose `FunctionType` member refers to the TPI stream.
// Note that LF_FUNC_ID and LF_MEMFUNC_ID have the same record layout, and
// in both cases we just need the second type index.
>;if (!ti->isSimple() && !ti->isNoneType()) {
    CVType funcIdData = iDTable.getType(*ti);
    SmallVector<TypeIndex, 2> indices;
    discoverTypeIndices(funcIdData, indices);
    assert(indices.size() == 2);
    *ti = indices[1];
}
...
@compnerd
Copy link
Collaborator

This is likely the known issue that we generate references to non-code entities which link refuses to resolve as it is invalid.

@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. compiler The Swift compiler in itself debug info Area → compiler → IRGen: Debug information emission Windows Platform: Windows
Projects
None yet
Development

No branches or pull requests

2 participants