-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: c++ 17 #7038
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
base: master
Are you sure you want to change the base?
refactor: c++ 17 #7038
Conversation
bbfda98 to
3576eb9
Compare
|
Is this one next up? Do you know what caused the test fails? |
3576eb9 to
0dd3516
Compare
0dd3516 to
cd81a22
Compare
|
We still get a test failure for x64 NativeTests which likely means GC is not working any more (not good). ChakraCore/bin/NativeTests/JsRTApiTest.cpp Line 136 in c6a9549
So far, I cannot reproduce this issue with a local build. Edit: The issue is reproducable using the ci build from Azure Artifacts. Edit: Only happens in 'Test' (likely in 'Release' aswell) not 'Debug' configuration. |
d2fdef9 to
b8e02b3
Compare
Can you reproduce with a local Test build? Or only by downloading a test build? If this dependent on compiler versions it may be awkward to solve, hopefully it's a simple configuration issue somehow... |
That's the problem: I can't 🙈
I fear that might be the case...
Here's what I did:
|
|
I created a small test c program based on the failing native test to test the behavior on linux
POCRemoving the #include <string.h>
#include <stdio.h>
#include "ChakraCommon.h"
#include "ChakraCore.h"
#define REQUIRE(condition) if (!(condition)) return -1;
#define CHECK(condition) if (!(condition)) return -1;
int main(){
JsRuntimeAttributes attributes = 0;
JsRuntimeHandle runtime = JS_INVALID_RUNTIME_HANDLE;
JsValueRef context = JS_INVALID_REFERENCE;
JsValueRef setContext = JS_INVALID_REFERENCE;
// Create runtime, context and set current context
REQUIRE(JsCreateRuntime(attributes, NULL, &runtime) == JsNoError);
REQUIRE(JsCreateContext(runtime, &context) == JsNoError);
REQUIRE(JsSetCurrentContext(context) == JsNoError);
REQUIRE(((JsGetCurrentContext(&setContext) == JsNoError) || setContext == context));
JsValueRef valueRef = JS_INVALID_REFERENCE;
REQUIRE(JsCreateString("test", strlen("test"), &valueRef) == JsNoError);
JsWeakRef weakRef = JS_INVALID_REFERENCE;
REQUIRE(JsCreateWeakReference(valueRef, &weakRef) == JsNoError);
// JsGetWeakReferenceValue should return the original value reference.
JsValueRef valueRefFromWeakRef = JS_INVALID_REFERENCE;
CHECK(JsGetWeakReferenceValue(weakRef, &valueRefFromWeakRef) == JsNoError);
CHECK(valueRefFromWeakRef != JS_INVALID_REFERENCE);
CHECK(valueRefFromWeakRef == valueRef);
// Clear the references on the stack, so that the value will be GC'd.
valueRef = JS_INVALID_REFERENCE;
valueRefFromWeakRef = JS_INVALID_REFERENCE;
puts("This line is the fix?!");
CHECK(JsCollectGarbage(runtime) == JsNoError);
// JsGetWeakReferenceValue should return an invalid reference after the value was GC'd.
JsValueRef valueRefAfterGC = JS_INVALID_REFERENCE;
CHECK(JsGetWeakReferenceValue(weakRef, &valueRefAfterGC) == JsNoError);
printf("valueRefAfterGC = %ld\n", (int64_t)valueRefAfterGC);
CHECK(valueRefAfterGC == JS_INVALID_REFERENCE);
printf("Pass\n");
} |
|
Is this a MSVC version issue - what is your local version vs Azure? The CI says "MSBuild version 17.14.23+b0019275e for .NET Framework" |
|
I can check tomorrow. The weird thing is: I get the same symptoms when I test the latest Linux build and when I build the v11 branch on Ubuntu 18.04! |
Something that's dependent on compiler Or OS versions is very awkward; also would be good to work out whether it's GC not triggering for some reason or GC not collecting the objects it ought to collect. The "fix" in this is interesting... Could the Compiler be re-ordering operations and the output prevents it doing it? |
3f72f99 to
71680df
Compare
|
Interesting that the tests now pass do you think the catch framework update was the problem? |
|
@rhuanjl According to this little sanity-check it actually seems like the catch-update "caused" the ci failures (good intuition on your side!) In my head there might be two root causes:
It's still strange that I could not reproduce the issue locally. |
a870a03 to
14e5681
Compare
14e5681 to
5699702
Compare
fb97201 to
b8bede4
Compare
|
Okay, I did some debugging of the ChakraCore/bin/NativeTests/JsRTApiTest.cpp Lines 113 to 137 in 2dba810
Turns out: The CC-GC (Conservative Mark'n'Sweep) actually finds a reference to the created js-string (see Test / POC above) on the stack. But the reference seems to originate from a stack-frame that's inside the GC handling stuff ( Here's my theory: AFAIK, stack memory does not get zeroed before or after a function call. So we will end up with a ghost-reference to out object that will be found by our conservative GC when scanning the whole stack. I added a new JSRT api ( This might also explain the behavior during my linux tests: The call to I'm still not sure though, why I could not reproduce the windows behavior locally. Also the last Microsoft build of the linux version does not show the test failures. |
The compiler inlines the `pattern` parameter of `WritePattern` onto the stack because it's only ever set to one value.
|
I added a new simple testcase to |
LibICU now requires c++ 17 but CC currently uses c++ 11:
ChakraCore/CMakeLists.txt
Line 375 in 36becec
This causes MacOS ci to fail.
📣 Changes
thow(...)bool std::uncaught_exception()is replaced byint uncaught_exceptions()see uncaught_exception💥 Breaking changes
@ppenzin
Fixes #3147
Fixes #6378