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

Linker error if there is more than one assert with the same name #14

Open
tyler92 opened this issue Sep 3, 2024 · 0 comments
Open

Linker error if there is more than one assert with the same name #14

tyler92 opened this issue Sep 3, 2024 · 0 comments

Comments

@tyler92
Copy link

tyler92 commented Sep 3, 2024

With the following two files:

// foo.cpp
#include <iostream>
#include "antithesis_sdk.h"

static void func()
{
    std::cout << "func" << std::endl;
    UNREACHABLE("TEST: assert 2", {});
}

void foo()
{
    func();
    std::cout << "foo" << std::endl;
    UNREACHABLE("TEST: assert 1", {});
}
// bar.cpp
#include <iostream>
#include "antithesis_sdk.h"

static void func()
{
    std::cout << "func" << std::endl;
    UNREACHABLE("TEST: assert 3", {});
}

void bar()
{
    func();
    std::cout << "bar" << std::endl;
    UNREACHABLE("TEST: assert 1", {});
}

We have two linker errors:

`.rodata._ZTAXtlN12_GLOBAL__N_112fixed_stringILm12EEEtlSt5arrayIcLm12EEtlA12_cLc118ELc111ELc105ELc100ELc32ELc102ELc117ELc110ELc99ELc40ELc41EEEEE' referenced in section `.text.startup[__cxx_global_var_init]' of CMakeFiles/antithesis-test.dir/bar.cpp.o: defined in discarded section `.rodata._ZTAXtlN12_GLOBAL__N_112fixed_stringILm12EEEtlSt5arrayIcLm12EEtlA12_cLc118ELc111ELc105ELc100ELc32ELc102ELc117ELc110ELc99ELc40ELc41EEEEE[_ZTAXtlN12_GLOBAL__N_112fixed_stringILm12EEEtlSt5arrayIcLm12EEtlA12_cLc118ELc111ELc105ELc100ELc32ELc102ELc117ELc110ELc99ELc40ELc41EEEEE]' of CMakeFiles/antithesis-test.dir/bar.cpp.o

`.rodata._ZTAXtlN12_GLOBAL__N_112fixed_stringILm15EEEtlSt5arrayIcLm15EEtlA15_cLc84ELc69ELc83ELc84ELc58ELc32ELc97ELc115ELc115ELc101ELc114ELc116ELc32ELc49EEEEE' referenced in section `.text.startup[__cxx_global_var_init.1]' of CMakeFiles/antithesis-test.dir/bar.cpp.o: defined in discarded section `.rodata._ZTAXtlN12_GLOBAL__N_112fixed_stringILm15EEEtlSt5arrayIcLm15EEtlA15_cLc84ELc69ELc83ELc84ELc58ELc32ELc97ELc115ELc115ELc101ELc114ELc116ELc32ELc49EEEEE[_ZTAXtlN12_GLOBAL__N_112fixed_stringILm15EEEtlSt5arrayIcLm15EEtlA15_cLc84ELc69ELc83ELc84ELc58ELc32ELc97ELc115ELc115ELc101ELc114ELc116ELc32ELc49EEEEE]' of CMakeFiles/antithesis-test.dir/bar.cpp.o

Both errors happen due to two different reasons:

  1. There are two asserts with the same error (UNREACHABLE("TEST: assert 1", {}))
  2. There are two functions with the same name (func)

Both cases lead to an instantiation of a variable with the type fixed_string (with the same arguments in the constructor) located in an anonymous namespace in antithesis_sdk.h.

As a workaround, the anonymous namespace can be replaced with a regular namespace.

@tyler92 tyler92 changed the title Linker error if there are more than one asserts with the same name Linker error if there are more than one assert with the same name Sep 3, 2024
@tyler92 tyler92 changed the title Linker error if there are more than one assert with the same name Linker error if there is more than one assert with the same name Sep 3, 2024
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

1 participant