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

Some fixes to sconsign #3238

Merged
merged 5 commits into from
Dec 1, 2018
Merged

Some fixes to sconsign #3238

merged 5 commits into from
Dec 1, 2018

Conversation

mwichmann
Copy link
Collaborator

Two locations which attempt to directly print an item tipped over on py3, so they now decode().

There seem to be cases where implicit dependencies do not have signatures, so instead of looping through the dep list and indexing into the signature list (IndexError), the two lists are now zipped, which means nothing is printed, but sconsign does not die (the zip technique is used in FS.py in the engine).

Minor PEP8 changes: spaces around operators; shorter lines; two-blanks rule around classes/functions. Also unused args changed to _ to show it was intentional.

Manpage updated slightly - the internal whichdb function explicitly looks for the .dblite suffix, so the claim that if it's not .dbm it is assumed to be dblite was not true.

sconsign still will not work on a dblite file which is not suffixed .dblite, but that is an existing problem, not a newly introduced one.

Signed-off-by: Mats Wichmann mats@linux.com

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated master/src/CHANGES.txt directory (and read the README.txt in that directory)
  • I have updated the appropriate documentation

mwichmann added a commit to mwichmann/scons that referenced this pull request Nov 10, 2018
The previous fix changed a failing line that printed something that
could be bytes in Py3 to do a decode. But it turned out that value can
be either str or bytes and the change failed the sconsign tests.
Use a try block instead of unconditionally calling decode.

Signed-off-by: Mats Wichmann <mats@linux.com>
@coveralls
Copy link

coveralls commented Nov 10, 2018

Coverage Status

Coverage decreased (-1.7%) to 79.967% when pulling 1c7b5c0 on mwichmann:mdw-sconsign into b4d710b on SCons:master.

