EdgeTX / edgetx

EdgeTX is the cutting edge open source firmware for your R/C radio
https://edgetx.org
GNU General Public License v2.0
1.53k stars 327 forks source link

Crash of Simulator when running a lua script #3195

Open voltangle opened 1 year ago

voltangle commented 1 year ago

Is there an existing issue for this problem?

What part of EdgeTX is the focus of this bug?

Simulator

Current Behavior

The whole thing crashes when running this code:


local video_data = {
-- truncated
}

local function delay(time)
    local currentTime = getTime()
    while (currentTime + time > getTime()) do end
end

local function init()
    lcd.clear()
    playFile("/SOUNDS/badapple.wav")
end

local function run(event, touchState)
    lcd.clear()
    for i, frames in ipairs(video_data) do
        local time = getTime()
        for _, coords in ipairs(frames) do
            print(string.format("Rectangle - x1: %d, x2: %d, y1: %d, y2: %d", coords[2], coords[1], coords[4], coords[3]))
            lcd.drawRectangle(coords[2], coords[1], coords[4], coords[3])
        end
        print("frame: ", i)
        lcd.refresh()
        while (time + 10 > getTime()) do end
    end
    return 0
end

return { run=run, init=init }

...with this error:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               companion [58769]
Path:                  /Applications/EdgeTX Companion 2.8.app/Contents/MacOS/companion
Identifier:            org.edgetx.companion
Version:                ()
Code Type:             X86-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-02-15 10:21:16.7341 +0100
OS Version:            macOS 13.2 (22D49)
Report Version:        12
Anonymous UUID:        1F729388-7A6A-BF7A-50B9-394BCB76FBDE

Sleep/Wake UUID:       D1E1C032-012C-4743-BD0D-BD8910980D04

Time Awake Since Boot: 270000 seconds
Time Since Wake:       48600 seconds

System Integrity Protection: disabled

Crashed Thread:        13

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process:   exc handler [58769]

Application Specific Information:
BUG IN CLIENT OF LIBPLATFORM: os_unfair_lock is corrupt, or owner thread exited without unlocking
Abort Cause 2042

