mistricky / codesnap.nvim

📸 Snapshot plugin with rich features that can make pretty code snapshots for Neovim
MIT License
473 stars 15 forks source link

Neovim crashes with EXC_BAD_ACCESS (SIGBUS) when copying image to clipboard #106

Closed try-to-fly closed 2 weeks ago

try-to-fly commented 2 weeks ago

Neovim crashes when attempting to copy an image to the clipboard. The crash report indicates an EXC_BAD_ACCESS (SIGBUS) error during the image processing.

Environment:

Crash Report:

Process:               nvim [69962]
Path:                  /opt/homebrew/*/nvim
Identifier:            nvim
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        Exited process [69961]
Responsible:           kitty [474]
User ID:               501

Date/Time:             2024-05-20 13:49:16.3895 +0800
OS Version:            macOS 14.4.1 (23E224)
Report Version:        12
Anonymous UUID:        F1BF2BD6-1FC7-2E39-2145-56C2098E5FC9

Sleep/Wake UUID:       056FE953-0A56-4A0E-947F-86AFF09C9338

Time Awake Since Boot: 18000 seconds
Time Since Wake:       855 seconds

System Integrity Protection: disabled

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

Exception Type:        EXC_BAD_ACCESS (SIGBUS)
Exception Codes:       UNKNOWN_0x101 at 0x000000000bad4007
Exception Codes:       0x0000000000000101, 0x000000000bad4007

Termination Reason:    Namespace SIGNAL, Code 10 Bus error: 10
Terminating Process:   exc handler [69962]

VM Region Info: 0xbad4007 is not in any region.  Bytes before following region: 4182245369
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      104f54000-10525c000    [ 3104K] r-x/r-x SM=COW  /opt/homebrew/*/nvim

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   ???                                      0xbad4007 ???
1   libdispatch.dylib                      0x19f7123e8 _dispatch_client_callout + 20
2   libdispatch.dylib                      0x19f713c68 _dispatch_once_callout + 32
3   ImageIO                                0x1aa429cdc TIFFWritePlugin::writeAll() + 80
4   ImageIO                                0x1aa429c44 IIO_Writer_TIFF::write(void*, void*) + 48
5   ImageIO                                0x1aa519df0 IIOImageDestination::finalizeDestination() + 896
6   ImageIO                                0x1aa429a4c CGImageDestinationFinalize + 180
7   AppKit                                 0x1a33fd738 +[NSBitmapImageRep(NSBitmapImageFileTypeExtensions) representationOfImageRepsInArray:usingType:properties:] + 1832
8   AppKit                                 0x1a33fc498 -[NSImage TIFFRepresentationUsingCompression:factor:] + 216
9   AppKit                                 0x1a34819bc -[NSPasteboard writeObjects:] + 712
10  generator.so                           0x10b74f968 arboard::platform::osx::Set::image::hb5065722d5ed8601 + 800
11  generator.so                           0x10b6eaad8 generator::copy::copy_into_clipboard::h763c2f0f6bc4a544 + 284
12  generator.so                           0x10b6f75cc oxi_luajit::function::store::_$u7b$$u7b$closure$u7d$$u7b$$u7b$closure$u7d$$u7d$::hfade5170fc7f2ec4 + 292
13  generator.so                           0x10b752730 oxi_luajit::function::store::c_fun::h932a2ea8af637371 + 52
14  libluajit-5.1.2.1.1713773202.dylib         0x105955a7c 0x105950000 + 23164
15  libluajit-5.1.2.1.1713773202.dylib         0x10596265c lua_pcall + 148
16  nvim                                   0x105099b0c nlua_do_ucmd + 1412
17  nvim                                   0x1051b8b54 do_ucmd + 276
18  nvim                                   0x10502ca30 execute_cmd0 + 140
19  nvim                                   0x105029670 do_cmdline + 8580
20  nvim                                   0x1050e6dc0 nv_colon + 420
21  nvim                                   0x1050e49f8 normal_execute + 4872
22  nvim                                   0x10517e7cc state_enter + 392
23  nvim                                   0x1050a47a4 main + 9492
24  dyld                                   0x19f53a0e0 start + 2360

Steps to Reproduce:

  1. Run CodeSnap to copy an image to the clipboard.
  2. Observe the crash.
mistricky commented 2 weeks ago

I can't reproduce it, CodeSnap works fine with Neovim 0.10 on my Mac, have you tried reinstall CodeSnap and try again?

try-to-fly commented 2 weeks ago

After debugging, I discovered that this line of code was causing the crash. Commenting out this code prevents the crash. However, when I attempted to update the board to the latest version(v3.4.0), it also crashed. I'm not sure where the problem lies.

CleanShot 2024-05-30 at 09 16 23@2x

try-to-fly commented 2 weeks ago

Summary

While testing the board module, I encountered errors when executing the demo. After analysis, I found that the issue was caused by the DYLD_LIBRARY_PATH environment variable. Removing this variable resolved the issue.

Detailed Description

Based on the above analysis, I attempted to test the board module and found that executing the demo also resulted in errors. I found a similar issue mentioned in the issues section: https://github.com/1Password/arboard/issues/109

The issue mentioned DYLD_LIBRARY_PATH as a potential cause. I had added this dependency when installing a certain functionality but forgot about it. After removing this environment variable, everything worked fine.

I will continue to investigate why DYLD_LIBRARY_PATH causes the crash.

export DYLD_LIBRARY_PATH="/opt/homebrew/lib/"