try:
bkids = entry.bsources + entry.bdepends + entry.bimplicit
bkidsigs = entry.bsourcesigs + entry.bdependsigs + entry.bimplicitsigs
except AttributeError:
return None
result = []
for i in range(len(bkids)):
result.append(nodeinfo_string(bkids[i], bkidsigs[i], " "))
for bkid, bkidsig in zip(bkids, bkidsigs):
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be list comprehension.. (which is faster than for loop.. ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done... though I don't think this is a performance critial place, as it's outputting a bunch of strings to stdout and won't ever do anything with results beyond that....

mwichmann added a commit to mwichmann/scons that referenced this pull request Nov 10, 2018
Signed-off-by: Mats Wichmann <mats@linux.com>
@staticmethod
def printentries(dir, val):
try:
print('=== ' + dir + ':')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For clarity, this problem turned up on a nearly empty sconsign file, which on Python2, which did not error, displayed this way:

=== .:
help: None 0 0

Using Python 3, it threw an exception:

    print('=== ' + dir + ':')
TypeError: must be str, not bytes

result = []
for i in range(len(bkids)):
result.append(nodeinfo_string(bkids[i], bkidsigs[i], " "))
result = [nodeinfo_string(bkid, bkidsig, " ")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This problem turned up after a complex build, sconsign file is 2404476 bytes. thows an IndexError because bkidsigs is zero length, so indexing into it inside the loop failed. There are multiple instances in our build of this problem seen if we cause it not to error, but all come from the same sconscript/environment. This change causes sconsign not to error out but does not address why signatures are missing - it follows the manpage comment of "the lines are simply omitted" since in these cases the function will return an empty list aka None.

is assumed to be a traditional
<markup>.sconsign</markup>
file containing the signature entries
for a single directory.
If neither of those is true,
<command>sconsign</command>
attempts to guess the format (but will
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove will probably get it wrong..

Copy link
Collaborator Author

@mwichmann mwichmann Nov 12, 2018

Choose a reason for hiding this comment

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

No problem, but it's true. sconsign doesn't seem to know how to recognize the default sconsign "dblite" format in any meaningful way, it only recognizes the presence of the file extension. If not found, the effort is passed on to python's whichdb, which didn't seem to be able to guess. The sentence was intended to lead into the (existing) next sentence, which is that you can specify the format with an argument.

mwichmann added a commit to mwichmann/scons that referenced this pull request Nov 12, 2018
Signed-off-by: Mats Wichmann <mats@linux.com>
@mwichmann
Copy link
Collaborator Author

mwichmann commented Nov 29, 2018

So what is needed to make this workable? The main issue here is "fails on bad data"... probaby claiming that should be fixed is non-controversial, but the solution may not be. Around line 286, the change does what code in the engine does - zip the two lists so "extras" are dropped. That can be seen as masking the problem, rather than fixing the generation of the problem data in the engine.

@bdbaddog
Copy link
Contributor

I think likely the right thing to do is issue and error and exit.
Give as much info about the node in question.
If the sconsign is corrupt in any fashion, continuing to process it may not have much value.

Also perhaps a flag to keep going regardless...? (and or to just issue a warning instead of error and exit?)

Or just issue an error for each and keep going?

@mwichmann
Copy link
Collaborator Author

Well, in my case, it's one specific area it breaks on, so I'm happy enough for it to continue. Since the sconsign file problem doesn't seem to keep the project from building it seems it should be non-fatal to the sconsign program too. Any preferences on what the warning message should be?

@mwichmann
Copy link
Collaborator Author

So this is an example from our build with a message added, to prompt discussion about how it could be more informative:

=== out/linux/x86_64/debug/resource/csdk/connectivity/src/bt_le_adapter/linux:
<SCons.Script.SConscript.DefaultEnvironmentCall object at 0x7f42373d4c50>: None 0 0
SConscript: None 1533235008 6541
advertisement.c: 408a24058168ff92ab0b760a88e9ebca 1530798816 4191
Warning: missing information, 6 ids and 0 sigs

@bdbaddog
Copy link
Contributor

Maybe add a warning count at bottom of output?
It'd be easy to miss such is a full sconsign dump?

@acmorrow
Copy link
Contributor

acmorrow commented Dec 1, 2018

Regarding warnings, is there a way to make SCons warnings fatal? If not, I'd suggest adding such a feature, maybe called --fatal-warnings or --warnings-are-errors.

@mwichmann
Copy link
Collaborator Author

I pursued this for a while a few months ago, when I found out calling a missing sconscript didn't fail the build. In the end, something specific to the sconscript topic went in; I still have a patch for my alternative approach sitting around, which was to add a -werror flag (syntax like -warn) which allowed warnings to be treated as errors - selectively or all of them (-werror=all). I didn't really end up pushing that approach, and I felt like it needed more thought.

Two locations which attempt to directly print an item tipped over on py3,
so they now decode().

There seem to be cases where implicit dependencies do not have signatures,
so instead of looping through the dep list and indexing into the signature
list (IndexError), the two lists are now zipped, which means nothing is
printed, but sconsign does not die (the zip technique is used in FS.py
in the engine).

Minor PEP8 changes: spaces around operators; shorter lines; two-blanks
rule around classes/functions. Also unused args changed to _ to show
it was intentional.

Manpage updated slightly - the internal whichdb function explicitly
looks for the .dblite suffix, so the claim that if it's not .dbm it
is assumed to be dblite was not true.

sconsign still will not work on a dblite file which is not suffixed
.dblite, but that is an existing problem, not a newly introduced one.

Signed-off-by: Mats Wichmann <mats@linux.com>
The previous fix changed a failing line that printed something that
could be bytes in Py3 to do a decode. But it turned out that value can
be either str or bytes and the change failed the sconsign tests.
Use a try block instead of unconditionally calling decode.

Signed-off-by: Mats Wichmann <mats@linux.com>
Signed-off-by: Mats Wichmann <mats@linux.com>
Signed-off-by: Mats Wichmann <mats@linux.com>
Rather than just silently moving on, emit warning messages
if id count does not match signature count; summarize at the
end if there were any warnings.

Signed-off-by: Mats Wichmann <mats@linux.com>
@acmorrow
Copy link
Contributor

acmorrow commented Dec 1, 2018

@mwichmann - Sounds like a good approach though. Did it ever make it to a PR?

@mwichmann
Copy link
Collaborator Author

No, but I can push one up if it's interesting.

@bdbaddog
Copy link
Contributor

bdbaddog commented Dec 1, 2018

Is there any reasonable way to test this?

@mwichmann
Copy link
Collaborator Author

test what? sconsign printing warnings? maybe there's a way to dummy up an sconsign file with the issue - there's already a test for a corrupt file. Not sure I know enough to build an artificial file. Meanwhile, until I fix our mess, we're able to reliably create a sconsign file that crashes unpatches sconsign.

@bdbaddog
Copy link
Contributor

bdbaddog commented Dec 1, 2018

ok. Merging.

@bdbaddog bdbaddog merged commit 55eb6f5 into SCons:master Dec 1, 2018
@acmorrow
Copy link
Contributor

acmorrow commented Dec 4, 2018

@mwichmann - I'd definitely be interested in your work to add -werror to scons. It sounds like a worthwhile feature.

@mwichmann
Copy link
Collaborator Author

published as #3250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants