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

[BUG]app crashed when click on tree node #1544

Closed
davelet opened this issue May 7, 2024 · 6 comments
Closed

[BUG]app crashed when click on tree node #1544

davelet opened this issue May 7, 2024 · 6 comments

Comments

@davelet
Copy link

davelet commented May 7, 2024

Remember to search before filing a new report

no similar issue found.

Describe the bug

I'm writing a little desktop app on Mac and using Tree.
The core code is

let mut tree = Tree::default().with_size(w, h);
        tree.set_root_label(".");
        tree.set_select_mode(TreeSelect::Multi);
        tree.set_color(Color::Blue);
        for i in 0 .. 5 {
            let ti = TreeItem::new(&tree, &*("item".to_owned() + &*i.to_string()));
            tree.add_item("2/2/3/1", &ti);
        }

     //   for i in 0 .. 5 {
     //       tree.add(&*("item".to_owned() + &*i.to_string()));
      //  }

        tree.set_callback(|t| {
            if let Some(items) = t.get_selected_items() {
                for i in items {
                    println!("{} selected", t.item_pathname(&i).unwrap());
                }
            }
        });

when the 2nd for block is commented out, the app runs well. But after I added it to logic, when I click on any tree node, the App will crash.

Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)

To Reproduce

see code above.
fltk=1.4.28

Expected behavior

no crash.

Screenshots

image

Desktop info

  • OS: macOS sonoma
  • Version 14.2.1

Additional info

System catch info :

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

Process:               json-hand [32745]
Path:                  /Users/USER/*/json-hand
Identifier:            json-hand
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        rustrover [84570]
Responsible:           rustrover [84570]
User ID:               505

Date/Time:             2024-05-07 17:42:03.6864 +0800
OS Version:            macOS 14.2.1 (23C71)
Report Version:        12
Bridge OS Version:     8.3 (21P3049)
Anonymous UUID:        4224A5B2-C349-6F4D-4091-6ACCFE19868C

Sleep/Wake UUID:       9FE61372-0955-49AD-AB03-A476334CB9AB

Time Awake Since Boot: 61000 seconds
Time Since Wake:       30194 seconds

System Integrity Protection: enabled

Crashed Thread:        0  main  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000028
Exception Codes:       0x0000000000000001, 0x0000000000000028

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [32745]

VM Region Info: 0x28 is not in any region.  Bytes before following region: 140737488130008
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      shared memory            7ffffffc9000-7ffffffca000 [    4K] r-x/r-x SM=SHM  

Thread 0 Crashed:: main Dispatch queue: com.apple.main-thread
0   json-hand                     	       0x10a48993b Fl_Tree_Item::find_clicked(Fl_Tree_Prefs const&, int) const + 11
1   json-hand                     	       0x10a486d24 Fl_Tree::handle(int) + 308
2   json-hand                     	       0x10a462e42 Widget_Derived<Fl_Tree>::handle(int) + 34
3   json-hand                     	       0x10a469b62 Fl_Group::handle(int) + 754
4   json-hand                     	       0x10a461252 Widget_Derived<Fl_Pack>::handle(int) + 34
5   json-hand                     	       0x10a469b62 Fl_Group::handle(int) + 754
6   json-hand                     	       0x10a461252 Widget_Derived<Fl_Pack>::handle(int) + 34
7   json-hand                     	       0x10a469b62 Fl_Group::handle(int) + 754
8   json-hand                     	       0x10a460b22 Widget_Derived<Fl_Double_Window>::handle(int) + 34
9   json-hand                     	       0x10a464733 send_event(int, Fl_Widget*, Fl_Window*) + 147
10  json-hand                     	       0x10a463e96 Fl::handle_(int, Fl_Window*) + 214
11  json-hand                     	       0x10a4b59d0 cocoaMouseHandler(NSEvent*) + 1072
12  AppKit                        	    0x7ff80a1ea891 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4580
13  AppKit                        	    0x7ff80a163572 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 404
14  AppKit                        	    0x7ff80a1631c3 -[NSWindow(NSEventRouting) sendEvent:] + 345
15  AppKit                        	    0x7ff80a8fa212 -[NSApplication(NSEventRouting) sendEvent:] + 346
16  json-hand                     	       0x10a4b280b Fl_Darwin_System_Driver::wait(double) + 587
17  json-hand                     	       0x10a4633e1 Fl::run() + 49
18  json-hand                     	       0x10a44f448 fltk::app::rt::run::h10d246a8c77088e3 + 88
19  json-hand                     	       0x10a446f04 fltk::app::App::run::he5ae025f91e828f8 + 20
20  json-hand                     	       0x10a41a132 json_hand::main::h9e6f1d69c4ee2904 + 146 (main.rs:22)
21  json-hand                     	       0x10a41fdae core::ops::function::FnOnce::call_once::h95e6b764449003e1 + 14 (function.rs:250)
22  json-hand                     	       0x10a4234e1 std::sys_common::backtrace::__rust_begin_short_backtrace::h2b67409ab47305ac + 17 (backtrace.rs:155)
23  json-hand                     	       0x10a425d74 std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h5327e065a2697704 + 20 (rt.rs:166)
24  json-hand                     	       0x10a538730 std::rt::lang_start_internal::h963c626e0d7ddd6e + 800
25  json-hand                     	       0x10a425d47 std::rt::lang_start::hbba52a207ce59bcd + 55 (rt.rs:165)
26  json-hand                     	       0x10a41a178 main + 24
27  dyld                          	    0x7ff806590386 start + 1942

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

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

Thread 3:
0   libsystem_pthread.dylib       	    0x7ff806916b88 start_wqthread + 0

Thread 4:: com.apple.NSEventThread
0   libsystem_kernel.dylib        	    0x7ff8068dba2e mach_msg2_trap + 10
1   libsystem_kernel.dylib        	    0x7ff8068e9e3a mach_msg2_internal + 84
2   libsystem_kernel.dylib        	    0x7ff8068e2b62 mach_msg_overwrite + 653
3   libsystem_kernel.dylib        	    0x7ff8068dbd1f mach_msg + 19
4   CoreFoundation                	    0x7ff8069f71b5 __CFRunLoopServiceMachPort + 143
5   CoreFoundation                	    0x7ff8069f5c25 __CFRunLoopRun + 1371
6   CoreFoundation                	    0x7ff8069f5102 CFRunLoopRunSpecific + 557
7   AppKit                        	    0x7ff80a160fac _NSEventThread + 122
8   libsystem_pthread.dylib       	    0x7ff80691b202 _pthread_start + 99
9   libsystem_pthread.dylib       	    0x7ff806916bab thread_start + 15

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

Thread 6:
0   libsystem_pthread.dylib       	    0x7ff806916b88 start_wqthread + 0

Thread 7:
0   libsystem_pthread.dylib       	    0x7ff806916b88 start_wqthread + 0

Thread 8:
0   libsystem_pthread.dylib       	    0x7ff806916b88 start_wqthread + 0

Thread 9:
0   libsystem_pthread.dylib       	    0x7ff806916b88 start_wqthread + 0

Thread 10:
0   libsystem_pthread.dylib       	    0x7ff806916b88 start_wqthread + 0

Thread 11:
0   libsystem_pthread.dylib       	    0x7ff806916b88 start_wqthread + 0

Thread 12:
0   libsystem_pthread.dylib       	    0x7ff806916b88 start_wqthread + 0

Thread 13:
0   libsystem_pthread.dylib       	    0x7ff806916b88 start_wqthread + 0


Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007fd3f33060f0  rcx: 0x00000000922f77fb  rdx: 0x0000000000000000
  rdi: 0x0000000000000000  rsi: 0x00007fd3f33061b8  rbp: 0x00007ff7b5af4420  rsp: 0x00007ff7b5af4400
   r8: 0x00000000000001ff   r9: 0x00000000924f7809  r10: 0x00000000000001ef  r11: 0x00000000000007fb
  r12: 0x0000000000000040  r13: 0x0000000000000100  r14: 0x00007fd3f33061b8  r15: 0x0000000000000001
  rip: 0x000000010a48993b  rfl: 0x0000000000010246  cr2: 0x0000000000000028
  
Logical CPU:     8
Error Code:      0x00000004 (no mapping for user data read)
Trap Number:     14

Thread 0 instruction stream:
  44 89 f1 41 89 d8 48 83-c4 08 5b 41 5c 41 5d 41  D..A..H...[A\A]A
  5e 41 5f 5d ff e0 41 83-cf 01 83 cb 01 41 39 df  ^A_]..A......A9.
  7f 1f 0f 1f 00 49 8b 7d-00 48 8b 07 44 89 f6 44  .....I.}.H..D..D
  89 fa ff 90 c0 00 00 00-41 83 c7 02 41 39 df 7e  ........A...A9.~
  e4 48 83 c4 08 5b 41 5c-41 5d 41 5e 41 5f 5d c3  .H...[A\A]A^A_].
  0f 1f 44 00 00 55 48 89-e5 41 57 41 56 41 54 53  ..D..UH..AWAVATS
 [0f]b7 47 28 a8 02 0f 84-8f 00 00 00 41 89 d6 49  ..G(........A..I	<==
  89 f7 48 89 fb 48 83 bf-90 00 00 00 00 75 07 41  ..H..H.......u.A
  80 7f 71 00 74 1c 45 85-f6 74 53 48 8d 0d bf 48  ..q.t.E..tSH...H
  11 00 8b 09 8b 53 30 39-d1 7c 07 03 53 38 39 d1  .....S09.|..S89.
  7e 5b a8 01 74 55 83 bb-80 00 00 00 00 7e 4c 45  ~[..tU.......~LE
  31 e4 0f 1f 00 48 8b 43-78 4a 8b 3c e0 4c 89 fe  1....H.CxJ.<.L..

Binary Images:
       0x11492a000 -        0x114939fff libobjc-trampolines.dylib (*) <d413ddb6-5356-3966-be97-ab6fe09421a2> /usr/lib/libobjc-trampolines.dylib
       0x10a40a000 -        0x10a585fff json-hand (*) <f4558e6a-f57f-38d9-be29-68516747c462> /Users/USER/*/json-hand
    0x7ff809fc5000 -     0x7ff80b3d1ffb com.apple.AppKit (6.9) <20292f0b-3eb2-3566-91e2-ea657457d71d> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
    0x7ff80658a000 -     0x7ff8066263bf dyld (*) <ab17bf63-259b-3b48-8d70-863166a2191c> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
    0x7ff806915000 -     0x7ff806920fff libsystem_pthread.dylib (*) <a9ba8a53-d774-3fe9-8bde-64187bff7ea9> /usr/lib/system/libsystem_pthread.dylib
    0x7ff8068da000 -     0x7ff806914ff7 libsystem_kernel.dylib (*) <9927a0a9-dfa8-3ffa-88d8-62055f37a137> /usr/lib/system/libsystem_kernel.dylib
    0x7ff80697b000 -     0x7ff806e15fec com.apple.CoreFoundation (6.9) <37924b83-2695-3956-b7ee-657a50e43c18> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

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: 17
    thread_create: 0
    thread_set_state: 100

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

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Accelerate framework               128K        1 
Activity Tracing                   256K        1 
CG image                          7576K        5 
CG raster data                    7504K        1 
ColorSync                          252K       33 
CoreAnimation                      172K       21 
CoreGraphics                        12K        2 
CoreServices                       620K        2 
CoreUI image data                 1196K        9 
Foundation                          16K        1 
Kernel Alloc Once                    8K        1 
MALLOC                           670.7M       73 
MALLOC guard page                   32K        8 
STACK GUARD                         52K       13 
Stack                             14.6M       15 
Stack Guard                       56.0M        1 
VM_ALLOCATE                        180K       12 
__CTF                               824        1 
__DATA                            18.7M      361 
__DATA_CONST                      18.5M      224 
__DATA_DIRTY                       801K      111 
__FONT_DATA                        2352        1 
__LINKEDIT                       181.9M        4 
__OBJC_RO                         71.1M        1 
__OBJC_RW                         2169K        2 
__TEXT                           303.9M      380 
dyld private memory                260K        2 
mapped file                      179.8M       26 
shared memory                     1304K       19 
===========                     =======  ======= 
TOTAL                              1.5G     1331 



