Comments (6)
> ... So far I haven't found a way to reliably reproduce this problem.
That is not good. It looks like memory corruption - it could be happening
anywhere: in your program, in odbc package, in Go stdlib or in Windows dlls.
Reproducible example will make hunting it down easier.
> ... Since I have not much experience yet with cgo,
Looking at your stack trace I don't see cgo is used here. Does your program use
any other packages that use cgo?
> ... any suggestions or ideas on how to debug this is very much appreciated.
Like I said earlier, I suspect it is memory corruption. If I am correct, it is
very difficult to find the problem because the crash is caused by either Go
garbage collector or by Windows memory manager freeing / reallocating memory.
That means it crashes long way after the bug being hit.
One obvious thing for you to try is to use "latest" Go version. You said, you
are using "go version 1.1.2". As far as I remember, there were some
database/sql fixes that could fix your problem. It is certainly worth a try.
Alex
Original comment by [email protected]
on 6 Sep 2013 at 12:45
from odbc.
Thanks for the reply. I wrongly assumed the driver used cgo, because of the
cgocall.c in the stacktrace. There are no other packages that use cgo.
I've reduced the problem to this:
https://gist.github.com/jstemmer/6461407
Some observations so far:
- The more parameters I use in my named query, the quicker the panic triggers.
- The longer the string variable I use as the parameters, the quicker the panic
triggers (after executing the statement about ~25 times on my machine).
- Calling runtime.GC() after each execute seems to solve it (at least in this
case; it runs the code in the gist every time without a panic).
- Panic happens both when compiling on windows or crosscompiling from linux to
windows.
- Tried with go tip (version devel +601c402eb321), doesn't seem to change
anything except triggering the panic faster (after executing the statement ~15
times).
- The same code runs fine with the mysql driver
(github.com/go-sql-driver/mysql) on both windows and linux.
Original comment by [email protected]
on 6 Sep 2013 at 9:30
from odbc.
I've worked around this issue by not using the sql parameters at all. I created
the entire sql statement as a single string, including escaping each of the
values where necessary, and executing it with the db.Exec function. This works
great for millions of inserts, which makes me believe the problem has something
to do with the way the parameters are handled.
After trying a few different things, I've managed to prevent the panic from
happening by supplying a nil for the last parameter of SQLBindParameter (in
param.go:105) when dealing with string parameters. This is possible since the
strings are null terminated. It seems to fix the problem at first when running
the different tests, but when I try to use it in my main application I
encounter other errors. For example "[Microsoft][ODBC SQL Server Driver][SQL
Server]Conversion failed when converting date and/or time from character
string", which is strange since this worked fine before. No more panics
however, which is good.
Unfortunately I don't have much time to investigate further to try and fix
these issues. I've found another go odbc driver at
https://github.com/LukeMauldin/lodbc which runs fine without any significant
problems.
Original comment by [email protected]
on 8 Sep 2013 at 1:34
from odbc.
> I've reduced the problem to this:
> https://gist.github.com/jstemmer/6461407
Thank you for that. I can see the problem know. Here is a fix
https://codereview.appspot.com/13253046/ Please, review and let me know, if you
like.
> Unfortunately I don't have much time to investigate further to try and fix
these issues. I've found another go odbc driver at
https://github.com/LukeMauldin/lodbc which runs fine without any significant
problems.
Fair enough. Luckily all these drivers are interchangeable. It should just be a
matter of changing import statement.
Alex
Original comment by [email protected]
on 9 Sep 2013 at 2:18
- Changed state: Accepted
from odbc.
Thanks for the patch. Some more issues popped up after applying the patch, I
tracked most of them down. I've added some comments at
https://codereview.appspot.com/13253046/
Original comment by [email protected]
on 9 Sep 2013 at 10:07
from odbc.
This issue was closed by revision d64013ec9967.
Original comment by [email protected]
on 13 Sep 2013 at 2:09
- Changed state: Fixed
from odbc.
Related Issues (20)
- Low max message length HOT 3
- Add tags to the repo HOT 1
- Implement QueryerContext interface HOT 1
- Implement RowsColumnTypeDatabaseTypeName HOT 1
- error when build from linux HOT 2
- only half of unicode string is inserted.
- Issue with Unixodbc-2.3.7 for master and for_issue_88 branch HOT 1
- 向 varchar字段保存中文中会被截断 HOT 10
- Maintain releases HOT 5
- The package is returning a panic instead of an error HOT 4
- Issues with parametrized queries Windows/DuckDB HOT 2
- abount microsoft access long binary data type HOT 1
- Unrecognized Data Type on Column
- random errors when doing the db.query using Denodo odbc driver HOT 1
- Does this package support `-buildmode=c-shared` HOT 1
- Have error `api/api_unix.go:15:11: fatal error: 'sql.h' file not found` HOT 6
- Error : unrecognized import path "golang.zx2c4.com/go118/netip" HOT 2
- connect db2 when column is NULL, parsing data error execution an error occurred is {wrong column #1 length 4294967295 returned, 16 expected} HOT 3
- (duckdb ODBC) Cannot Insert INTEGER HOT 3
- Cannot Update Golang Bool value to TINYINT column HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odbc.