Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error on certain org files (minimal example included) #10

Closed
rdicosmo opened this issue Dec 29, 2020 · 5 comments
Closed

runtime error on certain org files (minimal example included) #10

rdicosmo opened this issue Dec 29, 2020 · 5 comments

Comments

@rdicosmo
Copy link

I get a runtime error on certain org files. A minimal org file that shows the error is the following:

#+STARTUP: hidestars

  • Reading
    ** Q
    • a

And here is the backtrace

$ ./microfts input -org /tmp/db.db /tmp/a.org
panic: runtime error: slice bounds out of range [1:0]

goroutine 1 [running]:
main.orgPart(0x24, 0xc000020180, 0x2b, 0x23, 0xc00002019f, 0x4)
/home/dicosmo/code/microfts/fulltext.go:144 +0x5cf
main.forParts(0xc000020180, 0x2b, 0xc000143bc0)
/home/dicosmo/code/microfts/fulltext.go:108 +0xf7
main.(*lmdbConfigStruct).indexOrg(0x665de0, 0x7ffceb819254, 0xa)
/home/dicosmo/code/microfts/fts-lmdb.go:554 +0x18f
main.(*lmdbConfigStruct).index(0x665de0, 0x7ffceb819254, 0xa)
/home/dicosmo/code/microfts/fts-lmdb.go:527 +0x48
main.cmdInput.func1()
/home/dicosmo/code/microfts/fts-lmdb.go:518 +0x4f
main.(*lmdbConfigStruct).update.func1.1()
/home/dicosmo/code/microfts/fts-lmdb.go:1682 +0x2f
main.(*lmdbConfigStruct).runTxn(0x665de0, 0xc00002cc40, 0x0, 0xc000143d08)
/home/dicosmo/code/microfts/fts-lmdb.go:1720 +0x1d0
main.(*lmdbConfigStruct).update.func1(0xc00002cc40, 0xc00002cc40, 0x0)
/home/dicosmo/code/microfts/fts-lmdb.go:1681 +0x72
github.com/AskAlexSharov/lmdb-go/lmdb.(*Txn).runOpTerm(0xc00002cc40, 0xc000143df0, 0x0, 0x0)
/home/dicosmo/go/pkg/mod/github.com/!ask!alex!sharov/lmdb-go@v1.9.1/lmdb/txn.go:158 +0x6e
github.com/AskAlexSharov/lmdb-go/lmdb.(*Env).run(0xc00007a6f0, 0x1, 0x0, 0xc000143df0, 0x0, 0x0)
/home/dicosmo/go/pkg/mod/github.com/!ask!alex!sharov/lmdb-go@v1.9.1/lmdb/env.go:515 +0xbb
github.com/AskAlexSharov/lmdb-go/lmdb.(*Env).Update(...)
/home/dicosmo/go/pkg/mod/github.com/!ask!alex!sharov/lmdb-go@v1.9.1/lmdb/env.go:482
main.(*lmdbConfigStruct).update(0x665de0, 0xc000143e70)
/home/dicosmo/code/microfts/fts-lmdb.go:1680 +0x77
main.cmdInput(0x665de0)
/home/dicosmo/code/microfts/fts-lmdb.go:516 +0x19e
main.runLmdb(0xc000070180)
/home/dicosmo/code/microfts/fts-lmdb.go:210 +0x3be
main.main()
/home/dicosmo/code/microfts/fulltext.go:357 +0xc6f

@zot
Copy link
Owner

zot commented Dec 29, 2020

Thanks for the detailed bug report! I'll take a look.

@zot
Copy link
Owner

zot commented Dec 29, 2020

Hmm, are you running on either Windows or a Mac, by any chance? I'm not getting an error on Linux and I wonder if this is a line-end problem...

@zot
Copy link
Owner

zot commented Dec 29, 2020

Although I can't reproduce the error, I added a check that should handle it. I also compiled and uploaded new versions for Linux and Windows. Unfortunately I can't build it for the the Mac so I'll have to wait until someone can do that for me.

If you use Linux or Windows, would you mind testing the version I uploaded (or you can fetch it from the repo and build it, if you like).

@rdicosmo
Copy link
Author

rdicosmo commented Dec 29, 2020

Thanks for looking into this so quickly: after recompilation, the error appears to have gone :-)

Here is more information that may help anyway.

I am on Linux (Debian bullseye).

$ go version go version go1.15.5 linux/amd64

Compilation raises several warnings:

$ go build -o microfts
mdb.c: In function ‘mdb_cursor_put’:
mdb.c:6779:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
6779 | if (SIZELEFT(fp) < offset) {
| ^
mdb.c:6784:5: note: here
6784 | case MDB_CURRENT:
| ^~~~
mdb.c: In function ‘mdb_env_cwalk’:
mdb.c:9216:7: warning: writing 8 bytes into a region of size 1 [-Wstringop-overflow=]
9216 | memcpy(NODEDATA(ni), &my->mc_next_pgno, sizeof(pgno_t));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mdb.c:916:8: note: at offset 0 to object ‘mn_data’ with size 1 declared here
916 | char mn_data[1]; /**< key and data are appended here */
| ^~~~~~~
mdb.c: In function ‘mdb_node_add’:
mdb.c:7367:4: warning: writing 8 bytes into a region of size 1 [-Wstringop-overflow=]
7367 | memcpy(ndata, &ofp->mp_pgno, sizeof(pgno_t));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mdb.c:7361:5: warning: writing 8 bytes into a region of size 1 [-Wstringop-overflow=]
7361 | memcpy(ndata, data->mv_data, sizeof(pgno_t));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@zot
Copy link
Owner

zot commented Dec 29, 2020

Great! It's the holidays here so I have some time to mess around with this stuff :).

Yeah, those errors are from the C code included with lmdb-go. I haven't looked at how to address those.

@zot zot closed this as completed Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants