michalc / sqlite-s3-query

Python functions to query SQLite files stored on S3
MIT License
251 stars 15 forks source link

OSError: exception: access violation writing 0x0000000000000000 #46

Closed Matvii-Boichenko closed 1 year ago

Matvii-Boichenko commented 1 year ago

Hi

Python 3.11 on Windows 10 Verifying code from the example received error. File test.py

from sqlite_s3_query import sqlite_s3_query

def test():
  query_my_db = partial(sqlite_s3_query,
                            url="https://<link to s3>/file.db",
                            get_credentials=get_boto3_credentials(),
                            )
      with \
              query_my_db() as query, \
              query("select sqlite_version();") as (columns, rows):
          for row in rows:
              print(row)

Received error Windows fatal exception: access violation -> OSError: exception: access violation writing 0x0000000000000000

Traceback:

Traceback (most recent call last):
  File "<project dir>\test.py", line 75, in <module>
    with \
  File "B:\Python\Python3.11\Lib\contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "<projec dirt>\venv\Lib\site-packages\sqlite_s3_query.py", line 396, in sqlite_s3_query
    with sqlite_s3_query_multi(url,
  File "B:\Python\Python3.11\Lib\contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "<project dir>\venv\Lib\site-packages\sqlite_s3_query.py", line 374, in sqlite_s3_query_multi
    with \
  File "B:\Python\Python3.11\Lib\contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "<project dir>\venv\Lib\site-packages\sqlite_s3_query.py", line 267, in get_vfs
    run(libsqlite3.sqlite3_vfs_register, byref(vfs), 0)
  File "<project dir>\venv\Lib\site-packages\sqlite_s3_query.py", line 71, in run
    res = func(*args)
          ^^^^^^^^^^^
OSError: exception: access violation writing 0x0000000000000000
michalc commented 1 year ago

Hi @Matvii-Boichenko,

Thanks for the report. Do you know what version of SQLite you’re using?

Matvii-Boichenko commented 1 year ago

@michalc select sqlite_version(); returned '3.42.0'

michalc commented 1 year ago

To let you know, have reproduced the issue in CI: https://github.com/michalc/sqlite-s3-query/pull/55

Not sure if you can see it, but https://github.com/michalc/sqlite-s3-query/actions/runs/5706715384/job/15462685466 is full of OSError: exception: access violation writing 0x0000000000000000. For example:

======================================================================
ERROR: test_select (test.TestSqliteS3Query)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\sqlite-s3-query\sqlite-s3-query\test.py", line 55, in test_select
    with sqlite_s3_query('http://localhost:9000/my-bucket/my.db', get_credentials=lambda now: (
  File "C:\hostedtoolcache\windows\Python\3.10.0\x64\lib\contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "D:\a\sqlite-s3-query\sqlite-s3-query\sqlite_s3_query.py", line 396, in sqlite_s3_query
    with sqlite_s3_query_multi(url,
  File "C:\hostedtoolcache\windows\Python\3.10.0\x64\lib\contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "D:\a\sqlite-s3-query\sqlite-s3-query\sqlite_s3_query.py", line 374, in sqlite_s3_query_multi
    with \
  File "C:\hostedtoolcache\windows\Python\3.10.0\x64\lib\contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "D:\a\sqlite-s3-query\sqlite-s3-query\sqlite_s3_query.py", line 267, in get_vfs
    run(libsqlite3.sqlite3_vfs_register, byref(vfs), 0)
  File "D:\a\sqlite-s3-query\sqlite-s3-query\sqlite_s3_query.py", line 71, in run
    res = func(*args)
OSError: exception: access violation writing 0x0000000000000000
michalc commented 1 year ago

Making some progress in https://github.com/michalc/sqlite-s3-query/pull/55: the access violation is fixed, but here are some issues with binding parameters to queries.

michalc commented 1 year ago

I think binding parameters sorted, but some issues I think when there are multiple queries in a single string - finalizing the statement seems to raise an error

michalc commented 1 year ago

So fixed in https://github.com/michalc/sqlite-s3-query/pull/55 (hopefully) and released in https://github.com/michalc/sqlite-s3-query/releases/tag/v0.0.76 (and should be on PyPI in a few mins)