You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds support for building JDBC driver with the [address sanitizer](https://github.com/google/sanitizers/wiki/addresssanitizer) enabled:
```bash
make sanitized
```
To run the sanitized binary `libasan` and `libstdc++` must be preloaded:
```bash
export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libasan.so.8 /usr/lib/x86_64-linux-gnu/libstdc++.so.6"
```
If we add the following deliberately erratic snippet somewhere inside the JDBC driver:
```c++
int *x = reinterpret_cast<int*>(malloc(10 * sizeof(int*)));
free(x);
std::cout << x[5] << std::endl;
```
Then the execution will abort with something like the following:
```
=================================================================
==114481==ERROR: AddressSanitizer: heap-use-after-free on address 0x7bf5410abf14 at pc 0x7b83372124ac bp 0x7f85413fe070 sp 0x7f85413fe068
READ of size 4 at 0x7bf5410abf14 thread T1
#0 0x7b83372124ab in _duckdb_jdbc_startup(JNIEnv_*, _jclass*, _jbyteArray*, unsigned char, _jobject*) duckdb-java/src/jni/duckdb_java.cpp:79:18
#1 0x7b8337239880 in Java_org_duckdb_DuckDBNative_duckdb_1jdbc_1startup duckdb-java/src/jni/functions.cpp:9:30
#2 0x7b852b3445d9 (<unknown module>)
[...]
==114481==ABORTING
```
Note that on successful run the JVM may print a lot of internal "leak" warnings, it may be necessary to prepare a [suppression file](https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions) to prevent this.
0 commit comments