alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
361 stars 141 forks source link

The package is returning a panic instead of an error #184

Closed ashwinipatankar closed 1 year ago

ashwinipatankar commented 1 year ago

OS: Windows Go version: 1.16 Database: bbj

Recently, in a peculiar case the package returned a panic instead of an error. Here is the stack trace - ` syscall.Syscall9(0x70d5dc30, 0x8, 0x3, 0x159c788, 0x1, 0x12ccb774, 0x12ccb760, 0x12ccb780, 0x200, 0x0, ...) /usr/lib/go-1.16/src/runtime/syscall_windows.go:356 +0xbb github.com/alexbrainman/odbc/api.SQLGetDiagRec(0x8b0003, 0x159c788, 0x1590001, 0x12ccb774, 0x12ccb760, 0x12ccb780, 0x200 , 0x0, 0x0) /home/xyz/go/pkg/mod/github.com/alexbrainman/odbc@v0.0.0-20211220213544-9c9a2e61c5e2/api/zapi_windows.go:144 + 0xca github.com/alexbrainman/odbc.NewError(0x92ad1b, 0xa, 0x891860, 0x12c19990, 0x352, 0x352) github.com/alexbrainman/odbc.(*Conn).PrepareODBCStmt(0x12c04e00, 0x12d0ca80, 0x351, 0x0, 0x0, 0x0)

github.com/alexbrainman/odbc.(*Conn).Prepare(0x12c04e00, 0x12d0ca80, 0x351, 0x0, 0x0, 0x0, 0x408c7a)`

Ideally it shall return an error instead of the panic, is that correct ?

And how this can be handled ?

alexbrainman commented 1 year ago

Here is the stack trace -

That is incomplete stack trace. You skipped the error message at the top of the stack trace. Also you did not provide source path and line numbers for github.com/alexbrainman/odbc.NewError and others.

It is impossible to suggest anything here.

Alex

ashwinipatankar commented 1 year ago

the complete stack trace is attached here. stactrace.txt