Thread 0::  Dispatch queue: com.apple.main-thread
0   CoreFoundation                      0x7ff81c0c72bb -[__NSArrayM count] + 24
1   CoreFoundation                      0x7ff81c12537e CFRunLoopRemoveObserver + 180
2   AppKit                              0x7ff81f697712 __38-[NSApplication setWindowsNeedUpdate:]_block_invoke_2 + 91
3   AppKit                              0x7ff81f69b136 ___NSRunLoopObserverCreateWithHandler_block_invoke + 41
4   CoreFoundation                      0x7ff81c125092 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
5   CoreFoundation                      0x7ff81c124fba __CFRunLoopDoObservers + 482
6   CoreFoundation                      0x7ff81c124540 __CFRunLoopRun + 870
7   CoreFoundation                      0x7ff81c123b60 CFRunLoopRunSpecific + 560
8   HIToolbox                           0x7ff825a71766 RunCurrentEventLoopInMode + 292
9   HIToolbox                           0x7ff825a71396 ReceiveNextEventCommon + 199
10  HIToolbox                           0x7ff825a712b3 _BlockUntilNextEventMatchingListInModeWithFilter + 70
11  AppKit                              0x7ff81f274293 _DPSNextEvent + 909
12  AppKit                              0x7ff81f273114 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1219
13  AppKit                              0x7ff81f51421e -[NSApplication _doModalLoop:peek:] + 301
14  AppKit                              0x7ff81f69605a __33-[NSApplication runModalSession:]_block_invoke_2 + 69
15  AppKit                              0x7ff81f696002 __33-[NSApplication runModalSession:]_block_invoke + 78
16  AppKit                              0x7ff81f51260b _NSTryRunModal + 100
17  AppKit                              0x7ff81f695eff -[NSApplication runModalSession:] + 128
18  libqcocoa.dylib                        0x102a86b17 0x102a51000 + 219927
19  QtCore                                 0x104089817 QCoreApplication::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 39
20  companion                              0x10156b6c7 DebugOutput::processBytesReceived() + 199
21  QtCore                                 0x1040b2d41 QObject::event(QEvent*) + 753
22  QtWidgets                              0x102e0b4da QWidget::event(QEvent*) + 4826
23  QtWidgets                              0x102dce67d QApplicationPrivate::notify_helper(QObject*, QEvent*) + 269
24  QtWidgets                              0x102dcfa82 QApplication::notify(QObject*, QEvent*) + 594
25  QtCore                                 0x104089324 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 212
26  QtCore                                 0x10408a55e QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 878
27  libqcocoa.dylib                        0x102a878f9 0x102a51000 + 223481
28  libqcocoa.dylib                        0x102a88068 0x102a51000 + 225384
29  CoreFoundation                      0x7ff81c125b78 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
30  CoreFoundation                      0x7ff81c125b27 __CFRunLoopDoSource0 + 157
31  CoreFoundation                      0x7ff81c125901 __CFRunLoopDoSources0 + 212
32  CoreFoundation                      0x7ff81c12457b __CFRunLoopRun + 929
33  CoreFoundation                      0x7ff81c123b60 CFRunLoopRunSpecific + 560
34  HIToolbox                           0x7ff825a71766 RunCurrentEventLoopInMode + 292
35  HIToolbox                           0x7ff825a71576 ReceiveNextEventCommon + 679
36  HIToolbox                           0x7ff825a712b3 _BlockUntilNextEventMatchingListInModeWithFilter + 70
37  AppKit                              0x7ff81f274293 _DPSNextEvent + 909
38  AppKit                              0x7ff81f273114 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1219
39  libqcocoa.dylib                        0x102a86d4e 0x102a51000 + 220494
40  QtCore                                 0x10408493f QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 431
41  QtCore                                 0x104089932 QCoreApplication::exec() + 130
42  companion                              0x101241055 main + 3077
43  dyld                                0x7ff81bd17310 start + 2432

Thread 1:
0   libsystem_pthread.dylib             0x7ff81c045c58 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib             0x7ff81c045c58 start_wqthread + 0

Thread 3:: Qt bearer thread
0   libsystem_kernel.dylib              0x7ff81c0122d6 poll + 10
1   QtCore                                 0x1040df690 qt_safe_poll(pollfd*, unsigned int, timespec const*) + 608
2   QtCore                                 0x1040e0e87 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 903
3   QtCore                                 0x10408493f QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 431
4   QtCore                                 0x103ec013c QThread::exec() + 140
5   QtCore                                 0x103ec10b3 0x103e9f000 + 139443
6   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
7   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 4:: com.apple.NSEventThread
0   libsystem_kernel.dylib              0x7ff81c00b5c2 mach_msg2_trap + 10
1   libsystem_kernel.dylib              0x7ff81c019604 mach_msg2_internal + 82
2   libsystem_kernel.dylib              0x7ff81c012635 mach_msg_overwrite + 723
3   libsystem_kernel.dylib              0x7ff81c00b8a8 mach_msg + 19
4   CoreFoundation                      0x7ff81c125cbe __CFRunLoopServiceMachPort + 145
5   CoreFoundation                      0x7ff81c12472a __CFRunLoopRun + 1360
6   CoreFoundation                      0x7ff81c123b60 CFRunLoopRunSpecific + 560
7   AppKit                              0x7ff81f3d5129 _NSEventThread + 132
8   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
9   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 5:
0   libsystem_pthread.dylib             0x7ff81c045c58 start_wqthread + 0

