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

Tidy hash generation bugfixes #1114

Merged
merged 1 commit into from
Nov 14, 2017
Merged

Conversation

bruntib
Copy link
Contributor

@bruntib bruntib commented Nov 10, 2017

On server side the linecache Python module cached the files from which
it returned a given line. If the file changed and the file was queried
from the cache then the given line returned from the old file version.

In case of ClangTidy the bug hash is generated by CodeChecker. Because
of the previous bug a false bug hash was generated if the line number of
the bug event changed. So now the bug hash is computed on client side
and is written to the .plist file. Server will use this hash instead of
generating it again.

When a bug path changed because it is shifted a few lines downer then
the corresponding line number was only updated in BagPathEvent and
BugReportPoint tables, but not in Report table. This caused a GUI
glitch, i.e. it didn't jump to the correct position when a report was
opened.

Fixes #1106

@bruntib bruntib added this to the release 6.2 milestone Nov 10, 2017
@whisperity whisperity added the analyzer 📈 Related to the analyze commands (analysis driver) label Nov 10, 2017
Return the given line from the file. If line_no is larger than the number
of lines in the file then empty string returns.
"""
with open(file_name) as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

Handling the file error exceptions would be nice here.

@@ -298,6 +300,18 @@ def _create_diag(message, fmap):
diag['path'].append(PListConverter._create_event_from_note(message,
fmap))

hash_content = [os.path.basename(message.path),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please factor out the hash generation to one module and add comment why is it generated this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, why did we add code to generate the hash? Didn't we already have such code? If that is not used shouldn't we delete that?

@csordasmarton
Copy link
Contributor

@bruntib Unit test cases are failed!

Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

Shouldn't we have a test-case for this?

message.message,
get_line(message.path, message.line),
str(message.column),
str(message.column)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intentional to include the column twice?

@@ -298,6 +300,18 @@ def _create_diag(message, fmap):
diag['path'].append(PListConverter._create_event_from_note(message,
fmap))

hash_content = [os.path.basename(message.path),
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, why did we add code to generate the hash? Didn't we already have such code? If that is not used shouldn't we delete that?

@bruntib bruntib force-pushed the tidy_hash_bugfix branch 2 times, most recently from 89b547b to ca8b7e0 Compare November 13, 2017 17:36
Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

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

-Make sure that you create a ticket for the incorrect processing of report hashes in case the report hash is missing from the test file

@@ -84,7 +84,7 @@ def compare_ctrl_sections(curr, prev):
from_col = m_loc.get('col')
until_col = m_loc.get('col')

line_content = linecache.getline(source_file, source_line)
line_content = get_line(source_file, source_line)

if line_content == '' and not os.path.isfile(source_file):
LOG.debug("Failed to generate report hash.")
Copy link
Member

Choose a reason for hiding this comment

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

This should be an ERROR level log

@@ -11,6 +11,8 @@
<string>clang-analyzer-core.DivideZero</string>
<key>description</key>
<string>Division by zero</string>
<key>issue_hash_content_of_line_in_context</key>
<string>b650887dabcbf08d794479d8d9c652b1</string>
Copy link
Member

Choose a reason for hiding this comment

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

Fix this hash. This hash does not contain the source code line.

@@ -84,7 +84,7 @@ def compare_ctrl_sections(curr, prev):
from_col = m_loc.get('col')
until_col = m_loc.get('col')

line_content = linecache.getline(source_file, source_line)
line_content = get_line(source_file, source_line)
Copy link
Member

Choose a reason for hiding this comment

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

If the hash is generated on the server side, because the original PLIST does not contain it, then the source_file will point to the path that is only valid on the client's machine.

Either fix this, or put here a fixme and create an issue

Copy link
Contributor

Choose a reason for hiding this comment

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

Before the store do we overwrite the file paths in the plist files, to the directory where they are extracted, or the path changes are only done during the report processing and the actual plist files are not modified?

@@ -9,12 +9,15 @@
"""

import copy
import hashlib
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused import.

import json
import os
import plistlib
import re

from libcodechecker.logger import LoggerFactory
from libcodechecker.report import generate_report_hash
from libcodechecker.util import get_line
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused import

if line_no == 0:
return line
return ''
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

No exception type(s) specified. For more information see Codacy.

Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

LGTM!

On server side the linecache Python module cached the files from which
it returned a given line. If the file changed and the file was queried
from the cache then the given line returned from the old file version.

In case of ClangTidy the bug hash is generated by CodeChecker. Because
of the previous bug a false bug hash was generated if the line number of
the bug event changed. So now the bug hash is computed on client side
and is written to the .plist file. Server will use this hash instead of
generating it again.

When a bug path changed because it is shifted a few lines downer then
the corresponding line number was only updated in BagPathEvent and
BugReportPoint tables, but not in Report table. This caused a GUI
glitch, i.e. it didn't jump to the correct position when a report was
opened.
@dkrupp dkrupp merged commit 9050cb4 into Ericsson:master Nov 14, 2017
@bruntib bruntib deleted the tidy_hash_bugfix branch November 14, 2017 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) bugfix 🔨
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants