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

Make sanitizers work again in coreclr #61948

Closed

Conversation

omajid
Copy link
Member

@omajid omajid commented Nov 23, 2021

  • Don't use CMAKE_CURRENT_SOURCE_DIR because it points to the original CMakeLists.txt that's doing an include. Use the variable that explicitly refers to eng/native.

  • --ffunction-sections produces an error with clang. -fsanitize=bool;-ffunction-sections (single dash in -ffunction) is accepted by even clang 3.0 (the oldest clang I could find on godbolt.org while the two-dash variant is treated as an error.

  • Add symbolizer argument to enable-sanitizers.sh to force exporting the symbol variable, which the comment states (I haven't verified) is not needed on newer clang versions.

  • Stop defaulting to an older clang version, and support un-versioned names too.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 23, 2021
@omajid
Copy link
Member Author

omajid commented Nov 23, 2021

I figured I would enable sanitizers to see if something obvious pops up for #61671, but I am running into some errors locally that I don't know how to fix:

$ source ./src/coreclr/enablesanitizers.sh ubsan
$ export VERBOSE=1
$ ./build.sh clr+libs+libs.tests -rc checked -lc Release
[....]
  /usr/bin/ld: ../../dlls/mscordac/libmscordaccore.so: undefined reference to `typeinfo for BINDER_SPACE::Assembly'
  /usr/bin/ld: ../../dlls/mscordac/libmscordaccore.so: undefined reference to `typeinfo for LCGMethodResolver'
  /usr/bin/ld: ../../dlls/mscordac/libmscordaccore.so: undefined reference to `typeinfo for DebuggerRCThread'

@omajid omajid changed the title Fix using sanitizers with modern clang versions too Make sanitizers work again Nov 23, 2021
- Don't use `CMAKE_CURRENT_SOURCE_DIR` because it points to the
  original CMakeLists.txt that's doing an `include`. Use the variable
  that explicitly refers to `eng/native`.

- `--ffunction-sections` produces an error with clang.
  `-fsanitize=bool;-ffunction-sections` (single dash in `-ffunction`) is
  accepted by even clang 3.0 (the oldest clang I could find on
  godbolt.org  while the two-dash variant is treated as an error.

- Add `symbolizer` argument to `enable-sanitizers.sh` to force exporting
  the symbol variable, which the comment states (I haven't verified) is
  not needed on newer clang versions.

- Stop defaulting to an older clang version. Handle more explicit
  versions, and suppport un-versioned names too.
@omajid omajid changed the title Make sanitizers work again Make sanitizers work again in coreclr Nov 23, 2021
@omajid omajid force-pushed the fix-up-sanitizers-with-modern-clang branch from 80fe56d to 42b49b0 Compare November 23, 2021 00:30
@omajid
Copy link
Member Author

omajid commented Nov 23, 2021

A standalone build with - without sanitizers enabled ./build.sh clr+libs+libs.tests -rc checked -lc Release - works for me.

I wonder why enabling sanitizers introduces undefined references.

Anyone know where if there's a library I need to link to to get access to BINDER_SPACE::Assembly, LCGMethodResolver and DebuggerRCThread?

@ghost
Copy link

ghost commented Nov 23, 2021

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

Issue Details
  • Don't use CMAKE_CURRENT_SOURCE_DIR because it points to the original CMakeLists.txt that's doing an include. Use the variable that explicitly refers to eng/native.

  • --ffunction-sections produces an error with clang. -fsanitize=bool;-ffunction-sections (single dash in -ffunction) is accepted by even clang 3.0 (the oldest clang I could find on godbolt.org while the two-dash variant is treated as an error.

  • Add symbolizer argument to enable-sanitizers.sh to force exporting the symbol variable, which the comment states (I haven't verified) is not needed on newer clang versions.

  • Stop defaulting to an older clang version, and support un-versioned names too.

Author: omajid
Assignees: -
Labels:

area-Infrastructure-coreclr, community-contribution

Milestone: -

@omajid omajid marked this pull request as draft November 23, 2021 13:55
@omajid
Copy link
Member Author

omajid commented Nov 23, 2021

Marking this as draft, until the issues in #61948 (comment) are resolved.

@tstellar
Copy link

@omajid This can happen if you have a library consumer built with rtti enabled trying to link with a library built without rtti.

@ghost
Copy link

ghost commented Dec 29, 2021

Draft Pull Request was automatically closed for inactivity. Please let us know if you'd like to reopen it.

@ghost ghost closed this Dec 29, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jan 29, 2022
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants