{"action":"created","issue":{"url":"https://api.github.com/repos/oracle/node-oracledb/issues/609","repository_url":"https://api.github.com/repos/oracle/node-oracledb","labels_url":"https://api.github.com/repos/oracle/node-oracledb/issues/609/labels{/name}","comments_url":"https://api.github.com/repos/oracle/node-oracledb/issues/609/comments","events_url":"https://api.github.com/repos/oracle/node-oracledb/issues/609/events","html_url":"https://github.com/oracle/node-oracledb/issues/609","id":205980131,"number":609,"title":"segmentation fault when querying clobs using promises/async","user":{"login":"jarlestabell","id":1764576,"avatar_url":"https://avatars.githubusercontent.com/u/1764576?v=3","gravatar_id":"","url":"https://api.github.com/users/jarlestabell","html_url":"https://github.com/jarlestabell","followers_url":"https://api.github.com/users/jarlestabell/followers","following_url":"https://api.github.com/users/jarlestabell/following{/other_user}","gists_url":"https://api.github.com/users/jarlestabell/gists{/gist_id}","starred_url":"https://api.github.com/users/jarlestabell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarlestabell/subscriptions","organizations_url":"https://api.github.com/users/jarlestabell/orgs","repos_url":"https://api.github.com/users/jarlestabell/repos","events_url":"https://api.github.com/users/jarlestabell/events{/privacy}","received_events_url":"https://api.github.com/users/jarlestabell/received_events","type":"User","site_admin":false},"labels":[{"id":161714386,"url":"https://api.github.com/repos/oracle/node-oracledb/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-02-07T18:51:21Z","updated_at":"2017-02-08T19:41:09Z","closed_at":null,"body":"I just tried making some async code using node-oracledb version 1.12 and TypeScript. I'm playing around to learn the abstractions, so it's not meant to be efficient or anything! (I noticed the current TS-type wrapper is missing the getRows function)\r\n\r\nHere's a simple class having two member functions:\r\n\r\n    export class ConnectionWrapper {\r\n        constructor(private readonly connection: oracledb.IConnection) {\r\n        }\r\n        executeAsResultSet = async (sql: string, bindParams: any[], asObjects: boolean):     Promise<oracledb.IResultSet> => {\r\n            const options = {\r\n               resultSet: true, outFormat: asObjects ? oracledb.OBJECT : oracledb.ARRAY,\r\n\r\n            };\r\n            const maybeResultSet = (await this.connection.execute(sql, bindParams, options)).resultSet\r\n            if (maybeResultSet) {\r\n                return maybeResultSet\r\n            }\r\n            else\r\n                throw Error('Unable to get resultset from query');\r\n        }\r\n\r\n        executeForEachObject = async <T>(sql: string, params: any[], handler: (T) => void) => {\r\n            const resultSet = await this.executeAsResultSet(sql, params, true);\r\n            try {\r\n                let row = (await resultSet.getRow()) as T;\r\n                console.log(`row: ${JSON.stringify(row)}`);\r\n                while (row) {\r\n                    handler(row);\r\n                    console.log(`fetchAsString: ${JSON.stringify(oracledb.fetchAsString)}`);\r\n                    row = (await resultSet.getRow()) as T;\r\n                    console.log(`row: ${JSON.stringify(row)}`);\r\n                }\r\n\r\n            } finally {\r\n                resultSet.close();\r\n            }\r\n        }\r\n    }\r\n\r\nThe logging is only frantic attempts at debuggig! :)\r\n(oracledb.fetchAsString is  [2006], as expected. )\r\n\r\nHere is how I call it:\r\n\r\n       const svar = await myConn.executeForEachObject<model.Gjenstand>(`select ART_ID, MUSEUMSNR, RAPPORT from usd_ark_gjenstand_ntnu.gjenstand t where t.art_id < 140`, [], \r\n            gj=> console.log(`art_id: ${gj.ART_ID} museumsnr: ${gj.MUSEUMSNR}`)\r\n       );\r\n\r\nRapport is a CLOB. It is empty in all rows returned for the query.\r\nI consistently get a segfault, but it varies how many rows it fetches before I get the segfault.\r\nI don't get this segfault if I remove the Rapport field.\r\nI get the segfault irrespective of whether I set:\r\n     `(oracledb as any).fetchAsString = [ oracledb.CLOB ]; `\r\nor not.\r\n\r\nHere's a crash log:\r\nPID 363 received SIGSEGV for address: 0x91\r\n/home/jarle/src/dsmusit/data-transformation/2017/ntnu-vm-gjenstandstype-normering/node_modules/segfault-handler/build/Release/segfault-ha\r\nndler.node(+0x1b98)[0x7f8db8d5eb98]\r\n/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f8dd71d5390]\r\n/home/jarle/src/dsmusit/data-transformation/2017/ntnu-vm-gjenstandstype-normering/node_modules/oracledb/build/Release/oracledb.node(_ZN10\r\nConnection11cbDynDefineEPvmjPmPS0_PPjS2_PPt+0x36)[0x7f8dd4bc7dd6]\r\n/home/jarle/src/dsmusit/data-transformation/2017/ntnu-vm-gjenstandstype-normering/node_modules/oracledb/build/Release/oracledb.node(_ZN8S\r\ntmtImpl14defineCallbackEPvP9OCIDefinejPS0_PPjPhS3_PPt+0x2d)[0x7f8dd4be949d]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(kpufGetRcvInfo+0x2ad)[0x7f8dc55ccc5d]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(ttccpwg+0x1e9)[0x7f8dc68fd6e9]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(ttcfour+0x35a)[0x7f8dc738e60a]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(ttcdrv+0x4184)[0x7f8dc73861c4]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(nioqwa+0x49)[0x7f8dc73714c9]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(upirtrc+0x55c)[0x7f8dc73535cc]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(kpurcsc+0x66)[0x7f8dc735dde6]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(kpufch0+0x715)[0x7f8dc735b445]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(kpufch+0x575)[0x7f8dc7359aa5]\r\n/opt/oracle/instantclient/libclntsh.so.12.1(OCIStmtFetch2+0xb)[0x7f8dc5570ffb]\r\n/home/jarle/src/dsmusit/data-transformation/2017/ntnu-vm-gjenstandstype-normering/node_modules/oracledb/build/Release/oracledb.node(_ZN8S\r\ntmtImpl5fetchEj+0x26)[0x7f8dd4be9b86]\r\n/home/jarle/src/dsmusit/data-transformation/2017/ntnu-vm-gjenstandstype-normering/node_modules/oracledb/build/Release/oracledb.node(_ZN10\r\nConnection7DoFetchEP6eBaton+0x30)[0x7f8dd4bcdc10]\r\n/home/jarle/src/dsmusit/data-transformation/2017/ntnu-vm-gjenstandstype-normering/node_modules/oracledb/build/Release/oracledb.node(_ZN9R\r\nesultSet13Async_GetRowsEP9uv_work_s+0x324)[0x7f8dd4bdeae4]\r\nnode[0x122aa41]\r\nnode[0x1239b79]\r\n/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f8dd71cb6ba]\r\n/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f8dd6f0182d]\r\n[1]    363 abort (core dumped)  node dist/index.js\r\n\r\nThere doesn't seem to be a problem if I use plain old callbacks to do the same query, it's only the promise/async which crashes."},"comment":{"url":"https://api.github.com/repos/oracle/node-oracledb/issues/comments/278438782","html_url":"https://github.com/oracle/node-oracledb/issues/609#issuecomment-278438782","issue_url":"https://api.github.com/repos/oracle/node-oracledb/issues/609","id":278438782,"user":{"login":"cjbj","id":200778,"avatar_url":"https://avatars.githubusercontent.com/u/200778?v=3","gravatar_id":"","url":"https://api.github.com/users/cjbj","html_url":"https://github.com/cjbj","followers_url":"https://api.github.com/users/cjbj/followers","following_url":"https://api.github.com/users/cjbj/following{/other_user}","gists_url":"https://api.github.com/users/cjbj/gists{/gist_id}","starred_url":"https://api.github.com/users/cjbj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjbj/subscriptions","organizations_url":"https://api.github.com/users/cjbj/orgs","repos_url":"https://api.github.com/users/cjbj/repos","events_url":"https://api.github.com/users/cjbj/events{/privacy}","received_events_url":"https://api.github.com/users/cjbj/received_events","type":"User","site_admin":false},"created_at":"2017-02-08T19:41:09Z","updated_at":"2017-02-08T19:41:09Z","body":"@jarlestabell thanks for the very concise testcase.  We'll look into it. Seems to be a dup of something our testing group recently reported.  Is bumping `maxRows` a workaround for you - or do you not know how many records are coming back?   FWIW @anthony-tuininga was playing with the testcase and indicated the not-yet-out node-oracledb v2 branch doesn't suffer the problem.\r\n\r\n@jarlestabell Can you try bumping `maxRows` too?  Got a standalone testcase?"}}
{"actor":{"display_login":"cjbj"}}