Thread 6:: QNetworkAccessManager thread
0   libsystem_kernel.dylib              0x7ff81c0122d6 poll + 10
1   QtCore                                 0x1040df48a qt_safe_poll(pollfd*, unsigned int, timespec const*) + 90
2   QtCore                                 0x1040e0e87 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 903
3   QtCore                                 0x10408493f QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 431
4   QtCore                                 0x103ec013c QThread::exec() + 140
5   QtCore                                 0x103ec10b3 0x103e9f000 + 139443
6   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
7   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 7:: Thread (pooled)
0   libsystem_kernel.dylib              0x7ff81c00e11a __psynch_cvwait + 10
1   libsystem_pthread.dylib             0x7ff81c04a7e1 _pthread_cond_wait + 1243
2   QtCore                                 0x103ec9bdf 0x103e9f000 + 175071
3   QtCore                                 0x103ec98ce 0x103e9f000 + 174286
4   QtCore                                 0x103ec980c QWaitCondition::wait(QMutex*, QDeadlineTimer) + 108
5   QtCore                                 0x103ec976e QWaitCondition::wait(QMutex*, unsigned long) + 62
6   QtCore                                 0x103ec6237 0x103e9f000 + 160311
7   QtCore                                 0x103ec10b3 0x103e9f000 + 139443
8   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
9   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 8:: QNetworkAccessManager thread
0   libsystem_kernel.dylib              0x7ff81c0122d6 poll + 10
1   QtCore                                 0x1040df48a qt_safe_poll(pollfd*, unsigned int, timespec const*) + 90
2   QtCore                                 0x1040e0e87 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 903
3   QtCore                                 0x10408493f QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 431
4   QtCore                                 0x103ec013c QThread::exec() + 140
5   QtCore                                 0x103ec10b3 0x103e9f000 + 139443
6   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
7   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 9:: QNetworkAccessManager thread
0   libsystem_kernel.dylib              0x7ff81c0122d6 poll + 10
1   QtCore                                 0x1040df48a qt_safe_poll(pollfd*, unsigned int, timespec const*) + 90
2   QtCore                                 0x1040e0e87 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 903
3   QtCore                                 0x10408493f QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 431
4   QtCore                                 0x103ec013c QThread::exec() + 140
5   QtCore                                 0x103ec10b3 0x103e9f000 + 139443
6   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
7   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 10:: QThread
0   libsystem_kernel.dylib              0x7ff81c0122d6 poll + 10
1   QtCore                                 0x1040df48a qt_safe_poll(pollfd*, unsigned int, timespec const*) + 90
2   QtCore                                 0x1040e0e87 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 903
3   QtCore                                 0x10408493f QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 431
4   QtCore                                 0x103ec013c QThread::exec() + 140
5   QtCore                                 0x103ec10b3 0x103e9f000 + 139443
6   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
7   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 11:
0   libsystem_kernel.dylib              0x7ff81c016c82 sem_wait + 10
1   libedgetx-x7-simulator.dylib           0x10c17da61 eeprom_thread_function(void*) + 33
2   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
3   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 12:
0   libsystem_kernel.dylib              0x7ff81c00dfea __semwait_signal + 10
1   libsystem_c.dylib                   0x7ff81bf22a9a nanosleep + 196
2   libsystem_c.dylib                   0x7ff81bf229d0 usleep + 53
3   libedgetx-x7-simulator.dylib           0x10c17ce22 audioThread(void*) + 114
4   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
5   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 13 Crashed:
0   libsystem_platform.dylib            0x7ff81c078ed3 _os_unfair_lock_corruption_abort + 37
1   libsystem_platform.dylib            0x7ff81c0731a4 _os_unfair_lock_lock_slow + 257
2   libsystem_pthread.dylib             0x7ff81c04619d pthread_mutex_destroy + 47
3   libSDL-1.2.0.dylib                     0x1025be063 SDL_DestroyMutex + 19
4   libSDL-1.2.0.dylib                     0x102589e44 SDL_AudioQuit + 68
5   libSDL-1.2.0.dylib                     0x102589120 SDL_QuitSubSystem + 96
6   libSDL-1.2.0.dylib                     0x10258919e SDL_Quit + 14
7   libSDL-1.2.0.dylib                     0x1025899b4 SDL_Parachute + 20
8   libsystem_platform.dylib            0x7ff81c074c1d _sigtramp + 29
9   ???                                            0x0 ???
10  libedgetx-x7-simulator.dylib           0x10c0e6235 mixerTask(void*) + 69
11  libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
12  libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 14:
0   libsystem_kernel.dylib              0x7ff81c00dfea __semwait_signal + 10
1   libsystem_c.dylib                   0x7ff81bf22a9a nanosleep + 196
2   libsystem_c.dylib                   0x7ff81bf229d0 usleep + 53
3   CoreAudio                              0x10c6469c9 0x10c63c000 + 43465
4   CoreAudio                              0x10c67c40b DefaultOutputAUEntry + 229
5   AudioToolboxCore                    0x7ff81ddc455c AudioOutputUnitStop + 207
6   libSDL-1.2.0.dylib                     0x1025be60b Core_CloseAudio + 27
7   libSDL-1.2.0.dylib                     0x102589e79 SDL_AudioQuit + 121
8   libSDL-1.2.0.dylib                     0x102589120 SDL_QuitSubSystem + 96
9   libSDL-1.2.0.dylib                     0x10258919e SDL_Quit + 14
10  libSDL-1.2.0.dylib                     0x1025899b4 SDL_Parachute + 20
11  libsystem_platform.dylib            0x7ff81c074c1d _sigtramp + 29
12  ???                                 0x600001c467c0 ???
13  libedgetx-x7-simulator.dylib           0x10c10e833 luaLcdDrawRectangle(lua_State*) + 131
14  libedgetx-x7-simulator.dylib           0x10c116d39 luaD_precall + 553
15  libedgetx-x7-simulator.dylib           0x10c127a2e luaV_execute + 3550
16  libedgetx-x7-simulator.dylib           0x10c117629 resume + 233
17  libedgetx-x7-simulator.dylib           0x10c1166d6 luaD_rawrunprotected + 86
18  libedgetx-x7-simulator.dylib           0x10c11734b lua_resume + 75
19  libedgetx-x7-simulator.dylib           0x10c1052d2 luaTask(unsigned short, bool) + 850
20  libedgetx-x7-simulator.dylib           0x10c0e5e23 guiMain(unsigned short) + 291
21  libedgetx-x7-simulator.dylib           0x10c0e634d menusTask(void*) + 77
22  libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
23  libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 15:: caulk.messenger.shared:17
0   libsystem_kernel.dylib              0x7ff81c00b53e semaphore_wait_trap + 10
1   caulk                               0x7ff8257bd8f8 caulk::mach::semaphore::wait_or_error() + 16
2   caulk                               0x7ff8257a3664 caulk::concurrent::details::worker_thread::run() + 36
3   caulk                               0x7ff8257a3328 void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, void (caulk::concurrent::details::worker_thread::*)(), std::__1::tuple<caulk::concurrent::details::worker_thread*> > >(void*) + 41
4   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
5   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 16:: com.apple.audio.IOThread.client
0   libsystem_kernel.dylib              0x7ff81c00b5c2 mach_msg2_trap + 10
1   libsystem_kernel.dylib              0x7ff81c019604 mach_msg2_internal + 82
2   libsystem_kernel.dylib              0x7ff81c012635 mach_msg_overwrite + 723
3   libsystem_kernel.dylib              0x7ff81c00b8a8 mach_msg + 19
4   CoreAudio                           0x7ff81e36d38d HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 111
5   CoreAudio                           0x7ff81e2405be HALC_ProxyIOContext::IOWorkLoop() + 4058
6   CoreAudio                           0x7ff81e23efe4 invocation function for block in HALC_ProxyIOContext::HALC_ProxyIOContext(unsigned int, unsigned int) + 80
7   CoreAudio                           0x7ff81e3cdaa4 HALB_IOThread::Entry(void*) + 72
8   libsystem_pthread.dylib             0x7ff81c04a259 _pthread_start + 125
9   libsystem_pthread.dylib             0x7ff81c045c7b thread_start + 15

Thread 13 crashed with X86 Thread State (64-bit):
  rax: 0x00000000000007fa  rbx: 0x0000000001050002  rcx: 0x00007ff81c0796fd  rdx: 0x0000000000000000
  rdi: 0x00000000000007fa  rsi: 0x0000600001c0be48  rbp: 0x000070000d9ab930  rsp: 0x000070000d9ab8f8
   r8: 0x000070000d9abe98   r9: 0xfb9bac6972b62c75  r10: 0x0000000000000000  r11: 0x0000000000000246
  r12: 0x0000000000014007  r13: 0x000000010c1b2f00  r14: 0x0000000000014007  r15: 0x0000600001c0be48
  rip: 0x00007ff81c078ed3  rfl: 0x0000000000010287  cr2: 0x000000010258f7f0

Logical CPU:     0
Error Code:      0x00000000 
Trap Number:     6

Thread 13 instruction stream:
  48 89 05 ae 87 d3 41 0f-0b 89 f8 48 8d 0d d7 07  H.....A....H....
  00 00 48 89 0d 6c 87 d3-41 48 89 05 95 87 d3 41  ..H..l..AH.....A
  0f 0b 89 f8 48 8d 0d 09-08 00 00 48 89 0d 53 87  ....H......H..S.
  d3 41 48 89 05 7c 87 d3-41 0f 0b 8d 8f 00 fe ff  .AH..|..A.......
  ff 89 f8 81 f9 00 fe 03-00 77 17 48 8d 0d 38 08  .........w.H..8.
  00 00 48 89 0d 2c 87 d3-41 48 89 05 55 87 d3 41  ..H..,..AH..U..A
 [0f]0b 48 8d 0d 83 08 00-00 48 89 0d 15 87 d3 41  ..H......H.....A <==
  48 89 05 3e 87 d3 41 0f-0b 89 f8 48 8d 0d 98 09  H..>..A....H....
  00 00 48 89 0d fc 86 d3-41 48 89 05 25 87 d3 41  ..H.....AH..%..A
  0f 0b 89 f8 48 8d 0d c5-09 00 00 48 89 0d e3 86  ....H......H....
  d3 41 48 89 05 0c 87 d3-41 0f 0b 89 f8 48 8d 0d  .AH.....A....H..
  fd 09 00 00 48 89 0d ca-86 d3 41 48 89 05 f3 86  ....H.....AH....

