Closed youjinp closed 3 years ago
@youjinp, I will try to reproduce. But, please, provide a complete stack trace.
Currently I haven't an iOS environment to reproduce. But I have not been able to reproduce the problem on OSX and FreeBSD. Therefore, I will be able to understand what is the matter and fix the problem only if you, or someone else, provide at least a full stack trace.
My apologies, here's the stack trace:
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
frame #0: 0x0000000191750e68 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x000000019178343c libsystem_pthread.dylib`pthread_kill + 292
frame #2: 0x00000001916cb460 libsystem_c.dylib`abort + 104
frame #3: 0x00000001916ca8f4 libsystem_c.dylib`__assert_rtn + 292
* frame #4: 0x0000000119f0de18 MDBXTests`mdbx_assert_fail(env=0x0000000000000000, msg="(uintptr_t)ptr % expected_alignment == 0", func="unaligned_poke_u64", line=199) at osal.c:246:5
frame #5: 0x0000000119eede98 MDBXTests`mdbx_read_header [inlined] unaligned_poke_u64(expected_alignment=4, ptr=0x000000016fdfbe9a, v=1) at core.c:199:3
frame #6: 0x0000000119eede54 MDBXTests`mdbx_read_header(env=0x000000011b0b5440, dest=0x000000016fdfbdf2, lck_exclusive=-1, mode_bits=438) at core.c:10355:3
frame #7: 0x0000000119ee721c MDBXTests`mdbx_setup_dxb(env=0x000000011b0b5440, lck_rc=-1, mode_bits=438) at core.c:11434:13
frame #8: 0x0000000119f05b48 MDBXTests`mdbx_env_open(env=0x000000011b0b5440, pathname="/Users/youjin/Library/Developer/Xcode/DerivedData/swift-mdbx-gcrkcmkxgesjrbbuhpwbjbfyjnka/Build/Products/Debug/MDBXTests.xctest/mdbx", flags=MDBX_ENV_DEFAULTS, mode=438) at core.c:12604:22
frame #9: 0x0000000119ef8c28 MDBXTests`MDBX.init(path="file:///Users/youjin/Library/Developer/Xcode/DerivedData/swift-mdbx-gcrkcmkxgesjrbbuhpwbjbfyjnka/Build/Products/Debug/MDBXTests.xctest/mdbx/", flags=(rawValue = 0), mode=(rawValue = 436), self=(env = 0x000000011b0b5440)) at MDBX.swift:30:24
frame #10: 0x0000000119ef8434 MDBXTests`MDBX.__allocating_init(path:flags:mode:) at MDBX.swift:0
frame #11: 0x0000000119e5302c MDBXTests`MDBXTests.testT(self=0x000000010181e0a0) at MDBXTests.swift:24:23
frame #12: 0x0000000119e538e8 MDBXTests`@objc MDBXTests.testT() at <compiler-generated>:0
frame #13: 0x0000000191863864 CoreFoundation`__invoking___ + 148
frame #14: 0x00000001918636e8 CoreFoundation`-[NSInvocation invoke] + 380
frame #15: 0x000000010049fcd0 XCTestCore`+[XCTFailableInvocation invokeStandardConventionInvocation:completion:] + 76
frame #16: 0x000000010049fc7c XCTestCore`__65+[XCTFailableInvocation invokeInvocation:lastObservedErrorIssue:]_block_invoke_3 + 28
frame #17: 0x000000010049f4bc XCTestCore`__81+[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:]_block_invoke.11 + 112
frame #18: 0x00000001004181b0 XCTestCore`+[XCTSwiftErrorObservation observeErrorsInBlock:] + 92
frame #19: 0x000000010049f314 XCTestCore`+[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:] + 492
frame #20: 0x000000010049f8f8 XCTestCore`+[XCTFailableInvocation invokeInvocation:lastObservedErrorIssue:] + 388
frame #21: 0x0000000100485c74 XCTestCore`__24-[XCTestCase invokeTest]_block_invoke_2 + 104
frame #22: 0x00000001004283c4 XCTestCore`-[XCTMemoryChecker _assertInvalidObjectsDeallocatedAfterScope:] + 88
frame #23: 0x000000010048fd1c XCTestCore`-[XCTestCase assertInvalidObjectsDeallocatedAfterScope:] + 72
frame #24: 0x0000000100485bc8 XCTestCore`__24-[XCTestCase invokeTest]_block_invoke.292 + 192
frame #25: 0x00000001003f2eac XCTestCore`-[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] + 180
frame #26: 0x00000001004856f4 XCTestCore`-[XCTestCase invokeTest] + 844
frame #27: 0x0000000100487080 XCTestCore`__26-[XCTestCase performTest:]_block_invoke_2 + 48
frame #28: 0x00000001003f2eac XCTestCore`-[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] + 180
frame #29: 0x0000000100486fb4 XCTestCore`__26-[XCTestCase performTest:]_block_invoke.408 + 124
frame #30: 0x000000010043e4f4 XCTestCore`+[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 228
frame #31: 0x00000001004867fc XCTestCore`-[XCTestCase performTest:] + 740
frame #32: 0x00000001003be358 XCTestCore`-[XCTest runTest] + 64
frame #33: 0x0000000100441728 XCTestCore`-[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] + 160
frame #34: 0x0000000100441594 XCTestCore`__27-[XCTestSuite performTest:]_block_invoke + 216
frame #35: 0x0000000100440f34 XCTestCore`__59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke + 48
frame #36: 0x000000010043e4f4 XCTestCore`+[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 228
frame #37: 0x0000000100440ed0 XCTestCore`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 192
frame #38: 0x000000010044120c XCTestCore`-[XCTestSuite performTest:] + 240
frame #39: 0x00000001003be358 XCTestCore`-[XCTest runTest] + 64
frame #40: 0x0000000100441728 XCTestCore`-[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] + 160
frame #41: 0x0000000100441594 XCTestCore`__27-[XCTestSuite performTest:]_block_invoke + 216
frame #42: 0x0000000100440f34 XCTestCore`__59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke + 48
frame #43: 0x000000010043e4f4 XCTestCore`+[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 228
frame #44: 0x0000000100440ed0 XCTestCore`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 192
frame #45: 0x000000010044120c XCTestCore`-[XCTestSuite performTest:] + 240
frame #46: 0x00000001003be358 XCTestCore`-[XCTest runTest] + 64
frame #47: 0x0000000100441728 XCTestCore`-[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] + 160
frame #48: 0x0000000100441594 XCTestCore`__27-[XCTestSuite performTest:]_block_invoke + 216
frame #49: 0x0000000100440f34 XCTestCore`__59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke + 48
frame #50: 0x000000010043e4f4 XCTestCore`+[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 228
frame #51: 0x0000000100440ed0 XCTestCore`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 192
frame #52: 0x000000010044120c XCTestCore`-[XCTestSuite performTest:] + 240
frame #53: 0x00000001003be358 XCTestCore`-[XCTest runTest] + 64
frame #54: 0x00000001003c04b4 XCTestCore`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke_2 + 160
frame #55: 0x000000010043e4f4 XCTestCore`+[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 228
frame #56: 0x00000001003c0404 XCTestCore`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 152
frame #57: 0x00000001003c05c8 XCTestCore`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke.98 + 116
frame #58: 0x00000001003eafc8 XCTestCore`-[XCTestObservationCenter _observeTestExecutionForBlock:] + 340
frame #59: 0x00000001003c0154 XCTestCore`-[XCTTestRunSession runTestsAndReturnError:] + 504
frame #60: 0x000000010043ba44 XCTestCore`-[XCTestDriver _runTests] + 464
frame #61: 0x00000001003be9fc XCTestCore`_XCTestMain + 100
frame #62: 0x00000001000063a8 xctest`main + 272
frame #63: 0x00000001917a1450 libdyld.dylib`start + 4
Taking look to the frames 7 and 6 we see that the mdbx_setup_dxb(env=0x000000011b0b5440, lck_rc=-1, mode_bits=438)
https://github.com/erthink/libmdbx/blob/bf603bdffc22c00d393b7614c1f11f3ebe4efb25/src/core.c#L11430-L11434 calls the mdbx_read_header(env=0x000000011b0b5440, dest=0x000000016fdfbdf2, lck_exclusive=-1, mode_bits=438)
https://github.com/erthink/libmdbx/blob/bf603bdffc22c00d393b7614c1f11f3ebe4efb25/src/core.c#L10347-L10355
During this call the dest
param of callee points to the local variable meta
of the caller.
The meta
variable is placed on the stack frame and there is no reason for it to be unaligned.
However, actually the dest
pointer is 0x000000016fdfbdf2
.
I have no explanation for this yet, except a compiler' bug.
@youjinp, as an experiment, suggest you trying to change the https://github.com/erthink/libmdbx/blob/bf603bdffc22c00d393b7614c1f11f3ebe4efb25/src/internals.h#L440 to #pragma pack(push, 4)
.
Well.. that worked!
Well.. that worked!
Ok, I will commit a such fix. Thanks for reporting.
Problem
Hi,
After updating from 10.1 to 10.3, I'm getting this failure on
mdbx_env_open
I've gotten the same issue on 10.2
What have I missed?
Thank you
Build
Built using the iOS-toolchain:
Config
Version