-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ibm_db crashes node with OUTPUT parameter of type BINARY and Data of type non-Buffer #943
Comments
asselin
pushed a commit
to asselin/node-ibm_db
that referenced
this issue
Sep 7, 2023
asselin
pushed a commit
to asselin/node-ibm_db
that referenced
this issue
Sep 7, 2023
This was referenced Sep 7, 2023
bimalkjha
pushed a commit
that referenced
this issue
Sep 14, 2023
bimalkjha
added a commit
that referenced
this issue
Sep 23, 2023
* update windows binary and electron binaries (Bimal Jha) * update test files, doc files and dependency versions. (Bimal Jha) * Fix for #942 (#944) (Andre Asselin) * Fix double free of Buffer/str for OUTPUT parameter, issue #942 (Bimal Jha) * Fix for #943 (#945) (Andre Asselin) * Support null value for INOUT type parameter of SP, issue #940 (Bimal Jha) * doc upate, correct links in api documentation (Bimal Jha) * fix: ignore CLI0106E error for endTransaction, issue #938 (Bimal Jha) * update test file (Bimal Jha) * add support for outparams in await call of stmt.execute() API, issue #936 (Bimal Jha) * Add addon binaries for electron v25 (Bimal Jha) * update issue template (Bimal Jha)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
System: Linux x86_64 (Bullseye), node v18.16.1
We have a simple stored procedure call to DB2, where one of the parameters is a BINARY output parameter. We have tried both leaving the Data as the default string type and setting it to a Buffer; in both cases, node crashes due to a double memory free. This bug report is for the case of using a String type, although I believe it will fail in the same way with any non-Buffer type. I opened #942 for Buffer types, since it's a different bug.
This bug was introduced in version 3.0 of ibm_db. I confirmed this by testing different levels of ibm_db (all with version 11.5.8 of the ODBC driver). Version 2.8.1 and 2.8.2 ran under load for 24 hours each with no crashes. Versions 3.0 and 3.2.1 crashed approx every 30 minutes under load with various messages:
This is the DB2 query:
The parameters are:
The call to ibm_db looks like:
The issue is that in this case, Nan::NewBuffer() will be used in GetOutputParameter() to return the data, but
isBuffer
will not be set to true, and FREE_PARAMS() will free the memory.If the input parameter is NOT a Buffer (as in this case, where it's a string), then e.g. GetStringParam() will be called from GetParametersFromArray(), and
isBuffer
will remain false.Later, in GetOutputParameter(), after the query completes, is this code:
The issue is that prm.c_type is SQL_C_BINARY, so this code will be executed, however, prm.isBuffer is false, so the test in the FREE_PARAMS() macro will not fire, and it will free the memory:
I confirmed this by adding a logging statement inside that if() statement in GetOutputParameter():
And you can see it show up in the log:
I've also noticed that the output string is also random every time you execute the query; that is also a manifestation of the same bug, using memory that technically is freed and being used by something else.
I created PR #945 to fix this.
The text was updated successfully, but these errors were encountered: