Skip to content

dumpb/loadb results in non-working database #153

@piotr-piatkowski

Description

@piotr-piatkowski

I was trying to serialize and then restore database, all I get when trying to call scan on restored database is hyperscan.InvalidError: error code -1. I'm using python module version 0.7.7 and python 3.11.9.

Here's sample code:

    db = hyperscan.Database(mode=hyperscan.HS_MODE_BLOCK)
    db.compile(
        expressions=[b'bar']
    )

    def callback(id, start, end, flags, context):
        print(f"Matched {id} from {start} to {end}")

    db.scan(b'foo bar baz', callback)

    data = hyperscan.dumpb(db)
    db2 = hyperscan.loadb(data, hyperscan.HS_MODE_BLOCK)
    db2.scan(b'foo bar baz', callback)

And results:

        data = hyperscan.dumpb(db)
        db2 = hyperscan.loadb(data, hyperscan.HS_MODE_BLOCK)
>       db2.scan(b'foo bar baz', callback)
E       hyperscan.InvalidError: error code -1

I also noticed in debugger that restored db has no scratch atribute set (it's None), but I'm not sure if this is the reason.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions