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

test: add test for postmortem metadata validation #17685

Merged
merged 1 commit into from
Dec 18, 2017

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Dec 14, 2017

This commit adds a test to validate postmortem metadata. There are a lot more constants to be added, but I wanted to get feedback on the idea before spending the time on all of the constants.

The idea is that we can include a list of metadata constants used by llnode, mdb_v8, and any other postmortem tools (if there are any). When this test runs, it will let us know if the constants have gone missing. Currently, we only find that out if the ustack helper compilation breaks, or someone reports a bug to llnode/mdb_v8.

This test doesn't need to run on all platforms (it currently depends on nm), but it would be great if it ran on at least one platform that the V8 team tests on.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@richardlau
Copy link
Member

cc @nodejs/diagnostics @nodejs/post-mortem

@richardlau
Copy link
Member

This test doesn't need to run on all platforms (it currently depends on nm),

Perhaps on Windows we could use dumpbin.

@Trott
Copy link
Member

Trott commented Dec 14, 2017

Nit: Maybe include a comment at the top of the test explaining what the test does?

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

I have some misgivings about this test:

  1. It only catches deletions, not semantic changes. Some might say "better than nothing" but I say "false sense of security." Integration testing with llnode's test suite will give better results.

  2. It's going to be tempting to just add everything from nm node | grep v8dbg even though llnode and mbd use only a fraction of it. That's not useful, just maintenance make-work, but so is updating it after every llnode or mdb change.

  3. Who is going to fix it when it starts failing and in what time frame? I've mentioned elsewhere that I don't think updating the metadata script should be the responsibility of the V8 upgrader. Neither should it block upgrades.

if (nm.error && nm.error.errno === 'ENOENT')
common.skip('nm not found on system');

const symbolRe = /\s(_v8dbg_.+)$/;
Copy link
Member

Choose a reason for hiding this comment

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

The underscore prefix is a macos-ism.

@cjihrig
Copy link
Contributor Author

cjihrig commented Dec 15, 2017

@bnoordhuis regarding your second point - I thought of that, and I've only added the metadata used by the most recent version of llnode. I just haven't pushed it up yet because there is already a missing constant.

Regarding your first point - I agree that test suite integration would be more in depth.
Regarding your third point - For the past few months I've been fixing these in nodejs/node-v8 because they only register as SmartOS compilation issues, which isn't the real underlying problem. Other than the original TurboFan upgrade, it's been a fairly smooth process. Even if this doesn't run in CI (although it could be marked flakey), I think it would be useful to have until we have something better.

