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

vkCreateDebugReportCallbackEXT causes segmentation fault #4

Closed
sohailshafii opened this issue May 3, 2017 · 8 comments
Closed

vkCreateDebugReportCallbackEXT causes segmentation fault #4

sohailshafii opened this issue May 3, 2017 · 8 comments

Comments

@sohailshafii
Copy link

sohailshafii commented May 3, 2017

Hello,

I've gotten the "hellovulkan" example running with little fuss. Just to make sure that we are on the same page, I compiled an armeabi-v7a (I'll just call it armv7 from now) version of the lwjgl library by defining the LWJGL_BUILD_ARCH environment variable prior to following the instructions here. I have NDK 14.1 installed and my test device is a Samsung S7.

Anyway, I copied over the relevant .so files from my SDK's armv7 NDK jniLibs directory to the "android-test" project and set the VALIDATE variable to true. This includes stuff like libVKlayer_core_validation.so, libVkLayer_image.so, libVkLayer_object_tracker.so, and so on. Every piece of validation code seems to run without a hitch except for vkCreateDebugReportCallbackEXT -- the item causes the following seg fault as seen in the ADB log:

--------- beginning of crash
05-03 10:47:12.451 16514 16605 F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 16605 (VKThread)
05-03 10:47:12.452 607 607 W : debuggerd: handling request: pid=16514 uid=10106 gid=10106 tid=16605
05-03 10:47:12.531 1662 1662 D CustomFrequencyManagerService: releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1555200 uid : 1000 pid : 1662 tag : AMS_RESUME_TAIL@CPU_MIN@24
05-03 10:47:12.534 16640 16640 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-03 10:47:12.534 16640 16640 F DEBUG : Build fingerprint: 'Verizon/heroqltevzw/heroqltevzw:7.0/NRD90M/G930VVRU4BQC5:user/release-keys'
05-03 10:47:12.534 16640 16640 F DEBUG : Revision: '14'
05-03 10:47:12.534 16640 16640 F DEBUG : ABI: 'arm'
05-03 10:47:12.535 16640 16640 F DEBUG : pid: 16514, tid: 16605, name: VKThread >>> org.lwjgl.demo.android.hellovulkan <<<
05-03 10:47:12.535 9246 9355 I PlayCommon: [809] PlayEventLogger.uploadEventsImpl: Preparing logs for uploading
05-03 10:47:12.535 16640 16640 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
05-03 10:47:12.535 16640 16640 F DEBUG : r0 dc5fed04 r1 c82a777c r2 00000004 r3 00000000
05-03 10:47:12.535 9246 9355 I PlayCommon: [809] PlayEventLogger.uploadEventsImpl: No file ready to send
05-03 10:47:12.535 16640 16640 F DEBUG : r4 c843ee44 r5 c82a7ad8 r6 c82a7870 r7 c82a7830
05-03 10:47:12.535 16640 16640 F DEBUG : r8 c82a7870 r9 daa1e000 sl c82a7780 fp daa1e000
05-03 10:47:12.535 16640 16640 F DEBUG : ip c8133c65 sp c82a7760 lr e6d04a1b pc c8133c5e cpsr 200d0030
05-03 10:47:12.566 16640 16640 F DEBUG :
05-03 10:47:12.566 16640 16640 F DEBUG : backtrace:
05-03 10:47:12.566 16640 16640 F DEBUG : #00 pc 00030c5e /data/app/org.lwjgl.demo.android.hellovulkan-2/lib/arm/liblwjgl.so
05-03 10:47:12.566 16640 16640 F DEBUG : #1 pc 000ada19 /system/lib/libart.so (art_quick_generic_jni_trampoline+40)
05-03 10:47:12.566 16640 16640 F DEBUG : #2 pc 000a9041 /system/lib/libart.so (art_quick_invoke_stub_internal+64)
05-03 10:47:12.566 16640 16640 F DEBUG : #3 pc 004021e9 /system/lib/libart.so (art_quick_invoke_static_stub+228)
05-03 10:47:12.566 16640 16640 F DEBUG : #4 pc 000b02ff /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+178)

I don't know if you need more of the log here, but I can post there rest. For now I will post the tail of it here:

05-03 10:47:12.568 16640 16640 F DEBUG : #35 pc 000cbc73 /system/lib/libart.so (_ZN3art8CheckJNI11CallMethodVEPKcP7_JNIEnvP8_jobjectP7_jclassP10_jmethodIDSt9__va_listNS_9Primitive4TypeENS_10InvokeTypeE+1054)
05-03 10:47:12.568 16640 16640 F DEBUG : #36 pc 000c1789 /system/lib/libart.so (_ZN3art8CheckJNI13CallIntMethodEP7_JNIEnvP8_jobjectP10_jmethodIDz+52)
05-03 10:47:12.568 16640 16640 F DEBUG : #37 pc 0001610c /data/app/org.lwjgl.demo.android.hellovulkan-2/lib/arm/liblwjgl.so

In case this helps you, the layer checking code related to validation did not find VK_LAYER_LUNARG_standard_validation but found VK_LAYER_GOOGLE_threading, VK_LAYER_LUNARG_parameter_validation, VK_LAYER_LUNARG_object_tracker and VK_LAYER_LUNARG_object_tracker.

