oracle / odpi

ODPI-C: Oracle Database Programming Interface for Drivers and Applications
https://oracle.github.io/odpi/
Other
264 stars 75 forks source link

SIGSEGV when using multiple dpiContexts #153

Closed tgulacsi closed 3 years ago

tgulacsi commented 3 years ago
  1. What version of ODPI-C are you using (see dpi.h)? v4.1.0

  2. What OS (and version) is your application on? linux/amd64

  3. What compiler (and version) did you use? go v1.16rc1

  4. What is your version of the Oracle Client (e.g. Instant Client)? How was it installed? Where it is installed? 21.1, official rpm

  5. What is your Oracle Database version? 19.5

  6. What problem or error(s) you are seeing? https://github.com/golang/go/issues/43977

dpiContext_getClientVersion SIGSEGVs on the second context

go test -run=NewDriver on godror v0.23.1 (2091233c574a27f0161d6d68c511e1773dab0133 sidesteps this problem with using one global dpiContext).

anthony-tuininga commented 3 years ago

There shouldn't be any reason not to use a single context but it would be good to figure out the source of this issue, too. I'll take a look and get back to you.

tgulacsi commented 3 years ago

This is a very strange error, and though reproducible in 9/10 of runs with Go 1.16rc1 (or tip), I've never seen it with Go <1.16. The more strange thing is that it disappears with env GODEBUG=cgocheck=2, only happens with the less strict (!) cgocheck=0 and cgocheck=1 ! So some write barrier is used with cgocheck=2 that elides this error.

With current godror tip, you can compile a test binary (for debugging) with

go  test -c  # compile test binary into godror.test
env GODROR_SEPARATE_CONTEXT=1 ./godror.test -test.count=1 -test.run=SepContext

The test code is on line 16 of drv_test.go (opens, uses and closes separate dpiContexts).

For Go, you can either download if from one of the links at the bottom of https://golang.org/dl/ , or install it separately with

go get golang.org/dl/go1.16rc1

or use the tip in the same manner with

go get golang.org/dl/gotip && gotip download
junaidriaz449 commented 3 years ago

I have also observed the exact same issue in C application. I can share a gdb backtrace if required.

cjbj commented 3 years ago

@junaidriaz449 do you have a test case handy? @anthony-tuininga is a bit slammed at the moment, so a standalone test case would be handy.

I'm sure @anthony-tuininga will be interested why you are using multiple contexts, given his previous comment.

anthony-tuininga commented 3 years ago

@tgulacsi, can you test with the changes made for #156? I believe they are related and that this issue is also resolved.

tgulacsi commented 3 years ago

Thanks, I can confirm those fixes work!