sqlite-jdbc
sqlite-jdbc copied to clipboard
JVM SIGSEGV when trying to load libspatialite5.0.1_1 on OSX Monterey
Hi, I recently updated my Macbook (Intel Core i7) to OSX Monterey(12.2.1) and cannot load the Spatialite extension since then. Here is the error log: hs_err_pid51593.log I installed libspatialite with homebrew, and used the Sample in the demo package and added properties to enable load extension and a statement loading the extension:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class Sample
{
public static void main(String[] args)
{
Connection connection = null;
Properties properties = new Properties();
properties.setProperty("enable_load_extension", "true");
try
{
// create a database connection
connection = DriverManager.getConnection("jdbc:sqlite:sample.db", properties);
connection.prepareStatement("SELECT load_extension('mod_spatialite')").execute();
Statement statement = connection.createStatement();
statement.setQueryTimeout(30); // set timeout to 30 sec.
statement.executeUpdate("drop table if exists person");
statement.executeUpdate("create table person (id integer, name string)");
statement.executeUpdate("insert into person values(1, 'leo')");
statement.executeUpdate("insert into person values(2, 'yui')");
ResultSet rs = statement.executeQuery("select * from person");
while(rs.next())
{
// read the result set
System.out.println("name = " + rs.getString("name"));
System.out.println("id = " + rs.getInt("id"));
}
}
catch(SQLException e)
{
// if the error message is "out of memory",
// it probably means no database file is found
System.err.println(e.getMessage());
}
finally
{
try
{
if(connection != null)
connection.close();
}
catch(SQLException e)
{
// connection close failed.
System.err.println(e);
}
}
}
}
Steps to reproduce: Install openjdk@11 and libspatialite with homebrew, checkout repository and change Sample.java as shown above, follow steps in Readme.
Thanks for your help, Nadja
I am not familiar with this extension, nor how it is installed. I checked the website and could not find any installation details. I didn't check the homebrew formula.
I tried locally and i get the same result. However, if i compile the native library against the version installed by homebrew, it seems to work:
make clean native SQLITE_OBJ=/opt/homebrew/Cellar/sqlite/3.39.2/lib/libsqlite3.dylib SQLITE_HEADER=/opt/homebrew/Cellar/sqlite/3.39.2/include/sqlite3.h
mvn clean package
The repro i did was with a M1 Mac running Monterey. With my Intel Mac running Big Sur i don't have the problem.