UPDATE: pushed this up. The missing constant was v8dbg_frametype_JavaScriptFrame, which no longer exists (and doesn't appear to be needed) in V8 6.3. The only other difference from Node 8 is that v8dbg_frametype_ConstructEntryFrame would be replaced with v8dbg_frametype_EntryConstructFrame. So, theoretically, this could be backported to Node 8, although that probably isn't necessary.

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

LGTM with the underscore prefix removed. Also we should mark this as flaky to avoid blocking V8 upgrades while being able to get notified when the constants were missing.

@joyeecheung
Copy link
Member

cc @nodejs/post-mortem

@cjihrig cjihrig force-pushed the metadata-test branch 2 times, most recently from dfd6168 to 8efc0a5 Compare December 15, 2017 04:22
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

LGTM if you mark it FLAKY.

const symbols = nm.stdout.toString().split('\n').map((line) => {
const match = line.match(symbolRe);

return match && match[1].replace(/^_/, '');
Copy link
Member

Choose a reason for hiding this comment

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

The _ isn't captured, the replace is a no-op.

@cjihrig
Copy link
Contributor Author

cjihrig commented Dec 15, 2017

nm seems to behave a little differently on AIX. I don't have access to any AIX machines though.

@richardlau
Copy link
Member

nm seems to behave a little differently on AIX. I don't have access to any AIX machines though.

-bash-4.3$ nm /tmp/usenode.riclau/node-v8.9.3-aix-ppc64/bin/node
0654-210 /tmp/usenode.riclau/node-v8.9.3-aix-ppc64/bin/node is not valid in the current object file mode.
        Use the -X option to specify the desired object mode.
-bash-4.3$

nm on AIX reference: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.cmds4/nm.htm

The default is to process 32-bit object files (ignore 64-bit objects). The mode can also be set with the OBJECT_MODE environment variable. For example, OBJECT_MODE=64 causes nm to process any 64-bit objects and ignore 32-bit objects. The -X flag overrides the OBJECT_MODE variable.

So probably want either -X64 or -Xany. Also probably -B as well (so that the names are at the end of the line so the regular expression will correctly match), otherwise you get output like this:

v8dbg_bit_field3_dictionary_map_shift D   537608848

instead of (with -B):

 537608848 D v8dbg_bit_field3_dictionary_map_shift

cc @nodejs/platform-aix

@cjihrig
Copy link
Contributor Author

cjihrig commented Dec 15, 2017

@cjihrig cjihrig force-pushed the metadata-test branch 4 times, most recently from b05f5d2 to 5708da8 Compare December 18, 2017 12:49
@cjihrig
Copy link
Contributor Author

cjihrig commented Dec 18, 2017

All nits should be addressed. Also replaced a map()-filter() sequence with a single reduce(). CI: https://ci.nodejs.org/job/node-test-pull-request/12171/

This commit adds a test to validate postmortem debugging metadata.
When this test runs, it can check for the presence of metadata
constants used by tools such as llnode and mdb and report if any
have accidentally been removed.

PR-URL: nodejs#17685
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@cjihrig cjihrig merged commit 68c63a9 into nodejs:master Dec 18, 2017
@cjihrig cjihrig deleted the metadata-test branch December 18, 2017 14:27
MylesBorins pushed a commit that referenced this pull request Jan 8, 2018
This commit adds a test to validate postmortem debugging metadata.
When this test runs, it can check for the presence of metadata
constants used by tools such as llnode and mdb and report if any
have accidentally been removed.

PR-URL: #17685
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MylesBorins pushed a commit that referenced this pull request Jan 9, 2018
This commit adds a test to validate postmortem debugging metadata.
When this test runs, it can check for the presence of metadata
constants used by tools such as llnode and mdb and report if any
have accidentally been removed.

PR-URL: #17685
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@MylesBorins MylesBorins mentioned this pull request Jan 10, 2018
boingoing pushed a commit to nodejs/node-chakracore that referenced this pull request Jan 18, 2018
This commit adds a test to validate postmortem debugging metadata.
When this test runs, it can check for the presence of metadata
constants used by tools such as llnode and mdb and report if any
have accidentally been removed.

PR-URL: nodejs/node#17685
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@MylesBorins
Copy link
Contributor

This lands cleanly on v8.x and the tests pass so I landed in on to staging. For v6.x it was easy to resolve the conflict but tests failed locally

=== release test-postmortem-metadata ===
Path: parallel/test-postmortem-metadata
assert.js:84
  throw new assert.AssertionError({
  ^
AssertionError: Missing constants: v8dbg_class_FixedTypedArrayBase__external_pointer__Object,v8dbg_class_JSObject__internal_fields__uintptr_t,v8dbg_class_JSReceiver__raw_properties_or_hash__Object,v8dbg_class_SharedFunctionInfo__compiler_hints__int,v8dbg_class_SharedFunctionInfo__end_position__int,v8dbg_class_SharedFunctionInfo__internal_formal_parameter_count__int,v8dbg_class_SharedFunctionInfo__raw_name__Object,v8dbg_class_SharedFunctionInfo__start_position_and_type__int,v8dbg_class_ThinString__actual__String,v8dbg_context_idx_closure,v8dbg_context_idx_prev,v8dbg_context_min_slots,v8dbg_frametype_ConstructEntryFrame,v8dbg_namedictionary_prefix_start_index,v8dbg_namedictionaryshape_entry_size,v8dbg_namedictionaryshape_prefix_size,v8dbg_prop_attributes_mask,v8dbg_prop_attributes_shift,v8dbg_prop_attributes_DONT_ENUM,v8dbg_prop_attributes_DONT_ENUM,v8dbg_prop_attributes_NONE,v8dbg_prop_attributes_READ_ONLY,v8dbg_prop_kind_mask,v8dbg_prop_kind_Accessor,v8dbg_prop_kind_Data,v8dbg_prop_location_mask,v8dbg_prop_location_shift,v8dbg_prop_location_Descriptor,v8dbg_prop_location_Field,v8dbg_APIObjectType,v8dbg_SpecialAPIObjectType,v8dbg_ThinStringTag
    at Object.<anonymous> (/Users/mborins/code/node/v6.x/test/parallel/test-postmortem-metadata.js:34:8)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.runMain (module.js:611:10)
    at run (bootstrap_node.js:387:7)
    at startup (bootstrap_node.js:153:9)
    at bootstrap_node.js:500:3
Command: out/Release/node /Users/mborins/code/node/v6.x/test/parallel/test-postmortem-metadata.js

Looks like it might be a pain to backport. Feel free to put dont-land-on-v6.x

MylesBorins pushed a commit that referenced this pull request Jan 23, 2018
This commit adds a test to validate postmortem debugging metadata.
When this test runs, it can check for the presence of metadata
constants used by tools such as llnode and mdb and report if any
have accidentally been removed.

PR-URL: #17685
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@gibfahn
Copy link
Member

gibfahn commented Jan 24, 2018

Depends on #16413, so will only go into 8.x if #16413 does.

@gibfahn gibfahn mentioned this pull request Jan 24, 2018
2 tasks
MylesBorins pushed a commit that referenced this pull request May 22, 2018
This commit adds a test to validate postmortem debugging metadata.
When this test runs, it can check for the presence of metadata
constants used by tools such as llnode and mdb and report if any
have accidentally been removed.

PR-URL: #17685
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Trott added a commit to Trott/io.js that referenced this pull request Jun 2, 2018
test-postmortem-metadata does not ever seem to fail on master. According
to Michaël Zasso, when it fails locally for him during a V8 upgrade, he
pings Colin Ihrig who fixes it almost immediately.

There was some discussion about marking it flaky when it first landed
but it's not clear to me that it is necessary. (We can always mark it
flaky again if it turns out that it is necessary.)

The reason I want this test removed from the status file for flaky tests
is that I believe that file can and should be used as a list of tests to
fix. But this test doesn't need any fixing.

Refs: nodejs#17685
MylesBorins pushed a commit that referenced this pull request Jun 14, 2018
This commit adds a test to validate postmortem debugging metadata.
When this test runs, it can check for the presence of metadata
constants used by tools such as llnode and mdb and report if any
have accidentally been removed.

PR-URL: #17685
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@MylesBorins MylesBorins mentioned this pull request Jul 9, 2018
rvagg pushed a commit that referenced this pull request Aug 16, 2018
This commit adds a test to validate postmortem debugging metadata.
When this test runs, it can check for the presence of metadata
constants used by tools such as llnode and mdb and report if any
have accidentally been removed.

PR-URL: #17685
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
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.

9 participants