-
Notifications
You must be signed in to change notification settings - Fork 340
chakrashim: check return value for inspector call #261
Conversation
@@ -77,22 +77,25 @@ void V8Debugger::getCompiledScripts( | |||
int contextGroupId, | |||
std::vector<std::unique_ptr<V8DebuggerScript>>& result) { | |||
JsValueRef scripts; | |||
JsDiagGetScripts(&scripts); | |||
if (JsDiagGetScripts(&scripts) != JsNoError) { | |||
assert(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this assert needed? Seems like this is a legitimate situation that just needs to be handled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at code only expected failure is JsErrorDiagNotInDebugMode, in all other case you should at least get an empty array, so assert in all other cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kunalspathak This was discovered due to that test case, but it won't actually fix it. The test case needs to be marked flaky.
if (jsrt::InspectorHelpers::GetIntProperty(scripts, "length", &length) != JsNoError) { | ||
assert(false); | ||
return; | ||
} | ||
|
||
for (int i = 0; i < length; i++) { | ||
JsValueRef index; | ||
JsValueRef index = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to initialize these to JS_INVALID_REFERENCE
@agarwal-sandeep @digitalinfinity Can you take another look? I made changes to remove asserts and fast fail in more unexpected scenarios. I also return an error to the calls if they attempt to enable inspector when the launch argument is missing. |
|
||
return false; | ||
} | ||
|
||
JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) { | ||
if (!m_isolate->InContext()) return JavaScriptCallFrames(); | ||
|
||
JsValueRef stackTrace; | ||
JsValueRef stackTrace = JS_INVALID_REFERENCE; | ||
JsDiagGetStackTrace(&stackTrace); | ||
|
||
int length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int length; [](start = 2, length = 11)
Initialize to 0?
@@ -365,50 +357,47 @@ void V8Debugger::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth) { | |||
void V8Debugger::asyncTaskScheduled(const StringView& taskName, void* task, | |||
bool recurring) { | |||
// CHAKRA-TODO - Figure out what to do here | |||
assert(false); | |||
CHAKRA_VERIFY(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHAKRA_VERIFY(false); [](start = 2, length = 21)
CHAKRA_UNIMPLEMENTED is more appropriate for all non-implemented functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I forgot about that one.
} | ||
CHAKRA_VERIFY_NOERROR(jsrt::InspectorHelpers::HasProperty(eventData, | ||
"breakpointId", | ||
&hasBreakpointId)); | ||
|
||
if (hasBreakpointId) { | ||
breakpointIds.reserve(1); | ||
|
||
int breakpointId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
breakpointId [](start = 8, length = 12)
initialize to 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I caught all the rest of these now.
src/node.cc
Outdated
@@ -4786,7 +4786,7 @@ inline int Start_TTDReplay(Isolate* isolate, void* isolate_context, | |||
// Start debug agent when argv has --debug | |||
StartDebug(&env, nullptr, debug_options); | |||
|
|||
if (debug_options.inspector_enabled()) | |||
if (debug_options.inspector_enabled() && !v8_platform.InspectorStarted(&env)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!v8_platform.InspectorStarted(&env) [](start = 43, length = 35)
StartDebug above already does this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just matching the pattern used by the non-TTD start method.
Rest looks good to me |
08a893a
to
7d081b0
Compare
* Added an error that's returned when debugger can't be enabled * Added validation for the JsGetScripts return value * Switched to CHAKRA_VERIFY(_NOERROR) macros for all asserted calls * Fixed uninitialized variables * Fixed line lengths * Switched to CHAKRA_UNIMPLEMENTED for unimplemented methods PR-URL: nodejs#261 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com> Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
* Added an error that's returned when debugger can't be enabled * Added validation for the JsGetScripts return value * Switched to CHAKRA_VERIFY(_NOERROR) macros for all asserted calls * Fixed uninitialized variables * Fixed line lengths * Switched to CHAKRA_UNIMPLEMENTED for unimplemented methods PR-URL: nodejs#261 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com> Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
* Added an error that's returned when debugger can't be enabled * Added validation for the JsGetScripts return value * Switched to CHAKRA_VERIFY(_NOERROR) macros for all asserted calls * Fixed uninitialized variables * Fixed line lengths * Switched to CHAKRA_UNIMPLEMENTED for unimplemented methods PR-URL: nodejs#261 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com> Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
* Added an error that's returned when debugger can't be enabled * Added validation for the JsGetScripts return value * Switched to CHAKRA_VERIFY(_NOERROR) macros for all asserted calls * Fixed uninitialized variables * Fixed line lengths * Switched to CHAKRA_UNIMPLEMENTED for unimplemented methods PR-URL: nodejs#261 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com> Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
* Added an error that's returned when debugger can't be enabled * Added validation for the JsGetScripts return value * Switched to CHAKRA_VERIFY(_NOERROR) macros for all asserted calls * Fixed uninitialized variables * Fixed line lengths * Switched to CHAKRA_UNIMPLEMENTED for unimplemented methods PR-URL: nodejs#261 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com> Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
* Added an error that's returned when debugger can't be enabled * Added validation for the JsGetScripts return value * Switched to CHAKRA_VERIFY(_NOERROR) macros for all asserted calls * Fixed uninitialized variables * Fixed line lengths * Switched to CHAKRA_UNIMPLEMENTED for unimplemented methods PR-URL: nodejs#261 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com> Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
* Added an error that's returned when debugger can't be enabled * Added validation for the JsGetScripts return value * Switched to CHAKRA_VERIFY(_NOERROR) macros for all asserted calls * Fixed uninitialized variables * Fixed line lengths * Switched to CHAKRA_UNIMPLEMENTED for unimplemented methods PR-URL: nodejs#261 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com> Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
The return value for JsDiagGetScripts was not being validated and
continuing on during an error condition.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
chakrashim