-----------
Full Report
-----------

{"app_name":"json-hand","timestamp":"2024-05-07 17:42:04.00 +0800","app_version":"","slice_uuid":"f4558e6a-f57f-38d9-be29-68516747c462","build_version":"","platform":1,"share_with_app_devs":0,"is_first_party":1,"bug_type":"309","os_version":"macOS 14.2.1 (23C71)","roots_installed":0,"incident_id":"C37F8D1D-7563-41F3-A94C-DD1ED2D7C280","name":"json-hand"}
{
  "uptime" : 61000,
  "procRole" : "Foreground",
  "version" : 2,
  "userID" : 505,
  "deployVersion" : 210,
  "modelCode" : "MacBookPro15,1",
  "coalitionID" : 4796,
  "osVersion" : {
    "train" : "macOS 14.2.1",
    "build" : "23C71",
    "releaseType" : "User"
  },
  "captureTime" : "2024-05-07 17:42:03.6864 +0800",
  "codeSigningMonitor" : 0,
  "incident" : "C37F8D1D-7563-41F3-A94C-DD1ED2D7C280",
  "pid" : 32745,
  "cpuType" : "X86-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2024-05-07 17:42:00.4327 +0800",
  "procStartAbsTime" : 61891977984737,
  "procExitAbsTime" : 61895218871688,
  "procName" : "json-hand",
  "procPath" : "\/Users\/USER\/*\/json-hand",
  "parentProc" : "rustrover",
  "parentPid" : 84570,
  "coalitionName" : "com.jetbrains.rustrover-EAP",
  "crashReporterKey" : "4224A5B2-C349-6F4D-4091-6ACCFE19868C",
  "responsiblePid" : 84570,
  "responsibleProc" : "rustrover",
  "codeSigningID" : "",
  "codeSigningTeamID" : "",
  "codeSigningValidationCategory" : 0,
  "codeSigningTrustLevel" : 4294967295,
  "wakeTime" : 30194,
  "bridgeVersion" : {"build":"21P3049","train":"8.3"},
  "sleepWakeUUID" : "9FE61372-0955-49AD-AB03-A476334CB9AB",
  "sip" : "enabled",
  "vmRegionInfo" : "0x28 is not in any region.  Bytes before following region: 140737488130008\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      shared memory            7ffffffc9000-7ffffffca000 [    4K] r-x\/r-x SM=SHM  ",
  "exception" : {"codes":"0x0000000000000001, 0x0000000000000028","rawCodes":[1,40],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x0000000000000028"},
  "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":32745},
  "vmregioninfo" : "0x28 is not in any region.  Bytes before following region: 140737488130008\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      shared memory            7ffffffc9000-7ffffffca000 [    4K] r-x\/r-x SM=SHM  ",
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":100,"task_for_pid":17},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"queue":"com.apple.main-thread","instructionState":{"instructionStream":{"bytes":[68,137,241,65,137,216,72,131,196,8,91,65,92,65,93,65,94,65,95,93,255,224,65,131,207,1,131,203,1,65,57,223,127,31,15,31,0,73,139,125,0,72,139,7,68,137,246,68,137,250,255,144,192,0,0,0,65,131,199,2,65,57,223,126,228,72,131,196,8,91,65,92,65,93,65,94,65,95,93,195,15,31,68,0,0,85,72,137,229,65,87,65,86,65,84,83,15,183,71,40,168,2,15,132,143,0,0,0,65,137,214,73,137,247,72,137,251,72,131,191,144,0,0,0,0,117,7,65,128,127,113,0,116,28,69,133,246,116,83,72,141,13,191,72,17,0,139,9,139,83,48,57,209,124,7,3,83,56,57,209,126,91,168,1,116,85,131,187,128,0,0,0,0,126,76,69,49,228,15,31,0,72,139,67,120,74,139,60,224,76,137,254],"offset":96}},"frames":[{"imageOffset":522555,"symbol":"Fl_Tree_Item::find_clicked(Fl_Tree_Prefs const&, int) const","symbolLocation":11,"imageIndex":1},{"imageOffset":511268,"symbol":"Fl_Tree::handle(int)","symbolLocation":308,"imageIndex":1},{"imageOffset":364098,"symbol":"Widget_Derived<Fl_Tree>::handle(int)","symbolLocation":34,"imageIndex":1},{"imageOffset":392034,"symbol":"Fl_Group::handle(int)","symbolLocation":754,"imageIndex":1},{"imageOffset":356946,"symbol":"Widget_Derived<Fl_Pack>::handle(int)","symbolLocation":34,"imageIndex":1},{"imageOffset":392034,"symbol":"Fl_Group::handle(int)","symbolLocation":754,"imageIndex":1},{"imageOffset":356946,"symbol":"Widget_Derived<Fl_Pack>::handle(int)","symbolLocation":34,"imageIndex":1},{"imageOffset":392034,"symbol":"Fl_Group::handle(int)","symbolLocation":754,"imageIndex":1},{"imageOffset":355106,"symbol":"Widget_Derived<Fl_Double_Window>::handle(int)","symbolLocation":34,"imageIndex":1},{"imageOffset":370483,"symbol":"send_event(int, Fl_Widget*, Fl_Window*)","symbolLocation":147,"imageIndex":1},{"imageOffset":368278,"symbol":"Fl::handle_(int, Fl_Window*)","symbolLocation":214,"imageIndex":1},{"imageOffset":702928,"symbol":"cocoaMouseHandler(NSEvent*)","symbolLocation":1072,"imageIndex":1},{"imageOffset":2250897,"symbol":"-[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:]","symbolLocation":4580,"imageIndex":2},{"imageOffset":1697138,"symbol":"-[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:]","symbolLocation":404,"imageIndex":2},{"imageOffset":1696195,"symbol":"-[NSWindow(NSEventRouting) sendEvent:]","symbolLocation":345,"imageIndex":2},{"imageOffset":9654802,"symbol":"-[NSApplication(NSEventRouting) sendEvent:]","symbolLocation":346,"imageIndex":2},{"imageOffset":690187,"symbol":"Fl_Darwin_System_Driver::wait(double)","symbolLocation":587,"imageIndex":1},{"imageOffset":365537,"symbol":"Fl::run()","symbolLocation":49,"imageIndex":1},{"imageOffset":283720,"symbol":"fltk::app::rt::run::h10d246a8c77088e3","symbolLocation":88,"imageIndex":1},{"imageOffset":249604,"symbol":"fltk::app::App::run::he5ae025f91e828f8","symbolLocation":20,"imageIndex":1},{"imageOffset":65842,"sourceLine":22,"sourceFile":"main.rs","symbol":"json_hand::main::h9e6f1d69c4ee2904","imageIndex":1,"symbolLocation":146},{"imageOffset":89518,"sourceLine":250,"sourceFile":"function.rs","symbol":"core::ops::function::FnOnce::call_once::h95e6b764449003e1","imageIndex":1,"symbolLocation":14},{"imageOffset":103649,"sourceLine":155,"sourceFile":"backtrace.rs","symbol":"std::sys_common::backtrace::__rust_begin_short_backtrace::h2b67409ab47305ac","imageIndex":1,"symbolLocation":17},{"imageOffset":114036,"sourceLine":166,"sourceFile":"rt.rs","symbol":"std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h5327e065a2697704","imageIndex":1,"symbolLocation":20},{"imageOffset":1238832,"symbol":"std::rt::lang_start_internal::h963c626e0d7ddd6e","symbolLocation":800,"imageIndex":1},{"imageOffset":113991,"sourceLine":165,"sourceFile":"rt.rs","symbol":"std::rt::lang_start::hbba52a207ce59bcd","imageIndex":1,"symbolLocation":55},{"imageOffset":65912,"symbol":"main","symbolLocation":24,"imageIndex":1},{"imageOffset":25478,"symbol":"start","symbolLocation":1942,"imageIndex":3}],"id":37915197,"triggered":true,"threadState":{"r13":{"value":256},"rax":{"value":0},"rflags":{"value":66118},"cpu":{"value":8},"r14":{"value":140548294861240},"rsi":{"value":140548294861240},"r8":{"value":511},"cr2":{"value":40},"rdx":{"value":0},"r10":{"value":495},"r9":{"value":2454681609},"r15":{"value":1},"rbx":{"value":140548294861040},"trap":{"value":14,"description":"(no mapping for user data read)"},"err":{"value":4},"r11":{"value":2043},"rip":{"value":4467497275,"matchesCrashFrame":1},"rbp":{"value":140701881812000},"rsp":{"value":140701881811968},"r12":{"value":64},"rcx":{"value":2452584443},"flavor":"x86_THREAD_STATE","rdi":{"value":0}},"name":"main"},{"id":37915277,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":1},"rsi":{"value":4611},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145357316096},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":123145357839224},"rbx":{"value":123145357840384},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145357840384},"r12":{"value":5193733},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145357840384}}},{"id":37915279,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":5379},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145357852672},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145358376960},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145358376960},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145358376960}}},{"id":37915303,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":20995},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145358389248},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145358913536},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145358913536},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145358913536}}},{"id":37915414,"name":"com.apple.NSEventThread","threadState":{"r13":{"value":21592279046},"rax":{"value":268451845},"rflags":{"value":518},"cpu":{"value":0},"r14":{"value":2},"rsi":{"value":21592279046},"r8":{"value":0},"cr2":{"value":0},"rdx":{"value":8589934592},"r10":{"value":178133768601600},"r9":{"value":178133768601600},"r15":{"value":178133768601600},"rbx":{"value":123145359982688},"trap":{"value":133},"err":{"value":16777263},"r11":{"value":518},"rip":{"value":140703238568494},"rbp":{"value":123145359982528},"rsp":{"value":123145359982424},"r12":{"value":4294967295},"rcx":{"value":123145359982424},"flavor":"x86_THREAD_STATE","rdi":{"value":123145359982688}},"frames":[{"imageOffset":6702,"symbol":"mach_msg2_trap","symbolLocation":10,"imageIndex":6},{"imageOffset":65082,"symbol":"mach_msg2_internal","symbolLocation":84,"imageIndex":6},{"imageOffset":35682,"symbol":"mach_msg_overwrite","symbolLocation":653,"imageIndex":6},{"imageOffset":7455,"symbol":"mach_msg","symbolLocation":19,"imageIndex":6},{"imageOffset":508341,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":143,"imageIndex":7},{"imageOffset":502821,"symbol":"__CFRunLoopRun","symbolLocation":1371,"imageIndex":7},{"imageOffset":499970,"symbol":"CFRunLoopRunSpecific","symbolLocation":557,"imageIndex":7},{"imageOffset":1687468,"symbol":"_NSEventThread","symbolLocation":122,"imageIndex":2},{"imageOffset":25090,"symbol":"_pthread_start","symbolLocation":99,"imageIndex":5},{"imageOffset":7083,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":37915431,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":45315},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145359998976},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145360523264},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145360523264},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145360523264}}},{"id":37915432,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":63491},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145360535552},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145361059840},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145361059840},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145361059840}}},{"id":37915433,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":63235},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145361072128},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145361596416},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145361596416},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145361596416}}},{"id":37915434,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":45571},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145361608704},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145362132992},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145362132992},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145362132992}}},{"id":37915435,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":62979},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145362145280},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145362669568},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145362669568},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145362669568}}},{"id":37915436,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":62723},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145362681856},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145363206144},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145363206144},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145363206144}}},{"id":37915437,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":62467},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145363218432},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145363742720},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145363742720},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145363742720}}},{"id":37915438,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":45827},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145363755008},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145364279296},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145364279296},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145364279296}}},{"id":37916863,"frames":[{"imageOffset":7048,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"r13":{"value":0},"rax":{"value":33554800},"rflags":{"value":512},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":127799},"r8":{"value":409604},"cr2":{"value":0},"rdx":{"value":123145358925824},"r10":{"value":0},"r9":{"value":18446744073709551615},"r15":{"value":0},"rbx":{"value":123145359450112},"trap":{"value":133},"err":{"value":33554800},"r11":{"value":582},"rip":{"value":140703238810504},"rbp":{"value":0},"rsp":{"value":123145359450112},"r12":{"value":0},"rcx":{"value":0},"flavor":"x86_THREAD_STATE","rdi":{"value":123145359450112}}}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "x86_64h",
    "base" : 4640120832,
    "size" : 65536,
    "uuid" : "d413ddb6-5356-3966-be97-ab6fe09421a2",
    "path" : "\/usr\/lib\/libobjc-trampolines.dylib",
    "name" : "libobjc-trampolines.dylib"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 4466974720,
    "size" : 1556480,
    "uuid" : "f4558e6a-f57f-38d9-be29-68516747c462",
    "path" : "\/Users\/USER\/*\/json-hand",
    "name" : "json-hand"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 140703296147456,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.AppKit",
    "size" : 21024764,
    "uuid" : "20292f0b-3eb2-3566-91e2-ea657457d71d",
    "path" : "\/System\/Library\/Frameworks\/AppKit.framework\/Versions\/C\/AppKit",
    "name" : "AppKit",
    "CFBundleVersion" : "2487.30.108"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 140703235088384,
    "size" : 639936,
    "uuid" : "ab17bf63-259b-3b48-8d70-863166a2191c",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 140703238803456,
    "size" : 49152,
    "uuid" : "a9ba8a53-d774-3fe9-8bde-64187bff7ea9",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 140703238561792,
    "size" : 241656,
    "uuid" : "9927a0a9-dfa8-3ffa-88d8-62055f37a137",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "x86_64h",
    "base" : 140703239221248,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.CoreFoundation",
    "size" : 4829165,
    "uuid" : "37924b83-2695-3956-b7ee-657a50e43c18",
    "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation",
    "name" : "CoreFoundation",
    "CFBundleVersion" : "2202"
  }
],
  "sharedCache" : {
  "base" : 140703234392064,
  "size" : 25769803776,
  "uuid" : "2a323ece-7dbf-33e2-9ef3-3390c59ddc35"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=485.7M resident=0K(0%) swapped_out_or_unallocated=485.7M(100%)\nWritable regions: Total=694.2M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=694.2M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nAccelerate framework               128K        1 \nActivity Tracing                   256K        1 \nCG image                          7576K        5 \nCG raster data                    7504K        1 \nColorSync                          252K       33 \nCoreAnimation                      172K       21 \nCoreGraphics                        12K        2 \nCoreServices                       620K        2 \nCoreUI image data                 1196K        9 \nFoundation                          16K        1 \nKernel Alloc Once                    8K        1 \nMALLOC                           670.7M       73 \nMALLOC guard page                   32K        8 \nSTACK GUARD                         52K       13 \nStack                             14.6M       15 \nStack Guard                       56.0M        1 \nVM_ALLOCATE                        180K       12 \n__CTF                               824        1 \n__DATA                            18.7M      361 \n__DATA_CONST                      18.5M      224 \n__DATA_DIRTY                       801K      111 \n__FONT_DATA                        2352        1 \n__LINKEDIT                       181.9M        4 \n__OBJC_RO                         71.1M        1 \n__OBJC_RW                         2169K        2 \n__TEXT                           303.9M      380 \ndyld private memory                260K        2 \nmapped file                      179.8M       26 \nshared memory                     1304K       19 \n===========                     =======  ======= \nTOTAL                              1.5G     1331 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "name" : "main",
    "queue" : "com.apple.main-thread"
  }
},
  "logWritingSignature" : "c7be63ca4f860cd88b1446b6831f58604a0730a0",
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "61675b89201f677a9a4cbd65",
      "factorPackIds" : {
        "HEALTH_FEATURE_AVAILABILITY" : "65a855f5f087695cfac03d1f"
      },
      "deploymentId" : 240000116
    },
    {
      "rolloutId" : "632c763c58740028737bfdd2",
      "factorPackIds" : {
        "SIRI_DIALOG_ASSETS" : "64a57d23fa6fd41b2353e2ae"
      },
      "deploymentId" : 240000034
    }
  ],
  "experiments" : [
    {
      "treatmentId" : "5d85d104-adc7-4ebf-8b7c-96d84fdad9cc",
      "experimentId" : "6384d56b96e8d228551ec182",
      "deploymentId" : 400000032
    }
  ]
}
}

Model: MacBookPro15,1, BootROM 2020.80.5.0.1 (iBridge: 21.16.3049.0.0,0), 6 processors, 6-Core Intel Core i7, 2.2 GHz, 16 GB, SMC 
Graphics: Intel UHD Graphics 630, Intel UHD Graphics 630, Built-In
Display: Color LCD, 2880 x 1800 Retina, Main, MirrorOff, Online
Graphics: Radeon Pro 555X, Radeon Pro 555X, PCIe, 4 GB
Memory Module: BANK 0/ChannelA-DIMM0, 8 GB, DDR4, 2400 MHz, SK Hynix, HMA81GS6AFR8N-UH
Memory Module: BANK 2/ChannelB-DIMM0, 8 GB, DDR4, 2400 MHz, SK Hynix, HMA81GS6AFR8N-UH
AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x7BF), wl0: Jul 10 2023 12:30:19 version 9.30.503.0.32.5.92 FWID 01-88a8883
AirPort: 
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB31Bus
USB Device: T2Bus
USB Device: Touch Bar Backlight
USB Device: Touch Bar Display
USB Device: Apple Internal Keyboard / Trackpad
USB Device: Headset
USB Device: Ambient Light Sensor
USB Device: FaceTime HD Camera (Built-in)
USB Device: Apple T2 Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 47.5
Thunderbolt Bus: MacBook Pro, Apple Inc., 47.5

