镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Debug build doesn't work on Windows #25593

Description

@seishun
  • Version: master
  • Platform: Windows
  • Subsystem: n/a

A debug build built using vcbuild debug and the latest VS2017 exits immediately. It seems to be a compiler bug: the EnvironmentOptionsParser instance is initialized before the DebugOptionsParser instance, causing a segfault. I would like someone to confirm the issue before I continue looking into it.

Activity

  1. added
    windowsIssues and PRs related to the Windows platform.
    on Jan 20, 2019
  2. seishun commented on Jan 20, 2019

    @seishun
    ContributorAuthor

    cc @nodejs/platform-windows

  3. refack commented on Jan 20, 2019

    @refack
    Contributor

    Confirmed.
    I'm not sure it's a Compiler bug, it might be Undefined Behavior. I think I was able to fix this by reordering the singleton declarations (*OptionsParser::instance) in node_options.cc by their order of dependency. e.g.

    const DebugOptionsParser DebugOptionsParser::instance;

  4. seishun commented on Jan 20, 2019

    @seishun
    ContributorAuthor

    They are already in the dependency order, aren't they?

  5. refack commented on Jan 20, 2019

    @refack
    Contributor

    They are already in the dependency order, aren't they?

    I think there is something more subtle that is related to static init order. But I didn't fully grok this.

    I found my patch: #25596

  6. seishun commented on Jan 20, 2019

    @seishun
    ContributorAuthor

    The static init order thing is irrelevant, they are all in the same translation unit here.

  7. refack commented on Jan 20, 2019

    @refack
    Contributor

    they are all in the same translation unit here.

    IIUC, not necessarily since they are used in two other places:

    options_parser::PerIsolateOptionsParser::instance.Parse(

    and
    options_parser::PerProcessOptionsParser::instance.Parse(

  8. seishun commented on Jan 20, 2019

    @seishun
    ContributorAuthor

    That's a usage, not a definition.

  9. refack commented on Jan 20, 2019

    @refack
    Contributor

    Are we sure those two lines are not part of some other static construction?
    Or alternatively that

    const DebugOptionsParser DebugOptionsParser::instance;
    isn't optimized away?

  10. addaleax commented on Jan 20, 2019

    @addaleax
    Member

    Are we sure those two lines are not part of some other static construction?

    Based on grepping the source code for cli_options, I would say that this is not the case, yes. The way in which @seishun narrowed down the issue might tell us more?

  11. seishun commented on Jan 20, 2019

    @seishun
    ContributorAuthor

    Narrowing it down was easy, I just pressed F5 and saw that the DebugOptionsParser instance is full of zeroes inside the EnvironmentOptionsParser constructor, and then confirmed it by setting a breakpoint in the DebugOptionsParser and seeing that it's never hit.

    I'm now trying to come up with a minimal test case.

  12. seishun commented on Jan 20, 2019

    @seishun
    ContributorAuthor

    From dumpbin /all node_options.obj output:

                                                    Symbol    Symbol
     Offset    Type              Applied To         Index     Name
     --------  ----------------  -----------------  --------  ------
     00000000  ADDR64            00000000 00000000      5219  ??__E?instance@EnvironmentOptionsParser@options_parser@node@@2V123@B@@YAXXZ (void __cdecl `dynamic initializer for 'public: static class node::options_parser::EnvironmentOptionsParser const node::options_parser::EnvironmentOptionsParser::instance''(void))
     00000008  ADDR64            00000000 00000000      521C  ??__E?instance@PerIsolateOptionsParser@options_parser@node@@2V123@B@@YAXXZ (void __cdecl `dynamic initializer for 'public: static class node::options_parser::PerIsolateOptionsParser const node::options_parser::PerIsolateOptionsParser::instance''(void))
     00000010  ADDR64            00000000 00000000      521F  ??__E?instance@PerProcessOptionsParser@options_parser@node@@2V123@B@@YAXXZ (void __cdecl `dynamic initializer for 'public: static class node::options_parser::PerProcessOptionsParser const node::options_parser::PerProcessOptionsParser::instance''(void))
     00000018  ADDR64            00000000 00000000      5208  ??__Ecli_options_mutex@per_process@node@@YAXXZ (void __cdecl node::per_process::`dynamic initializer for 'cli_options_mutex''(void))
     00000020  ADDR64            00000000 00000000      520F  ??__Ecli_options@per_process@node@@YAXXZ (void __cdecl node::per_process::`dynamic initializer for 'cli_options''(void))
     00000028  ADDR64            00000000 00000000      5216  ??__E?instance@DebugOptionsParser@options_parser@node@@2V123@B@@YAXXZ (void __cdecl `dynamic initializer for 'public: static class node::options_parser::DebugOptionsParser const node::options_parser::DebugOptionsParser::instance''(void))
    

    I wonder if cli_options_mutex or cli_options is throwing it off somehow?

  13. addaleax commented on Jan 20, 2019

    @addaleax
    Member

    @seishun I think this means that DebugOptionsParser is actually initialized last, right? If so, I think this is pretty clearly a compiler bug…

  14. seishun commented on Jan 20, 2019

    @seishun
    ContributorAuthor

    Correct, this is from the .CRT$XCU section, which defines the dynamic initialization order (CRT Initialization).

  15. seishun commented on Jan 20, 2019

    @seishun
    ContributorAuthor

    I'm now trying to come up with a minimal test case.

    Too difficult, the bug disappears when removing random lines. Is there someone in the Visual Studio team we could ping here?

  16. 6 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildIssues and PRs related to Node.js builds or CI infrastructure.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions