simonhaenisch / md-to-pdf

Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
https://www.npmjs.com/md-to-pdf
MIT License
1.19k stars 110 forks source link

bug: Chromium crashes on mac os #86

Closed EnilPajic closed 3 years ago

EnilPajic commented 3 years ago

Context:

Describe the bug:

Using simple md-to-pdf readme.md command, chromium crashes. Tried with --debug (as suggested in this comment on #54), but it seems that --debug is not supported.

Tried --launch-options '{ "args": ["--no-sandbox"] }' (from #20) and --launch-options="['--no-sandbox', '--disable-setuid-sandbox']" (from #54), but to no avail.

Bellow you can find my command line history with commands and their outputs. Also, you can find screenshot of it too.

➜  ls
readme.md
➜  pwd
/tmp/md
➜  md-to-pdf -v
3.3.1
➜  node -v
v14.0.0
➜  md-to-pdf readme.md 
  ✖ generating PDF from readme.md
    → TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
ListrError: Something went wrong
    at /usr/local/lib/node_modules/md-to-pdf/node_modules/listr/index.js:102:18
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async main (/usr/local/lib/node_modules/md-to-pdf/dist/cli.js:116:5) {
  errors: [
    Error: Failed to launch the browser process!

    TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

        at onClose (/usr/local/lib/node_modules/md-to-pdf/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
        at Interface.<anonymous> (/usr/local/lib/node_modules/md-to-pdf/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)
        at Interface.emit (events.js:327:22)
        at Interface.close (readline.js:424:8)
        at Socket.onend (readline.js:202:10)
        at Socket.emit (events.js:327:22)
        at endReadableNT (_stream_readable.js:1218:12)
        at processTicksAndRejections (internal/process/task_queues.js:84:21)
  ],
  context: [Object: null prototype] {}
}
➜  system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 11.1 (20C69)
      Kernel Version: Darwin 20.2.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: Enil’s MacBook Pro 16
      User Name: Enil (enil)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 8 days 20:18
image

And, if I click on 'report...' button in 'Chromium quit unexpectedly', this is how my report looks like (maybe you can find some useful info here):

Process:               Chromium [70913]
Path:                  /usr/local/lib/node_modules/md-to-pdf/node_modules/puppeteer/.local-chromium/mac-856583/chrome-mac/Chromium.app/Contents/MacOS/Chromium
Identifier:            Chromium
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        node [70909]
Responsible:           Terminal [452]
User ID:               501

Date/Time:             2021-03-04 12:39:19.933 +0100
OS Version:            macOS 11.1 (20C69)
Report Version:        12
Bridge OS Version:     5.1 (18P3030)
Anonymous UUID:        E755C7V3-B1C9-48C5-886C-77478A3EBAC9

Sleep/Wake UUID:       73BD2083-7461-46DD-8C26-F3C157AA26322

Time Awake Since Boot: 290000 seconds
Time Since Wake:       10000 seconds

System Integrity Protection: enabled

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

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
dlopen /usr/local/lib/node_modules/md-to-pdf/node_modules/puppeteer/.local-chromium/mac-856583/chrome-mac/Chromium.app/Contents/MacOS/../Frameworks/Chromium Framework.framework/Versions/90.0.4427.0/Chromium Framework: dlopen(/usr/local/lib/node_modules/md-to-pdf/node_modules/puppeteer/.local-chromium/mac-856583/chrome-mac/Chromium.app/Contents/MacOS/../Frameworks/Chromium Framework.framework/Versions/90.0.4427.0/Chromium Framework, 261): image not found.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff202f4462 __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff20322610 pthread_kill + 263
2   libsystem_c.dylib               0x00007fff20275720 abort + 120
3   libsystem_c.dylib               0x00007fff2027588b abort_report_np + 177
4   Chromium                        0x00000001050190c3 0x105016000 + 12483
5   Chromium                        0x0000000105018fad main + 237
6   libdyld.dylib                   0x00007fff2033d621 start + 1

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x000000010d251e00  rcx: 0x00007ffeeabe78b8  rdx: 0x0000000000000000
  rdi: 0x0000000000000307  rsi: 0x0000000000000006  rbp: 0x00007ffeeabe78e0  rsp: 0x00007ffeeabe78b8
   r8: 0x00007ffeeabe7850   r9: 0x00007ffeeabe8ad0  r10: 0x000000010d251e00  r11: 0x0000000000000246
  r12: 0x0000000000000307  r13: 0x00007fa33c504110  r14: 0x0000000000000006  r15: 0x0000000000000016
  rip: 0x00007fff202f4462  rfl: 0x0000000000000246  cr2: 0x00007fff889a4498

Logical CPU:     0
Error Code:      0x02000148
Trap Number:     133

Thread 0 instruction stream not available.

Thread 0 last branch register state not available.

Binary Images:
       0x105016000 -        0x105041fff +Chromium (0) <AE905F22-1757-328E-BC52-1F01E5C0702E> /usr/local/lib/node_modules/md-to-pdf/node_modules/puppeteer/.local-chromium/mac-856583/chrome-mac/Chromium.app/Contents/MacOS/Chromium
       0x10d17a000 -        0x10d215fff  dyld (832.7.1) <DEA51514-B4E8-3368-979B-89D0F8397ABC> /usr/lib/dyld
    0x7fff20058000 -     0x7fff20059fff  libsystem_blocks.dylib (78) <9CF131C6-16FB-3DD0-B046-9E0B6AB99935> /usr/lib/system/libsystem_blocks.dylib
    0x7fff2005a000 -     0x7fff2008ffff  libxpc.dylib (2038.40.38) <003A027D-9CE3-3794-A319-88495844662D> /usr/lib/system/libxpc.dylib
    0x7fff20090000 -     0x7fff200a7fff  libsystem_trace.dylib (1277.50.1) <48C14376-626E-3C81-B0F5-7416E64580C7> /usr/lib/system/libsystem_trace.dylib
    0x7fff200a8000 -     0x7fff20146fff  libcorecrypto.dylib (1000.60.19) <92F0211E-506E-3760-A3C2-808BF3905C07> /usr/lib/system/libcorecrypto.dylib
    0x7fff20147000 -     0x7fff20173fff  libsystem_malloc.dylib (317.40.8) <2EF43B96-90FB-3C50-B73E-035238504E33> /usr/lib/system/libsystem_malloc.dylib
    0x7fff20174000 -     0x7fff201b8fff  libdispatch.dylib (1271.40.12) <CEF1460B-1362-381A-AE69-6BCE2D8C215B> /usr/lib/system/libdispatch.dylib
    0x7fff201b9000 -     0x7fff201f1fff  libobjc.A.dylib (818.2) <45EA2DE2-B612-3486-B156-2359CE279159> /usr/lib/libobjc.A.dylib
    0x7fff201f2000 -     0x7fff201f4fff  libsystem_featureflags.dylib (28.60.1) <7B4EBDDB-244E-3F78-8895-566FE22288F3> /usr/lib/system/libsystem_featureflags.dylib
    0x7fff201f5000 -     0x7fff2027dfff  libsystem_c.dylib (1439.40.11) <06D9F593-C815-385D-957F-2B5BCC223A8A> /usr/lib/system/libsystem_c.dylib
    0x7fff2027e000 -     0x7fff202d3fff  libc++.1.dylib (904.4) <AE3A940A-7A9C-3F99-B175-3511528D8DFE> /usr/lib/libc++.1.dylib
    0x7fff202d4000 -     0x7fff202ecfff  libc++abi.dylib (904.4) <DDFCBF9C-432D-3B8A-8641-578D2EDDCAD8> /usr/lib/libc++abi.dylib
    0x7fff202ed000 -     0x7fff2031bfff  libsystem_kernel.dylib (7195.60.75) <4BD61365-29AF-3234-8002-D989D295FDBB> /usr/lib/system/libsystem_kernel.dylib
    0x7fff2031c000 -     0x7fff20327fff  libsystem_pthread.dylib (454.60.1) <8DD3A0BC-2C92-31E3-BBAB-CE923A4342E4> /usr/lib/system/libsystem_pthread.dylib
    0x7fff20328000 -     0x7fff20362fff  libdyld.dylib (832.7.1) <2F8A14F5-7CB8-3EDD-85EA-7FA960BBC04E> /usr/lib/system/libdyld.dylib
    0x7fff20363000 -     0x7fff2036cfff  libsystem_platform.dylib (254.60.1) <3F7F6461-7B5C-3197-ACD7-C8A0CFCC6F55> /usr/lib/system/libsystem_platform.dylib
    0x7fff2036d000 -     0x7fff20398fff  libsystem_info.dylib (542.40.3) <0979757C-5F0D-3F5A-9E0E-EBF234B310AF> /usr/lib/system/libsystem_info.dylib
    0x7fff22785000 -     0x7fff2278efff  libsystem_darwin.dylib (1439.40.11) <BD269412-C9D0-32EE-B42B-B09A187A9B95> /usr/lib/system/libsystem_darwin.dylib
    0x7fff22b9f000 -     0x7fff22baafff  libsystem_notify.dylib (279.40.4) <98D74EEF-60D9-3665-B877-7BE1558BA83E> /usr/lib/system/libsystem_notify.dylib
    0x7fff24afa000 -     0x7fff24b08fff  libsystem_networkextension.dylib (1295.60.5) <F476B1CB-3561-30C5-A78E-44E99B1720A3> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff24b66000 -     0x7fff24b7cfff  libsystem_asl.dylib (385) <940C5BB9-4928-3A63-97F2-132797C8B7E5> /usr/lib/system/libsystem_asl.dylib
    0x7fff26264000 -     0x7fff2626bfff  libsystem_symptoms.dylib (1431.60.1) <88F35AAC-746F-3176-81DF-49CE3D285636> /usr/lib/system/libsystem_symptoms.dylib
    0x7fff282b6000 -     0x7fff282c6fff  libsystem_containermanager.dylib (318.60.1) <4ED09A19-04CC-3464-9EFB-F674932020B5> /usr/lib/system/libsystem_containermanager.dylib
    0x7fff28fc2000 -     0x7fff28fc5fff  libsystem_configuration.dylib (1109.60.2) <C57B346B-0A03-3F87-BCAC-87B702FA0719> /usr/lib/system/libsystem_configuration.dylib
    0x7fff28fc6000 -     0x7fff28fcafff  libsystem_sandbox.dylib (1441.60.4) <8CE27199-D633-31D2-AB08-56380A1DA9FB> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff29ccd000 -     0x7fff29ccffff  libquarantine.dylib (119.40.2) <19D42B9D-3336-3543-AF75-6E605EA31599> /usr/lib/system/libquarantine.dylib
    0x7fff2a24e000 -     0x7fff2a252fff  libsystem_coreservices.dylib (127) <A2D875B9-8BA8-33AD-BE92-ADAB915A8D5B> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff2a469000 -     0x7fff2a4b0fff  libsystem_m.dylib (3186.40.2) <79820D9E-0FF1-3F20-AF4F-F87EE20CE8C9> /usr/lib/system/libsystem_m.dylib
    0x7fff2a4b2000 -     0x7fff2a4b7fff  libmacho.dylib (973.4) <28AE1649-22ED-3C4D-A232-29D37F821C39> /usr/lib/system/libmacho.dylib
    0x7fff2a4d4000 -     0x7fff2a4dffff  libcommonCrypto.dylib (60178.40.2) <1D0A75A5-DEC5-39C6-AB3D-E789B8866712> /usr/lib/system/libcommonCrypto.dylib
    0x7fff2a4e0000 -     0x7fff2a4eafff  libunwind.dylib (200.10) <C5792A9C-DF0F-3821-BC14-238A78462E8A> /usr/lib/system/libunwind.dylib
    0x7fff2a4eb000 -     0x7fff2a4f2fff  liboah.dylib (203.13.2) <FF72E19B-3B02-34D4-A821-3397BB28AC02> /usr/lib/liboah.dylib
    0x7fff2a4f3000 -     0x7fff2a4fdfff  libcopyfile.dylib (173.40.2) <89483CD4-DA46-3AF2-AE78-FC37CED05ACC> /usr/lib/system/libcopyfile.dylib
    0x7fff2a4fe000 -     0x7fff2a505fff  libcompiler_rt.dylib (102.2) <0DB26EC8-B4CD-3268-B865-C2FC07E4D2AA> /usr/lib/system/libcompiler_rt.dylib
    0x7fff2a506000 -     0x7fff2a508fff  libsystem_collections.dylib (1439.40.11) <D40D8097-0ABF-3645-B065-168F43ACFF4C> /usr/lib/system/libsystem_collections.dylib
    0x7fff2a509000 -     0x7fff2a50bfff  libsystem_secinit.dylib (87.60.1) <99B5FD99-1A8B-37C1-BD70-04990FA33B1C> /usr/lib/system/libsystem_secinit.dylib
    0x7fff2a50c000 -     0x7fff2a50efff  libremovefile.dylib (49.40.3) <750012C2-7097-33C3-B796-2766E6CDE8C1> /usr/lib/system/libremovefile.dylib
    0x7fff2a50f000 -     0x7fff2a50ffff  libkeymgr.dylib (31) <2C7B58B0-BE54-3A50-B399-AA49C19083A9> /usr/lib/system/libkeymgr.dylib
    0x7fff2a510000 -     0x7fff2a517fff  libsystem_dnssd.dylib (1310.60.4) <81EFC44D-450E-3AA3-AC8F-D7EF68F464B4> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff2a518000 -     0x7fff2a51dfff  libcache.dylib (83) <2F7F7303-DB23-359E-85CD-8B2F93223E2A> /usr/lib/system/libcache.dylib
    0x7fff2a51e000 -     0x7fff2a51ffff  libSystem.B.dylib (1292.60.1) <A7FB4899-9E04-37ED-9DD8-8FFF0400879C> /usr/lib/libSystem.B.dylib
    0x7fff2d951000 -     0x7fff2d951fff  liblaunch.dylib (2038.40.38) <05A7EFDD-4111-3E4D-B668-239B69DE3D0F> /usr/lib/system/liblaunch.dylib
    0x7fff2fdfe000 -     0x7fff2fdfefff  libsystem_product_info_filter.dylib (8.40.1) <7CCAF1A8-F570-341E-B275-0C80B092F8E0> /usr/lib/system/libsystem_product_info_filter.dylib

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

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

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                    8K        1 
MALLOC                            19.1M       10 
MALLOC guard page                   16K        4 
STACK GUARD                       56.0M        1 
Stack                             8192K        1 
VM_ALLOCATE                         12K        3 
__DATA                             405K       43 
__DATA_CONST                       242K       33 
__DATA_DIRTY                        58K       21 
__LINKEDIT                       489.3M        4 
__OBJC_RO                         60.5M        1 
__OBJC_RW                         2452K        2 
__TEXT                            5164K       44 
shared memory                        4K        1 
===========                     =======  ======= 
TOTAL                            641.1M      169 

Model: MacBookPro16,1, BootROM 1554.60.15.0.0 (iBridge: 18.16.13030.0.0,0), 6 processors, 6-Core Intel Core i7, 2,6 GHz, 16 GB, SMC 
Graphics: kHW_IntelUHDGraphics630Item, Intel UHD Graphics 630, spdisplays_builtin
Graphics: kHW_AMDRadeonPro5300MItem, AMD Radeon Pro 5300M, spdisplays_pcie_device, 4 GB
Memory Module: BANK 0/ChannelA-DIMM0, 8 GB, DDR4, 2667 MHz, SK Hynix, -
Memory Module: BANK 2/ChannelB-DIMM0, 8 GB, DDR4, 2667 MHz, SK Hynix, -
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x7BF), wl0: Sep 11 2020 17:01:15 version 9.30.440.2.32.5.61 FWID 01-1d69e4b4
Bluetooth: Version 8.0.2f9, 3 services, 18 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB 3.1 Bus
USB Device: Apple T2 Bus
USB Device: Composite Device
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., 63.1
Thunderbolt Bus: MacBook Pro, Apple Inc., 63.1
simonhaenisch commented 3 years ago

Tried with --debug

This flag has been removed because all the info that was logged by it is output by default now in case of an error.

Looking at the chromium executable path, it looks like you're using the latest Puppeteer 8.0 (Chromium version r856583). I've tried upgrading as well and it still works for me (on macOS 11.2 here). So I'm not really sure where the problem is for you but I suggest you search for "puppeteer chromium quit unexpectedly" and maybe there's some related upstream issue. If you find something, please reference it here. I've done a quick search and couldn't find anything, and it isn't reproducible for me either, so I can't really do anything here.

Also, have you checked the troubleshooting link? https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

simonhaenisch commented 3 years ago

Closing this for now as there has been no reply.

EnilPajic commented 3 years ago

Sorry @simonhaenisch. I didn't feel that there is something to reply. Yes, I searched "pupeteer chromium quit unexpectedly", even before posting question here. Yes, I read the docs on link, even before posting here (that link was in errors before crash).

I checked, for me, it still crashes, and I'm now on 11.3.1.

I'm sorry I didn't reply. If I can provide some help regarding this, I'll gladly help.

Best regards.

simonhaenisch commented 3 years ago

Thanks for the update. If you have another Mac available, maybe you can try to see if it's reproducible there as well, or you could try creating a new user account on your Mac (the user's Library folder holds all the support files for Chromium, so creating a new user would have a clean slate here). If that solves it, you can try to delete all the support files from Chromium (see list of folders here, or use something like App Cleaner). BTW you have tried deleting node_modules and reinstalling, right?

TBH I'm still considering closing this because it does not seem related to md-to-pdf at all, just a problem with Chromium on your computer. But I'll wait to see if you can solve it with one of these ideas first and if not, maybe this can be debugged further (I'm not sure how though if it's not reproducible).

EnilPajic commented 3 years ago

Thank you for reopening. I'll try on another Mac (Catalina) next week and also try to clean the folders you mentioned. I'll let you know of the results.

As for closing the issue, you are probably right. But, we can give it another shot, maybe there is something that can be done.

EnilPajic commented 3 years ago

Hello. Tried on another Mac (Catalina), it is working ok.

On my Mac: again, removed /usr/local/lib/node_modules (md-to-pdf was globally installed), without success. Removed all Chromium related stuff from Library and from brew and it finally worked.

So, maybe something got mixed, or some faulty files were generated on my first install.

Thank you very much for your time.