@MoAlyousef
Copy link
Collaborator

Thank you for the detailed report.
I'll try to analyze this tonight.

@MoAlyousef
Copy link
Collaborator

MoAlyousef commented May 7, 2024

I tried the following program on linux:

use fltk::prelude::*;
use fltk::*;

fn main() {
    let app = app::App::default();
    let mut w = window::Window::default().with_size(400, 300);
    let mut tree = tree::Tree::default().with_size(400, 300);
    tree.set_root_label(".");
    tree.set_select_mode(tree::TreeSelect::Multi);
    // tree.set_color(Color::Blue);
    for i in 0 .. 5 {
        let ti = tree::TreeItem::new(&tree, &*("item".to_owned() + &*i.to_string()));
        tree.add_item("2/2/3/1", &ti);
    }

   for i in 0 .. 5 {
       tree.add(&*("item".to_owned() + &*i.to_string()));
   }

    tree.set_callback(|t| {
        if let Some(items) = t.get_selected_items() {
            for i in items {
                println!("{} selected", t.item_pathname(&i).unwrap());
            }
        }
    });
    w.end();
    w.show();

    app.run().unwrap();
}

It doesn't cause a crash and also ran it under valgrind with no memory errors. Can you check on your system?
If it crashes on macos, then it could be platform specific.
If it doesn't crash, then I would appreciate a minimal repro.

