Consider the following code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <3ds.h>
int main(int argc, char* argv[])
{
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
printf("Hello, world!\n");
srvInit();
Handle notifsemaphore;
srvEnableNotification(¬ifsemaphore);
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
gfxSwapBuffers();
hidScanInput();
// Your code goes here
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
}
printf("Exiting");
svcCloseHandle(notifsemaphore);
gfxExit();
return 0;
}
This simple program takes, from a rough "Mississippi" timer, about 18.5 seconds to exit. Commenting out srvEnableNotification allows an exit as fast as you would expect. In a practical application it varies. I haven't seen it go any further than a whole minute, but some testers have complained that it takes several minutes to exit (???)
Doing some debugging, I found the following information about this hang, as provided through the following GDB info:
Thread 1 stopped.
svcSleepThread () at /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/svc.s:88
88 in /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/svc.s
(gdb) backtrace
#0 svcSleepThread () at /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/svc.s:88
#1 0x00129be4 in aptExit () at /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/services/apt.c:300
#2 0x0012c12c in __appExit ()
at /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/system/appExit.c:15
#3 0x001000f8 in __ctru_exit ()
at /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/system/stack_adjust.s:39
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) thread 2
[Switching to thread 2 (Thread 390)]
#0 svcWaitSynchronizationN () at /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/svc.s:271
271 in /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/svc.s
(gdb) backtrace
#0 svcWaitSynchronizationN () at /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/svc.s:271
#1 0x001295f8 in aptEventHandler (arg=<optimized out>)
at /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/services/apt.c:331
#2 0x00125694 in _thread_begin (arg=<optimized out>)
at /home/davem/projects/devkitpro/pacman-packages/libctru/src/source/thread.c:37
#3 0x00000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
These are the only two threads still alive, everything else has closed out. After talking with profi200 and yellows8 on IRC we couldn't figure anything out, which leads me to conclude that this is a bug in libctru. Here are the logs: https://pastebin.com/GxAaPvSq
Consider the following code:
This simple program takes, from a rough "Mississippi" timer, about 18.5 seconds to exit. Commenting out
srvEnableNotificationallows an exit as fast as you would expect. In a practical application it varies. I haven't seen it go any further than a whole minute, but some testers have complained that it takes several minutes to exit (???)Doing some debugging, I found the following information about this hang, as provided through the following GDB info:
These are the only two threads still alive, everything else has closed out. After talking with profi200 and yellows8 on IRC we couldn't figure anything out, which leads me to conclude that this is a bug in libctru. Here are the logs: https://pastebin.com/GxAaPvSq