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

Segfault when calling iterator without open #134

Closed
finnp opened this issue Nov 26, 2014 · 5 comments · Fixed by #514
Closed

Segfault when calling iterator without open #134

finnp opened this issue Nov 26, 2014 · 5 comments · Fixed by #514
Labels
bug Something isn't working segfault

Comments

@finnp
Copy link
Member

finnp commented Nov 26, 2014

Hey,

when calling the iterator without open first I get a

[1]    37329 segmentation fault  node reproduce.js

when doing this with a missing open:

var db = require('leveldown')('test')
var iterator = db.iterator()

Best,
Finn

@finnp
Copy link
Member Author

finnp commented Nov 26, 2014

I also get it when opening another leveldown on the same location:

var level = require('leveldown')

var db1 = level('test')
var db2 = level('test')

db1.open(function () {
  db2.open(function () {
    db2.iterator()
  })
})

@kesla
Copy link
Contributor

kesla commented Nov 27, 2014

Yeah, maybe we should show something nice than a segfault, however you need to open the db before using it - so these cases will still create an error for you.

With regards to the second case - when you try to open it a second time you should be getting an error, so the database isn't open then. See https://github.com/google/leveldb#limitations for more info

https://github.com/Level/deferred-leveldown or https://github.com/rvagg/node-levelup can help you out

@finnp
Copy link
Member Author

finnp commented Nov 27, 2014

Ah yeah so the second example can be reduced to the first one.

To be clear I am aware that both of these snippets are wrong. I just don't think a segfault is an acceptable error here.

@rvagg
Copy link
Member

rvagg commented Nov 27, 2014

Agreed @finnp, it's always been our priority to fix any segfaultage and this comes under that category. Thanks for reporting, if you have time to investigate a fix then we'd love to see it! It should be fairly straight forward state checking and returning (or throwing) an error.

@ralphtheninja
Copy link
Member

Still problems on 1.7.1

@ralphtheninja ralphtheninja added segfault bug Something isn't working labels Jun 8, 2017
This was referenced Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working segfault
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants