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 when using connection pool #18

Closed gx0r closed 9 years ago

gx0r commented 9 years ago

Node v0.10.33 / Mac OS X Yosemite.

PID 66449 received SIGSEGV for address: 0x0
0   segfault-handler.node               0x00000001008d647f _ZL16segfault_handleriP9__siginfoPv + 287
1   libsystem_platform.dylib            0x00007fff90d27f1a _sigtramp + 26
2   ???                                 0x0000000000000000 0x0 + 0
3   libclntsh.dylib.11.1                0x0000000104a22ef8 sltsmna + 40
4   libclntsh.dylib.11.1                0x000000010391bf0a kpuspsessionrelease + 298
5   libclntsh.dylib.11.1                0x0000000103a2520b OCISessionRelease + 251
6   libocci.dylib.11.1                  0x0000000100d19238 _ZN6oracle4occi14ConnectionImpl10do_destroyEjPvj + 372
7   libocci.dylib.11.1                  0x0000000100d19323 _ZN6oracle4occi14ConnectionImpl7destroyEjRKSs + 77
8   libocci.dylib.11.1                  0x0000000100d74ed6 _ZN6oracle4occi27StatelessConnectionPoolImpl17releaseConnectionEPNS0_10ConnectionERKSs + 174
9   oracle_bindings.node                0x00000001008de7ed _ZN10Connection15closeConnectionEv + 97
10  oracle_bindings.node                0x00000001008e061e _ZN10Connection9EIO_CloseEP9uv_work_s + 22
11  node                                0x0000000100391717 worker + 90
12  node                                0x0000000100387ef2 uv__thread_start + 25
13  libsystem_pthread.dylib             0x00007fff901d92fc _pthread_body + 131
14  libsystem_pthread.dylib             0x00007fff901d9279 _pthread_body + 0
15  libsystem_pthread.dylib             0x00007fff901d74b1 thread_start + 13

and

{ openConnections: 0,
  busyConnections: 0,
  maxConnections: 5,
  minConnections: 0,
  incrConnections: 1,
  busyOption: 0,
  timeout: 0,
  poolName: 'OCI:SP:CI1RqB9XBCjgVSrP6RSQZB' }
node(66600,0x110487000) malloc: *** error for object 0x100c01d58: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

Test case

// npm install express strong-oracle segfault-handler 

'use strict';
var SegfaultHandler = require('segfault-handler');
SegfaultHandler.registerHandler();

var fs = require('fs');
var http = require('http');

var db = require('./db.json');

var oracle = require('strong-oracle')();
var express = require('express');
var app = express();

oracle.createConnectionPool(db, function(err, pool) {
  if (err) {
    console.error(err);
    return;
  }
  console.log(pool.getInfo());

  function handleErr(err, res) {
    if (err) {
      if (res) res.status(500).send("" + err);
      console.error(err);
    }
  }

  app.get('/', function(req, res) {
    var query = "SELECT * FROM ( SELECT * FROM USERS ";

    for (var i = 0; i < 5; i++) {
      query = query + " UNION ALL SELECT * FROM USERS "
    }

    query = query + " ) WHERE ROWNUM <= 2500";
    pool.getConnection(function(err, conn) {
      if (err) handleErr(err);
      conn.execute(query, [], function(err, result) {
        if (err) handleErr(err);
        else {
          res.send(JSON.stringify(result));
          conn.close();
        }
      });
    });
  });

  app.listen(3000);

});

Reload http://localhost:3000/ in browser 3 times triggers segfault.

raymondfeng commented 9 years ago

Are you on version 1.2.2? We fixed a segfault issue recently.

gx0r commented 9 years ago

Yes, 1.2.2.

raymondfeng commented 9 years ago

FYI: I'm on vacation for Thanksgiving holidays. Will investigate later.

gx0r commented 9 years ago

Thanks @raymondfeng. No rush from me; I am just prototyping some stuff with these modules. I wrote https://www.npmjs.org/package/oracle-query-stream and am playing around with streaming queries from Oracle. I am actually the same person who reported the other segfault. The other segfault is fixed for me now (thank you!), and this segfault looks like it might be specific to the native connection pool code.

raymondfeng commented 9 years ago

It should have been fixed now. Please reopen if you see otherwise.

einfallstoll commented 9 years ago

I receive the following stacktrace:

ORA-24550: signal received: [si_signo=11] [si_errno=0] [si_code=128] [si_int=8] [si_ptr=0x8] [si_addr=(nil)]
kpedbg_dmp_stack()+404<-kpeDbgCrash()+210<-kpeDbgSignalHandler()+122<-skgesig_sigactionHandler()+229<-__sighandler()<-_ZN10Connection15CreateStatementEP12ExecuteBaton()+56<-_ZN10Connection11EIO_ExecuteEP9uv_work_s()+35<-worker()+144<-uv__thread_start()+33<-start_thread()+230
Segmentation fault

And installed is strong-oracle@1.6.4.

raymondfeng commented 9 years ago

@einfallstoll How to reproduce the problem?

einfallstoll commented 9 years ago

@raymondfeng Sometimes a restart of the server may help. Seems like it resolved itself.

oebspm commented 9 years ago

I get the same issue when trying to do some IO in the middle of data stream. Steps to reproduce:

  1. Prepare reader: var reader = self.connection.reader(sql_query, params);
  2. Stream some date using reader.nextRow
  3. In the middle of streaming do some inserts into another database and resume streaming when done