Skip to content

Error when getting the CFG #17

@sabaa

Description

@sabaa

Hello,

I get an exception when I try to get the CFG for the following code:

const fs = require('fs');
fs.open('/open/some/file.txt', 'r', (err, fd) => {
  if (err) throw err;
  fs.close(fd, (err) => {
    if (err) throw err;
  });
});

The error is:

TypeError: Cannot set property 'nextSibling' of undefined
    at backToFront (node_modules/esgraph/lib/index.js:369:56)
    at BlockOrProgram (node_modules/esgraph/lib/index.js:374:7)
    at recurse (node_modules/walkes/index.js:20:10)
    at /Users/saba/Documents/northeastern/research/async-miner/node_modules/walkes/index.js:40:10
    at Array.forEach (<anonymous>)
    at checkProps (node_modules/walkes/index.js:34:20)
    at recurse (node_modules/walkes/index.js:20:10)
    at Array.map (<anonymous>)
    at /Users/saba/Documents/northeastern/research/async-miner/node_modules/walkes/index.js:38:15
    at Array.forEach (<anonymous>)
    at checkProps (node_modules/walkes/index.js:34:20)
    at recurse (node_modules/walkes/index.js:20:10)
    at /Users/saba/Documents/northeastern/research/async-miner/node_modules/walkes/index.js:40:10
    at Array.forEach (<anonymous>)
    at checkProps (node_modules/walkes/index.js:34:20)
    at recurse (node_modules/walkes/index.js:20:10)
    at backToFront (node_modules/esgraph/lib/index.js:370:9)
    at BlockOrProgram (node_modules/esgraph/lib/index.js:374:7)
    at recurse (node_modules/walkes/index.js:20:10)
    at walker (node_modules/walkes/index.js:24:9)
    at linkSiblings (node_modules/esgraph/lib/index.js:376:5)
    at ControlFlowGraph (node_modules/esgraph/lib/index.js:47:3)
    at Parser.getCfg (app/parser.js:25:17)

I don't have any issues for calls that are not nested. E.g., if the fs.close() is not included, I won't have any issues.

I'd appreciate any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions