Open yaronyg opened 8 years ago
On what platform is it happening?
Is step 4 correct?
What jxcore version has been installed?
This bug works in osx.
@andrew-aladev thanks.
When you are in test/www/jxcore
you can reproduce this by jx runTests.js bv_tests/testPouchDBGenerator.js
Just to make sure: jx is using V8?
My jx was installed using new gist.
jx -jxv
> v0.3.1.2
jx -jsv
> Google V8 v3.14.5.9
OK, thanks.
I started the investigation, I can repro the bug on macOS, while on Linux the bug is not present.
* thread #6: tid = 0x8acaa, 0x00007fff93a21f2e libsystem_malloc.dylib`malloc_error_break, stop reason = breakpoint 1.1
* frame #0: 0x00007fff93a21f2e libsystem_malloc.dylib`malloc_error_break
frame #1: 0x00007fff93a12fd2 libsystem_malloc.dylib`free + 314
frame #2: 0x00000001001ea351 jx`leveldown::AsyncWorker::SetStatus(leveldb::Status) [inlined] leveldb::Status::operator=(s=0x0000700000541e78) + 28 at status.h:99
frame #3: 0x00000001001ea335 jx`leveldown::AsyncWorker::SetStatus(this=0x00000001018005b0, status=(state_ = 0x0000000000000000)) + 17 at async.h:34
frame #4: 0x00000001057063cd leveldown.node`leveldown::OpenWorker::Execute(this=0x00000001018005b0) + 51 at database_async.cc:54
frame #5: 0x00000001002085bf jx`worker(arg=<unavailable>) + 90 at threadpool.c:68
frame #6: 0x00000001001fe9ac jx`uv__thread_start(ctx_v=<unavailable>) + 25 at uv-common.c:282
frame #7: 0x00007fff88ad799d libsystem_pthread.dylib`_pthread_body + 131
frame #8: 0x00007fff88ad791a libsystem_pthread.dylib`_pthread_start + 168
frame #9: 0x00007fff88ad5351 libsystem_pthread.dylib`thread_start + 13
inline void Status::operator=(const Status& s) {
// The following condition catches both aliasing (when this == &s),
// and the common case where both s and *this are ok.
if (state_ != s.state_) {
delete[] state_;
state_ = (s.state_ == NULL) ? NULL : CopyState(s.state_);
}
}
@andrew-aladev the test requires leveldown-mobile, but when running on macOS, it's using leveldown, as you can see from the stack trace. If I remove node_modules/leveldown, the test passes. I'm a little bit lost here.
$ jx runTests.js bv_tests/testPouchDBGenerator.js
Test runner loading file: /Users/cicoriasmbp13/build/Thali_CordovaPlugin/test/www/jxcore/bv_tests/testPouchDBGenerator.js
TAP version 13
# setup
# test defaultDirectory
ok 1 should be equal
ok 2 should be equal
ok 3 should be equal
# teardown
# setup
# test defaultAdapter
ok 4 should be equal
ok 5 should be equal
ok 6 should be equal
ok 7 should be equal
ok 8 should be equal
ok 9 should be equal
ok 10 should be equal
ok 11 should be equal
# teardown
1..11
# tests 11
# pass 11
# ok
P.S. On Linux it uses leveldown-mobile.
This is a bug and we do need to fix it but we are kicking down the priority. We need to make sure we don't call the wrong leveldown.
So what is almost certainly happening here is that at some point we installed PouchDB or Express-PouchDB using node which would cause us to bring in leveldown. Then we used JX to run some tests in the same directory. But Pouch still prefers leveldown to leveldown-mobile and so boom. I think we now avoid this because we hard coded our dependency on leveldown-mobile when we call PouchDB. But in any case we have a work around (delete node_modules/leveldown) so I'm kicking this to Icebox for now.
We are getting the following error during tests: jx(1068,0x105751000) malloc: * error for object 0xa6e00786a2e65: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug
To repro:
It will core dump with the error above pretty quickly.