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

[SEGFAULT]: root_node nullptr check #35882

Conversation

gaurav1086
Copy link
Contributor

Accessing root_node after it may possibly still be nullptr.

@tensorflow-bot tensorflow-bot bot added the size:XS CL Change Size: Extra Small label Jan 14, 2020
@tensorflow-bot tensorflow-bot bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Jan 15, 2020
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jan 15, 2020
@aaroey aaroey removed their request for review January 15, 2020 16:52
@rthadur rthadur added this to Assigned Reviewer in PR Queue via automation Jan 15, 2020
@rthadur rthadur self-assigned this Jan 15, 2020
@rthadur
Copy link
Contributor

rthadur commented Jan 15, 2020

@gaurav1086 there are some sanity checks failing , can you please take a look.
Here is the link:https://source.cloud.google.com/results/invocations/b15d98de-a35a-4020-8fdf-3d3978f2c401/log

@gaurav1086
Copy link
Contributor Author

@rthadur , thanks a lot for the review.
The two tests that are failing are:
do_pip_smoke_test: Pip Smoke Test: Checking py_test dependencies exist in pip package
do_bazel_nobuild: bazel nobuild
They do not seem to be related to my change. I will run the tests again to see if they prevail.

@mihaimaruseac
Copy link
Collaborator

The sanity failures are due to https://support.sonatype.com/hc/en-us/articles/360041287334

This is a bazel failure, hoping it will be fixed soon

@gaurav1086
Copy link
Contributor Author

@mihaimaruseac thanks for the clarification.

@mihaimaruseac mihaimaruseac added the kokoro:force-run Tests on submitted change label Jan 15, 2020
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jan 15, 2020
mihaimaruseac
mihaimaruseac previously approved these changes Jan 15, 2020
PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer Jan 15, 2020
@tensorflow-bot tensorflow-bot bot added the kokoro:force-run Tests on submitted change label Jan 15, 2020
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jan 15, 2020
@rthadur rthadur added ready to pull PR ready for merge process and removed ready to pull PR ready for merge process labels Jan 15, 2020
Copy link
Contributor

@sanjoy sanjoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to return early, LOG(FATAL) << msg crashes the program.

PR Queue automation moved this from Approved by Reviewer to Reviewer Requested Changes Jan 16, 2020
@gaurav1086
Copy link
Contributor Author

Yes. You are right. In file: tensorflow/core/platform/default/logging.cc:237, it calls abort(), when the LOG_LEVEL is FATAL,

if (severity_ == FATAL) {
abort();
}

However, I think having this change wouldn't hurt as being good coding practice.

@sanjoy
Copy link
Contributor

sanjoy commented Jan 17, 2020

However, I think having this change wouldn't hurt as being good coding practice.

Can you share why you think this is good coding practice?

@gaurav1086
Copy link
Contributor Author

@sanjoy , If someone in the future by mistake removes the "LOG(FATAL) << msg" statement or changes the log level from FATAL to something else, it might crash the code by accessing the root_node(nullptr). So good to have these additional checks (without undermining performance). However it's obviously a choice.

@sanjoy
Copy link
Contributor

sanjoy commented Jan 17, 2020

@sanjoy , If someone in the future by mistake removes the "LOG(FATAL) << msg" statement or changes the log level from FATAL to something else, it might crash the code by accessing the root_node(nullptr). So good to have these additional checks (without undermining performance). However it's obviously a choice.

But there are cons to adding the return false; as well. For instance if someone does not know LOG(FATAL) crashes , they might assume that ParseInstructionList legitimately returns false if root_node is nullptr.

IMO the right fix here is to add a clear comment that LOG(FATAL) crashes so the immediately following deref of root_node is OK. What do you think?

@gaurav1086 gaurav1086 force-pushed the hlo_parser_nullptr_dereferencing branch from 9203702 to 8f56248 Compare January 18, 2020 00:33
@tensorflow-bot tensorflow-bot bot removed the ready to pull PR ready for merge process label Jan 18, 2020
@gaurav1086
Copy link
Contributor Author

Done.

@@ -636,7 +636,7 @@ bool HloParserImpl::ParseInstructionList(HloComputation** computation,
// the pool, which should not happen.
if (root_node == nullptr) {
LOG(FATAL) << "instruction " << root_name
<< " was marked as ROOT but the parser has not seen it before";
<< " was marked as ROOT but the parser has not seen it before"; // abort()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being so pedantic, but can you please use a full english sentence here? // abort() reads like code that was accidentally commented out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, please check now. Thanks.

sanjoy
sanjoy previously approved these changes Jan 19, 2020
PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer Jan 19, 2020
@tensorflow-bot tensorflow-bot bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Jan 19, 2020
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jan 19, 2020
@mihaimaruseac mihaimaruseac added the kokoro:force-run Tests on submitted change label Jan 21, 2020
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jan 21, 2020
PR Queue automation moved this from Approved by Reviewer to Reviewer Requested Changes Jan 21, 2020
@tensorflow-bot tensorflow-bot bot removed the ready to pull PR ready for merge process label Jan 21, 2020
PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer Jan 22, 2020
@tensorflow-bot tensorflow-bot bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Jan 22, 2020
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jan 22, 2020
tensorflow-copybara pushed a commit that referenced this pull request Jan 24, 2020
…ncing

PiperOrigin-RevId: 291440430
Change-Id: Ie588fccf880c234f15140421cabf993c606e3017
@tensorflow-copybara tensorflow-copybara merged commit 0f909a3 into tensorflow:master Jan 24, 2020
PR Queue automation moved this from Approved by Reviewer to Merged Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes ready to pull PR ready for merge process size:XS CL Change Size: Extra Small
Projects
PR Queue
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

7 participants