Binary Images:
    0x7ff81c0a6000 -     0x7ff81c53ffef com.apple.CoreFoundation (6.9) <c2615780-0140-315c-a455-7e03bb22d3d6> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7ff81f236000 -     0x7ff82023eff2 com.apple.AppKit (6.9) <480a5693-f3e3-3b50-a1f3-169d12a12a0e> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
    0x7ff825a42000 -     0x7ff825d39ffd com.apple.HIToolbox (2.1.1) <7bf47984-29cb-319e-a6da-0884d158f96a> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
       0x102a51000 -        0x102bb8fff libqcocoa.dylib (*) <aaf96c3b-7fa8-364b-9e1b-039f8d891422> /Applications/EdgeTX Companion 2.8.app/Contents/Plugins/platforms/libqcocoa.dylib
       0x103e9f000 -        0x1043d4fff org.qt-project.QtCore (5.12) <4016188b-3e53-3268-95b9-a3826de2f323> /Applications/EdgeTX Companion 2.8.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore
       0x10118d000 -        0x102125fff org.edgetx.companion (*) <2271ea1e-73ce-3b80-9279-66a8e5633c36> /Applications/EdgeTX Companion 2.8.app/Contents/MacOS/companion
       0x102dbe000 -        0x1031fcfff org.qt-project.QtWidgets (5.12) <234d0c44-43b0-3e31-a215-9b8c6ff91ce9> /Applications/EdgeTX Companion 2.8.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets
    0x7ff81bd11000 -     0x7ff81bda5caf dyld (*) <270c4224-a38f-3a22-9ba9-95968f487738> /usr/lib/dyld
    0x7ff81c044000 -     0x7ff81c04fff7 libsystem_pthread.dylib (*) <3bd433d4-15bd-3add-a612-95e4d3b20719> /usr/lib/system/libsystem_pthread.dylib
    0x7ff81c00a000 -     0x7ff81c043ff7 libsystem_kernel.dylib (*) <ca136b67-0559-3f19-8b7e-9b80438090b6> /usr/lib/system/libsystem_kernel.dylib
       0x10c0d0000 -        0x10c195fff libedgetx-x7-simulator.dylib (*) <ce2bf1bb-5a6b-373f-bc23-6fdb9baab2ab> /Applications/EdgeTX Companion 2.8.app/Contents/Resources/libedgetx-x7-simulator.dylib
    0x7ff81bf12000 -     0x7ff81bf9afff libsystem_c.dylib (*) <1aec5d1a-6e43-30f9-a9f2-11eb85d3e70c> /usr/lib/system/libsystem_c.dylib
    0x7ff81c071000 -     0x7ff81c07aff7 libsystem_platform.dylib (*) <04645919-7592-3a26-93b5-95663f983856> /usr/lib/system/libsystem_platform.dylib
       0x102588000 -        0x1025c8fff libSDL-1.2.0.dylib (*) <f5d95d77-1cf0-3856-9978-382fb4dc261e> /Applications/EdgeTX Companion 2.8.app/Contents/Frameworks/libSDL-1.2.0.dylib
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x10c63c000 -        0x10c77bfff com.apple.audio.units.Components (1.14) <0ca017dd-3578-3e5b-be2d-7bd22a8ce342> /System/Library/Components/CoreAudio.component/Contents/MacOS/CoreAudio
    0x7ff81dbc1000 -     0x7ff81de6dfef com.apple.audio.AudioToolboxCore (1.0) <61cc9361-069e-3abc-9fc4-826015cfb91a> /System/Library/PrivateFrameworks/AudioToolboxCore.framework/Versions/A/AudioToolboxCore
    0x7ff8257a1000 -     0x7ff8257c6fff com.apple.audio.caulk (1.0) <bf7582bd-4de0-3ca2-8b69-f1944725f182> /System/Library/PrivateFrameworks/caulk.framework/Versions/A/caulk
    0x7ff81e05d000 -     0x7ff81e77bff5 com.apple.audio.CoreAudio (5.0) <3b6e93dd-f8c6-338c-9251-5e750e091dd3> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=635.2M resident=0K(0%) swapped_out_or_unallocated=635.2M(100%)
