strongloop / strong-oracle

Deprecated: Node.js Driver for Oracle databases (Use https://github.com/oracle/node-oracledb instead)
Other
45 stars 18 forks source link

segfault after garbage collection #70

Open vschoettke opened 8 years ago

vschoettke commented 8 years ago

The connection (result from oracle.connect) does not retain the oracle client so if the garbage collector (Mark-sweep) is run it will collect the client even if a connection is still open (OracleClient destructor is called) and the next call to a client function that depends on m_environment will crash.

I added a simple example for reproduction. you have to run it with node --expose-gc crash.js.

crash.js content:

var connectData = {
    host: '127.0.0.1',
    database: 'XE',
    user: 'user',
    password: 'password'
};

oracle.connect(connectData, function (err, connection) {
    // var oracle2 = oracle; // will work if comment is removed
    if (err) {
        throw new Error(err);
    }

    global.gc();

    var execResult = connection.executeSync(
        'SELECT 1 from DUAL',
        []
    );
    console.log("RESULT", execResult);

    connection.close();
});

If the comment-out code is reinserted oracle (OracleClient) will not be garbage collected because it's used inside the function.

FWIW: This was tested with occi 12.1.0.1.0 and 12.1.0.2.0 with Linux and node 4 and 6.

raymondfeng commented 8 years ago

@vschoettke Good catch. Would you like to submit a patch?