Skip to content

Conversation

@rhuanjl
Copy link
Collaborator

@rhuanjl rhuanjl commented Jan 13, 2018

Fixes #4482 and adds the POC of that bug as a test case.

Notes:

  1. ChakraCore segfaults during JsParseModuleSource in certain cases involving circular imports #4482 is mis-titled - it was a coincidence that the debugger was attached when the error was first noticed
  2. The issue is when there is a circular dependency in export slots between modules
  3. Not sure if this is the best fix but I couldn't see any other practical way to do it


uint SourceTextModuleRecord::GetLocalExportSlotIndexByExportName(PropertyId exportNameId)
{
if(!this->WasDeclarationInitialized())//allow for circular imports that reference each other's functions
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: coding style isnt a big deal for us, but I think we usually avoid using this-> unless it is to avoid ambiguity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Happy to remove though this-> is used 109 times in SourceTextModuleRecord so I was kinda copying what I'd seen there.

@jackhorton
Copy link
Contributor

/cc @boingoing , who is the person I know with the most context for ES Modules.

@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Jan 13, 2018

#4551 does this in a neater way so closing this PR

@rhuanjl rhuanjl closed this Jan 13, 2018
chakrabot pushed a commit that referenced this pull request Jan 16, 2018
Merge pull request #4551 from obastemur:module_circular

Alternative to #4550 , fixes #4482

Saw the test case brought by @rhuanjl to #4482 and the proposed fix at #4550 . After looking at the code, looks like couple of tiny changes are needed to module support.

I don't have much context on modules though. This PR is just a weekend after breakfast hacking. /cc @akroshg  @boingoing @rhuanjl

#### how it works

Separate `ModuleDeclarationInstantiation` into `ModuleDeclarationInstantiation` and `GenerateRootFunction`. This way, in case `childrenModuleSet` has circular dependents, we may instantiate all the modules prior to triggering the rest
chakrabot pushed a commit that referenced this pull request Jan 16, 2018
Merge pull request #4551 from obastemur:module_circular

Alternative to #4550 , fixes #4482

Saw the test case brought by @rhuanjl to #4482 and the proposed fix at #4550 . After looking at the code, looks like couple of tiny changes are needed to module support.

I don't have much context on modules though. This PR is just a weekend after breakfast hacking. /cc @akroshg  @boingoing @rhuanjl

#### how it works

Separate `ModuleDeclarationInstantiation` into `ModuleDeclarationInstantiation` and `GenerateRootFunction`. This way, in case `childrenModuleSet` has circular dependents, we may instantiate all the modules prior to triggering the rest
chakrabot pushed a commit that referenced this pull request Jan 17, 2018
…ircular import

Merge pull request #4551 from obastemur:module_circular

Alternative to #4550 , fixes #4482

Saw the test case brought by @rhuanjl to #4482 and the proposed fix at #4550 . After looking at the code, looks like couple of tiny changes are needed to module support.

I don't have much context on modules though. This PR is just a weekend after breakfast hacking. /cc @akroshg  @boingoing @rhuanjl

#### how it works

Separate `ModuleDeclarationInstantiation` into `ModuleDeclarationInstantiation` and `GenerateRootFunction`. This way, in case `childrenModuleSet` has circular dependents, we may instantiate all the modules prior to triggering the rest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChakraCore segfaults during JsParseModuleSource in certain cases involving circular imports

3 participants