Writable regions: Total=612.8M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=612.8M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Accelerate framework               256K        2 
Activity Tracing                   256K        1 
CG backing stores                  720K        4 
CG image                            52K        9 
ColorSync                          108K        9 
CoreAnimation                       56K        9 
CoreGraphics                        28K        4 
CoreUI image data                  576K       10 
Foundation                          80K        3 
Kernel Alloc Once                    8K        1 
MALLOC                           210.9M      111 
MALLOC guard page                   32K        8 
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                       56.1M       17 
Stack                             16.1M       17 
VM_ALLOCATE                        288K       15 
__CTF                               756        1 
__DATA                            24.0M      501 
__DATA_CONST                      29.5M      302 
__DATA_DIRTY                      1390K      165 
__FONT_DATA                        2352        1 
__LINKEDIT                       187.8M       30 
__OBJC_RO                         65.5M        1 
__OBJC_RW                         1989K        2 
__TEXT                           447.3M      516 
dyld private memory                288K        3 
mapped file                      128.0M       58 
shared memory                      796K       23 
===========                     =======  ======= 
TOTAL                              1.5G     1824 
TOTAL, minus reserved VM space     1.1G     1824 

Expected Behavior

Well, not crash and at least show a meaningful error message 🤷

Steps To Reproduce

  1. Go to the simulator
  2. Open the script
  3. See the simulator shit the bed while trying to run it