Here are some log messages that are printed during a successful run (vkCreateDebugReportCallbackEXT):
5-03 11:02:58.025 19508 19527 D vulkan : vulkan instance layer version (1/7) : 0.0.0/0
05-03 11:02:58.025 19508 19527 D vulkan : vulkan instance layer version (2/7) : 0.0.0/0
05-03 11:02:58.025 19508 19527 D vulkan : vulkan instance layer version (3/7) : 0.0.0/0
05-03 11:02:58.025 19508 19527 D vulkan : vulkan instance layer version (4/7) : 0.0.0/0
05-03 11:02:58.025 19508 19527 D vulkan : vulkan instance layer version (5/7) : 0.0.0/0
05-03 11:02:58.025 19508 19527 D vulkan : vulkan instance layer version (6/7) : 0.0.0/0
05-03 11:02:58.025 19508 19527 D vulkan : vulkan instance layer version (7/7) : 0.0.0/0
05-03 11:02:58.026 19508 19527 I Test : Could not find layer: VK_LAYER_LUNARG_standard_validation
05-03 11:02:58.027 19508 19527 I Test : Found layer: VK_LAYER_GOOGLE_threading
05-03 11:02:58.028 19508 19527 I Test : Found layer: VK_LAYER_LUNARG_parameter_validation
05-03 11:02:58.029 19508 19527 I Test : Found layer: VK_LAYER_LUNARG_object_tracker
05-03 11:02:58.029 19508 19527 I Test : Found layer: VK_LAYER_LUNARG_image
05-03 11:02:58.036 19508 19527 D vulkan : vulkan api version_1_0 1.0.0
05-03 11:02:58.036 19508 19527 D vulkan : vulkan header version 13
05-03 11:02:58.043 19508 19527 I vulkan : Loaded layer VK_LAYER_LUNARG_core_validation
05-03 11:02:58.045 19508 19527 I vulkan : Loaded layer VK_LAYER_LUNARG_swapchain
05-03 11:02:58.046 19508 19527 I vulkan : Loaded layer VK_LAYER_GOOGLE_unique_objects

@sohailshafii
Copy link
Author

I assume that vkGetInstanceProcAddr needs to be called for vkCreateDebugReportCallbackEXT. The code in the example provided in android-test does not do that (unless that example was updated recently). I know how to use vkGetInstanceProcAddr in C++ so I'm wondering how I would do the same in Java.

@Spasi
Copy link
Member

Spasi commented May 5, 2017

Are you running HelloVulkan without any modifications? The VALIDATE flag at line 53 must be set to true in order to enable validation (enumerates the validation layers, enables the EXT_debug_report extension and calls vkCreateDebugReportCallbackEXT).

I assume that vkGetInstanceProcAddr needs to be called for vkCreateDebugReportCallbackEXT

No, the vkCreateDebugReportCallbackEXT function pointer is stored in the VkInstance passed as the first parameter.

@sohailshafii
Copy link
Author

The only changes I made to that Java file are that VALIDATE flag as you mentioned (it is true) and a log statement right before the call for vkCreateDebugReportCallbackEXT (for debugging purposes). I just ran it again and it's that line that causes the crash. The S7 I am running the program on has Android 7.0 on it and I don't know that would relate to this at all (i.e. maybe an older version of Android would have problems with this but I really doubt that).

The rest of the project is unchanged with the exception of:
-the armv7 jnilibs in main/jniLibs/armeabi-v7a (libVkLayer_core_validation.so, *_image.so, *_object_tracker.so, *_parameter_validation.so, *_swapchain.so, *_threading.so and *_unique_objects.so)
-the armv7 lwjgl aar file.
-Android studio forced me to update the gradle version in build.gradle to 2.3.1 (from 2.3.0-beta3)

@Spasi
Copy link
Member

Spasi commented May 5, 2017

I think the problem is related to dyncall, which is used to implement callbacks in LWJGL. The armeabi-v7a artifacts for dyncall where available on our S3 build bucket, but I noticed that there was no CI setup for that architecture. I can't remember when/how those binaries were build.

The CI and a fresh build is up now, please rebuild lwjgl3 for armeabi-v7a and try again. The build script should download new .a files under libs/android/armeabi-v7a, please verify that they're dated 5/5.

@sohailshafii
Copy link
Author

sohailshafii commented May 6, 2017

I've verified that the .a files are dated 5/5 after the recompilation. Unfortunately, the problem still persists.

@Spasi
Copy link
Member

Spasi commented May 8, 2017

Hey @sohailshafii,

The bug was indeed in LWJGL's callback implementation. It has been fixed with LWJGL/lwjgl3@26459f7 and the android branch has been updated to include the fix.

Please note that the validation layer binaries in the NDK are not up-to-date and have issues. In my tests, they reported errors that shouldn't happen and VK_LAYER_LUNARG_core_validation crashed after a while. It might be a good idea to build them from source.

Thanks for reporting this issue!

@Spasi
Copy link
Member

Spasi commented May 8, 2017

To clarify: the aarch64 validation layers worked fine, it was the armeabi-v7a binaries that were problematic for me (tested on Nvidia Shield and Nexus 6P), after fixing the callback bugs.

@sohailshafii
Copy link
Author

sohailshafii commented May 9, 2017

Thank you for your assistance and attention on this matter. I've verified that the debug callback now works in android-test and in my own program. When I get a chance I will recompile the validation layer binaries in the NDK.

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