@davelet
Copy link
Author

davelet commented May 8, 2024

@MoAlyousef Thank you but sorry of my misleading message. Yes and your code works well. So I tried many times to comment / uncomment some code blocks in my project back and forth and eventually I found out the code causing crash. Badly I can't figure it out why the code is incorrect. So I uploaded it to a repo and create a pr. Please help me to solve it.

you can see that it's clear() method doing the odd thing. But why?

@MoAlyousef
Copy link
Collaborator

Thank you for sharing the code. I was able to minimize it to the following:

use fltk::prelude::*;
use fltk::*;
use fltk::enums::*;

fn main() {
    let app = app::App::default();
    let mut w = window::Window::default().with_size(400, 300);
    let mut i = input::Input::new(0, 0, 400, 40, None);
    let mut tree = tree::Tree::new(0, 40, 400, 260, None);
    tree.set_root_label(".");
    tree.set_select_mode(tree::TreeSelect::Multi);
    for i in 0 .. 5 {
        let ti = tree::TreeItem::new(&tree, &*("item".to_owned() + &*i.to_string()));
        tree.add_item("2/2/3/1", &ti);
    }
    w.end();
    w.show();

    i.handle(move |i, ev| match ev {
        Event::Unfocus => {
            tree.clear();
            true       
        } 
        _ => false,
    });

    app.run().unwrap();
}

I believe it's an issue with FLTK's focus. I'll try to reproduce in C++ then I'll report it there.
I think the issue arises from the Fl_Tree handler, it checks whether the root item is null or not, however in the Fl_Push event, it refocuses the Fl_Tree, which bypasses the check.

@MoAlyousef
Copy link
Collaborator

MoAlyousef commented May 8, 2024

I've reported this and a fix was applied. If you can try the master branch by adding to your Cargo.toml:

[patch.crates-io]
fltk = { git = "https://github.com/fltk-rs/fltk-rs" }

Note, the issue upstream is still open for input by other core FLTK devs.

@davelet
Copy link
Author

davelet commented May 8, 2024

Yes man, it works as expected. good job doc! I'll close this issue.

@davelet davelet closed this as completed May 8, 2024
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