Version

2.8.0

Transmitter

Taranis Q X7

Anything else?

For debugging purposes, here is a file with some video data: badapple.lua.zip

voltangle commented 1 year ago

I have not tested this on a real device because the radio doesn't have enough memory even for 20 frames

raphaelcoeffic commented 1 year ago

I'm using the simpler simu to test (does not use Qt) and it "works". By that I mean that it does not crash or causes any bad memory accesses (tested with -DASAN=YES; LLVM's address sanitiser).

frankiearzu commented 1 year ago

That method of delay seems weird "while (time + 10 > getTime()) do end", the run() function should do work and exit as soon as it can. Also using CPU time for nothing.

Have you try do it incrementally.. i.e, on every call to run() do only 1 frame?? and if it is too soon to display the next frame, exit run() without doing anything? You will need to keep track of the what is your current displayed frame as well as the last displayed time at script level variables.

voltangle commented 1 year ago

That's a good suggestion, thanks! But that's an issue with the script logic, and it should definitely not result in the simulator dying btw now it works fine after upgrading to 2.8.1, so yea that's that

gagarinlg commented 1 year ago

No Lua script should be able to crash the radio. But there are a lot of checks missing.

frankiearzu commented 1 year ago

The challenge with embeded programming is that is not like traditional PC software. In many embeded systems, they use what is called "Cooperative Multitasking" that is that a running task has to give up the CPU to switch to other tasks. That was the original intention on OpenTX/EdgeTx. EdgeTX changed it multi-tasking library to a more modern one, but the LUA programming philosofy shoud still be the same. Short running method calls and not hog the CPU

pierrotm777 commented 5 months ago

Hello frankiearzu,

I look for a method to keep a message on my screen 3s. I have tried this method without success

  local idSA = getFieldInfo("sh").id
  local ss = getValue (idSA) -- ON=1024, OFF=-1024
  if ss > 0 then -- chech SwReset switch
    local timeMs = getTime()
    lcd.drawText(20 , 50, "RESET SWITCH TOGGLED", DBLSIZE + RED + SHADOWED)
    while (timeMs + 3 > getTime()) do end
  end

Thanks for your help,

Pierre

frankiearzu commented 5 months ago

You cannot have delays or long delay loops in LUA.  Every time a refresh it called, it needs to return as soon as posible.You can do a state machine.. with 2 states: Normal and DiplayMsg.You start in Display state,Every time refresh is called, if you need to show a message, you record your start time and switch to display state.In the display state, you display your message, and check if the time is past 3s.. If so, you change your state back to normal.On Mar 31, 2024, at 5:59 AM, pierrotm777 @.***> wrote: Hello frankiearzu, I look for a method to keep a message on my screen 3s. I have tried this method without success local idSA = getFieldInfo("sh").id local ss = getValue (idSA) -- ON=1024, OFF=-1024 if ss > 0 then -- chech SwReset switch local timeMs = getTime() lcd.drawText(20 , 50, "RESET SWITCH TOGGLED", DBLSIZE + RED + SHADOWED) while (timeMs + 3 > getTime()) do end end

Thanks for your help, Pierre

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

pierrotm777 commented 5 months ago

Do you have an example how to change the display state ?

frankiearzu commented 5 months ago

Is just a variable, you assign a value to it. You can say value 1 is normal, value 2 is displaying message.So in your main loop you will have an IF for each of the state (1 and 2) and put the corresponding code for each.  On Mar 31, 2024, at 9:44 AM, pierrotm777 @.***> wrote: Do you have an example how to change the display state ?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

pierrotm777 commented 5 months ago

Ok, thanks