`2022/12/27 14:34:42 Running in debug mode. Name >> ClaireImportV3-Jaguar ClaireImportV3-Jaguar.info(1): starting ClaireImportV3-Jaguar service Exception 0xc0000005 0x1 0x0 0x70558c08 PC=0x70558c08

syscall.Syscall9(0x70d5dc30, 0x8, 0x3, 0x159c788, 0x1, 0x12ccb774, 0x12ccb760, 0x12ccb780, 0x200, 0x0, ...) /usr/lib/go-1.16/src/runtime/syscall_windows.go:356 +0xbb github.com/alexbrainman/odbc/api.SQLGetDiagRec(0x8b0003, 0x159c788, 0x1590001, 0x12ccb774, 0x12ccb760, 0x12ccb780, 0x200 , 0x0, 0x0) /home/drago/go/pkg/mod/github.com/alexbrainman/odbc@v0.0.0-20211220213544-9c9a2e61c5e2/api/zapi_windows.go:144 + 0xca github.com/ClaireIT/odbc.NewError(0x92ad1b, 0xa, 0x891860, 0x12c19990, 0x352, 0x352) /home/drago/go/pkg/mod/github.com/!claire!i!t/odbc@v0.0.0-20220104103903-eb94d8404bd2/error.go:53 +0x11e github.com/ClaireIT/odbc.(Conn).newError(...) /home/drago/go/pkg/mod/github.com/!claire!i!t/odbc@v0.0.0-20220104103903-eb94d8404bd2/conn.go:69 github.com/ClaireIT/odbc.(Conn).PrepareODBCStmt(0x12c04e00, 0x12d0ca80, 0x351, 0x0, 0x0, 0x0) /home/drago/go/pkg/mod/github.com/!claire!i!t/odbc@v0.0.0-20220104103903-eb94d8404bd2/odbcstmt.go:46 +0x320 github.com/ClaireIT/odbc.(Conn).Prepare(0x12c04e00, 0x12d0ca80, 0x351, 0x0, 0x0, 0x0, 0x408c7a) /home/drago/go/pkg/mod/github.com/!claire!i!t/odbc@v0.0.0-20220104103903-eb94d8404bd2/stmt.go:26 +0x41 database/sql.ctxDriverPrepare(0x9d6acc, 0x12c180a8, 0x9d5b90, 0x12c04e00, 0x12d0ca80, 0x351, 0x5, 0x47aee3, 0x12c4db78, 0x0) /usr/lib/go-1.16/src/database/sql/ctxutil.go:17 +0x6c database/sql.(DB).queryDC.func2() /usr/lib/go-1.16/src/database/sql/sql.go:1672 +0x58 database/sql.withLock(0x9d4c10, 0x12c4db60, 0x12ccbdc0) /usr/lib/go-1.16/src/database/sql/sql.go:3294 +0x57 database/sql.(DB).queryDC(0x12cb0360, 0x9d6acc, 0x12c180a8, 0x0, 0x0, 0x12c4db60, 0x12d8dde0, 0x12d0ca80, 0x351, 0x0, . ..) /usr/lib/go-1.16/src/database/sql/sql.go:1671 +0x112 database/sql.(DB).query(0x12cb0360, 0x9d6acc, 0x12c180a8, 0x12d0ca80, 0x351, 0x0, 0x0, 0x0, 0x1, 0x0, ...) /usr/lib/go-1.16/src/database/sql/sql.go:1628 +0xe1 database/sql.(DB).QueryContext(0x12cb0360, 0x9d6acc, 0x12c180a8, 0x12d0ca80, 0x351, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /usr/lib/go-1.16/src/database/sql/sql.go:1605 +0x8c database/sql.(DB).Query(...) /usr/lib/go-1.16/src/database/sql/sql.go:1619 main.read(0x12cb0360, 0x12d0ca80, 0x351, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /home/drago/claire/cmd/dmsv3/clients/win/reader.go:34 +0xf2 main.(Service).Execute.func1(0x12d8ddc0, 0x12c13080, 0x93d2b6, 0x24, 0x12e881c0) /home/drago/claire/cmd/dmsv3/clients/win/service.go:159 +0x1a8 created by main.(Service).Execute /home/drago/claire/cmd/dmsv3/clients/win/service.go:89 +0x281

goroutine 1 [chan receive]: main.(*Service).Execute(0x12d8ddc0, 0x12d8ddc8, 0x1, 0x1, 0x12c13040, 0x12c13080, 0x40bc0c, 0x4) /home/drago/claire/cmd/dmsv3/clients/win/service.go:207 +0x2a3 golang.org/x/sys/windows/svc/debug.Run(0x12c169f0, 0x15, 0x9d2118, 0x12d8ddc0, 0x0, 0x0) /home/drago/go/pkg/mod/golang.org/x/sys@v0.0.0-20210412220455-f1c623a9e750/windows/svc/debug/service.go:40 +0x11 e main.runService(0x12c169f0, 0x15, 0x1) /home/drago/claire/cmd/dmsv3/clients/win/service.go:268 +0x179 main.main() /home/drago/claire/cmd/dmsv3/clients/win/main.go:64 +0x5fe

goroutine 6 [select]: go.opencensus.io/stats/view.(*worker).start(0x12c4d620) /home/drago/go/pkg/mod/go.opencensus.io@v0.23.0/stats/view/worker.go:276 +0xa4 created by go.opencensus.io/stats/view.init.0 /home/drago/go/pkg/mod/go.opencensus.io@v0.23.0/stats/view/worker.go:34 +0x59

goroutine 7 [syscall]: os/signal.signal_recv(0x0) /usr/lib/go-1.16/src/runtime/sigqueue.go:168 +0x132 os/signal.loop() /usr/lib/go-1.16/src/os/signal/signal_unix.go:23 +0x1a created by os/signal.Notify.func1.1 /usr/lib/go-1.16/src/os/signal/signal.go:151 +0x33

goroutine 8 [select]: golang.org/x/sys/windows/svc/debug.Run.func1(0x12c130c0, 0x12c13040, 0x12c13080) /home/drago/go/pkg/mod/golang.org/x/sys@v0.0.0-20210412220455-f1c623a9e750/windows/svc/debug/service.go:32 +0xba

created by golang.org/x/sys/windows/svc/debug.Run /home/drago/go/pkg/mod/golang.org/x/sys@v0.0.0-20210412220455-f1c623a9e750/windows/svc/debug/service.go:29 +0xc1

goroutine 36 [select]: database/sql.(*DB).connectionOpener(0x12cb0360, 0x9d6aac, 0x12c86300) /usr/lib/go-1.16/src/database/sql/sql.go:1133 +0xab created by database/sql.OpenDB /usr/lib/go-1.16/src/database/sql/sql.go:740 +0xf8 eax 0x395 ebx 0x33c6c0c8 ecx 0x0 edx 0x33c6c45d edi 0x33c6a796 esi 0x33c6d8a6 ebp 0x33c6a400 esp 0x32dffe5c eip 0x70558c08 eflags 0x10206 cs 0x23 fs 0x53 gs 0x2b`

alexbrainman commented 1 year ago

@ashwinipatankar

Does https://github.com/alexbrainman/odbc/pull/189 fixes your issue?

Please test. Thank you.

Alex

alexbrainman commented 1 year ago

@ashwinipatankar

I expect this commit https://github.com/alexbrainman/odbc/commit/1421b829acc9091991ee8e7065fc1dfb3f885d94 fixes your problem. So I am closing the issue.

Please, reopen if you disagee.

Alex