-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Null dereference error compiling with clang 3.9 #6941
Comments
@noahfalk, @mikem8361 could you please take a look? Our code is using construct that is illegal based on the new Clang 3.9 |
I don't understand "interopsafeEXEC" or how/why it works with previous clang versions. @noahfalk ? |
You can try defining interopsafe/interopsafeEXEC as dummy instances - to avoid the null casting issues:
|
This doesn't seem to help, I'm getting
with above macro definitions. As far as I understand those are meant to be dummy parameters for the placement --- a/src/debug/ee/debugger.h 2016-10-08 21:37:38.000000000 +0200
+++ b/src/debug/ee/debugger.h 2016-11-07 22:22:06.057650158 +0100
@@ -3512,9 +3512,11 @@
* ------------------------------------------------------------------------ */
class InteropSafe {};
+static InteropSafe *dummyInteropSafe = new InteropSafe();
-#define interopsafe (*(InteropSafe*)NULL)
+#define interopsafe (*dummyInteropSafe)
class InteropSafeExecutable {};
+static InteropSafeExecutable *dummyInteropSafeExecutable = new InteropSafeExecutable();
-#define interopsafeEXEC (*(InteropSafeExecutable*)NULL)
+#define interopsafeEXEC (*dummyInteropSafeExecutable)
#ifndef DACCESS_COMPILE
inline void * __cdecl operator new(size_t n, const InteropSafe&) and it did work. I'm fairly sure it's a wrong solution, but it gets rid of the errors. Maybe a proper solution would be to have some sort of a factory method that isn't bound by placement new's contract? I've also noticed this comment above non-
I imagine this might be some sort of optimisation, but shouldn't maybe some more explicit throw be used in this case instead of exploiting such undefined behaviour? Or in case you have disabled C++ exceptions in the codebase to handle it in a custom way, then maybe some other way to terminate the program? |
I've fiddled with it a bit more, and here is a complete patchset over Of course the patches only make clang stop complaining and probably don't solve the issues appropriately (the compilation finishes without errors, but |
Are there any updates on this front? Our team wants to move over 1.1 and it would be nice if I could keep running the application. |
@jaen I will try to figure it out. But I am not sure how it is related to 1.1, the code with the InterpoSafeXXX has not changed since January 2015. It is not a bug, it is just the new clang being more strict. |
Sure, thanks for looking into it! |
dotnet/coreclr#8309 has attempt to fix it by disabling the warning. |
@jkotas I am finishing a trivial fix that doesn't disable any warnings. |
@jaen, @jkotas the PR for the clang 3.9 build fix is dotnet/coreclr#8311 |
@janvorli the current |
Fixed by dotnet/coreclr#8311 |
Trying to compile newest
1.1.0-preview1
release on Arch Linux (clang 3.9, gcc 6.2.1) fails with errors pertaining to creating null references, such as this one:You can see the full build log here – https://gist.github.com/jaen/1315903d63f9b1d2d5fdc61baef6a0dc.
This issue was mentioned in #6882, but it seems there's no separate issue, so I made one.
If there's anything else I can do to help, let me know.
The text was updated successfully, but these errors were encountered: