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

Oboe unit tests crashing with memory corruption, library cross linking the flowgraph code #930

Closed
philburk opened this issue Jul 8, 2020 · 1 comment · Fixed by #931 or #941
Closed
Assignees
Labels
bug P1 high priority

Comments

@philburk
Copy link
Collaborator

philburk commented Jul 8, 2020

Oboe version: <= 1.4.2
App name used for testing: unit tests

Short description
Unit tests that open and close an MMAP stream crash due to memory corruption.
The root cause is because AAudio is creating an object using the flowgraph code in AAudio,
but calling the destructor in Oboe!
The Oboe and AAudio flowgraph code is similar but not identical. So it crashes.

Steps to reproduce
Run adb logcat in a separate window.
Follow instructions at: https://github.com/google/oboe/tree/master/tests
to run the tests.

Expected behavior
Test runs to completion and and reports number of tests that PASS.

Actual behavior
Test stops before final report.
Logcat shows Native Exception and stack trace like the one below.

Any additional context
See internal b/160633017

I added -fvisibility=hidden and it seemed to fix the problem.

Here is a stack dump:
07-06 14:32:54.969 F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7afffffff0 in tid 11546 (testOboe), pid 11546 (testOboe)

07-06 14:32:55.046 F DEBUG : #00 pc 00000000000444fc /apex/com.android.runtime/lib64/bionic/libc.so (scudo::Allocator<scudo::AndroidConfig, &(scudo_malloc_postinit)>::deallocate(void*, scudo::Chunk::Origin, unsigned long, unsigned long)+132) (BuildId: e0da623f4ab0530a50a9af9e181b341d)
07-06 14:32:55.046 F DEBUG : #1 pc 0000000000074110 /data/user/0/com.google.oboe.tests.unittestrunner/files/testOboe
07-06 14:32:55.046 F DEBUG : #2 pc 0000000000035144 /system/lib64/libaaudio_internal.so (AAudioFlowGraph::~AAudioFlowGraph()+148) (BuildId: 572fc676500947b5f7300082d299c641)
07-06 14:32:55.046 F DEBUG : #3 pc 0000000000033b80 /system/lib64/libaaudio_internal.so (aaudio::AudioStreamInternalPlay::~AudioStreamInternalPlay()+36) (BuildId: 572fc676500947b5f7300082d299c641)
07-06 14:32:55.046 F DEBUG : #4 pc 0000000000003b90 /system/lib64/libaaudio.so (AAudioStream_close.cfi+356) (BuildId: f0582a3365d1efd6d1317e4eb2a35e31)

@philburk philburk added the bug label Jul 8, 2020
philburk added a commit that referenced this issue Jul 8, 2020
This fixes a problem with AAudio calling flowgraph module
destructors in Oboe, which causes memory corruption.

Fixes #930
philburk added a commit that referenced this issue Jul 8, 2020
This fixes a problem with AAudio calling flowgraph module
destructors in Oboe, which causes memory corruption.

Fixes #930
@philburk
Copy link
Collaborator Author

philburk commented Jul 9, 2020

It is not safe to rely on a build option to prevent a dangerous memory corruption.
We should modify the source code to prevent this.

@philburk philburk reopened this Jul 9, 2020
philburk added a commit that referenced this issue Jul 9, 2020
to prevent AAudio from calling into the Oboe library
and causing memory corruption.

Fixes #930
philburk added a commit that referenced this issue Jul 9, 2020
to prevent AAudio from calling into the Oboe library
and causing memory corruption.

Pass in external namespace.

Fixes #930
@philburk philburk self-assigned this Jul 13, 2020
@philburk philburk added the P1 high priority label Jul 13, 2020
philburk added a commit that referenced this issue Jul 15, 2020
to prevent AAudio from calling into the Oboe library
and causing memory corruption.

Pass in external namespace.

Fixes #930
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug P1 high priority
Projects
None yet
1 participant