cyclone icon indicating copy to clipboard operation
cyclone copied to clipboard

Complete Freeze on MacOS / M1

Open c0nn3r opened this issue 3 years ago • 12 comments

When I run icyc on MacOS, the REPL seems to "hang" and not execute anything.

okefenokee:~ conner$ rlwrap icyc

              :@
            @@@
          @@@@:
        `@@@@@+
       .@@@+@@@
       @@     @@     Cyclone Scheme->C compiler
      ,@             http://justinethier.github.io/cyclone/
      '@
      .@             (c) 2014-2021 Justin Ethier
       @@     #@     Version 0.30.0
       `@@@#@@@.
        #@@@@@
        +@@@+
        @@#
      `@.

cyclone> (write 'hello-world)

The cyclone command has the same behavior when trying to compile a file. It completely pins the CPU when either using the REPL or the cyclone command. I am using a M1 chip, which I think might have something to do with it.

c0nn3r avatar Jul 04 '21 07:07 c0nn3r

Here is the process sample:

Sampling completed, processing symbols...
Analysis of sampling cyclone (pid 27341) every 1 millisecond
Process:         cyclone [27341]
Path:            /opt/homebrew/*/cyclone
Load Address:    0x102f74000
Identifier:      cyclone
Version:         0
Code Type:       ARM64
Platform:        macOS
Parent Process:  bash [27235]

Date/Time:       2021-07-04 00:24:12.741 -0700
Launch Time:     2021-07-04 00:23:55.567 -0700
OS Version:      macOS 11.4 (20F71)
Report Version:  7
Analysis Tool:   /usr/bin/sample

Physical footprint:         2033K
Physical footprint (peak):  2033K
----

Call graph:
    2503 Thread_7020243   DispatchQueue_1: com.apple.main-thread  (serial)
    + 2503 start  (in libdyld.dylib) + 4  [0x184d11450]
    +   2503 main  (in cyclone) + 216  [0x102f76c88]
    +     2503 Cyc_start_trampoline  (in cyclone) + 148  [0x103672cf4]
    +       2503 __lambda_427  (in cyclone) + 140  [0x102f80090]
    +         2503 __lambda_443  (in cyclone) + 316  [0x102f79954]
    +           2503 __lambda_431  (in cyclone) + 288  [0x102f7890c]
    +             2503 __lambda_432  (in cyclone) + 124  [0x102f7f958]
    +               2503 __lambda_1  (in cyclone) + 236  [0x10308cf74]
    +                 2503 __lambda_251  (in cyclone) + 308  [0x102fc0f24]
    +                   2503 __lambda_433  (in cyclone) + 120  [0x102f7f9f8]
    +                     2503 __lambda_20  (in cyclone) + 192  [0x103039d18]
    +                       2503 __lambda_21  (in cyclone) + 416  [0x103039c30]
    +                         2503 __lambda_22  (in cyclone) + 268  [0x10303e334]
    +                           2503 __lambda_23  (in cyclone) + 200  [0x10303e440]
    +                             2503 __lambda_24  (in cyclone) + 512  [0x10303e668]
    +                               2503 __lambda_25  (in cyclone) + 196  [0x10303e7a8]
    +                                 2503 __lambda_26  (in cyclone) + 888  [0x10303eb48]
    +                                   2503 __lambda_27  (in cyclone) + 172  [0x10303ec58]
    +                                     2503 __lambda_28  (in cyclone) + 164  [0x10303ed24]
    +                                       2503 __lambda_85  (in cyclone) + 204  [0x10303ee18]
    +                                         2503 __lambda_29  (in cyclone) + 172  [0x10303eeec]
    +                                           2503 __lambda_30  (in cyclone) + 184  [0x10303f0b0]
    +                                             2503 __lambda_31  (in cyclone) + 184  [0x10303efd0]
    +                                               2503 __lambda_11  (in cyclone) + 416  [0x103039ee0]
    +                                                 2503 __lambda_12  (in cyclone) + 268  [0x10303f340]
    +                                                   2503 __lambda_13  (in cyclone) + 196  [0x10303f448]
    +                                                     2503 __lambda_14  (in cyclone) + 512  [0x10303f670]
    +                                                       2503 __lambda_15  (in cyclone) + 196  [0x10303f7b0]
    +                                                         2503 __lambda_16  (in cyclone) + 148  [0x10303f86c]
    +                                                           2503 __lambda_17  (in cyclone) + 148  [0x10303fd50]
    +                                                             2503 __lambda_18  (in cyclone) + 172  [0x10303fe24]
    +                                                               2503 __lambda_35  (in cyclone) + 256  [0x10303924c]
    +                                                                 2503 Cyc_io_read_token  (in cyclone) + 1396  [0x103674f84]
    +                                                                   2503 gc_mutator_thread_runnable  (in cyclone) + 212  [0x103679ec4]
    +                                                                     2503 gc_mutator_thread_runnable  (in cyclone) + 224,228,...  [0x103679ed0,0x103679ed4,...]
    2503 Thread_7020245
      2503 thread_start  (in libsystem_pthread.dylib) + 8  [0x184cee5e0]
        2503 _pthread_start  (in libsystem_pthread.dylib) + 320  [0x184cf3878]
          2503 collector_main  (in cyclone) + 64  [0x103679500]
            2503 nanosleep  (in libsystem_c.dylib) + 216  [0x184c382a4]
              2503 __semwait_signal  (in libsystem_kernel.dylib) + 8  [0x184cbc344]

Total number in stack (recursive counted multiple, when >=5):

Sort by top of stack, same collapsed (when >= 5):
        __semwait_signal  (in libsystem_kernel.dylib)        2503
        gc_mutator_thread_runnable  (in cyclone)        2503

Binary Images:
       0x102f74000 -        0x1036bbfff +cyclone (0) <CDB8C367-2456-3A98-8507-34E895911DA3> /opt/homebrew/*/cyclone
       0x1037cc000 -        0x1037d3ff7 +libck.0.dylib (0) <203644C4-DC64-32A4-9F57-35FE569F6E04> /opt/homebrew/*/libck.0.dylib
       0x103a60000 -        0x103ade1d3  dyld (852) <CF624584-51D6-329D-91C5-6BEDFADFB2D2> /usr/lib/dyld
       0x184a4e000 -        0x184a4fe8b  libsystem_blocks.dylib (79) <D1EEB8DD-4C98-3860-951D-8EC75B5C887E> /usr/lib/system/libsystem_blocks.dylib
       0x184a50000 -        0x184a87bcb  libxpc.dylib (2038.120.1) <EFD268F9-B27D-36AA-86A6-8774041CDAD1> /usr/lib/system/libxpc.dylib
       0x184a88000 -        0x184a9fb93  libsystem_trace.dylib (1277.120.1) <43C2510E-8316-3BEF-8AA5-7FD377B8E517> /usr/lib/system/libsystem_trace.dylib
       0x184aa0000 -        0x184b13fcf  libcorecrypto.dylib (1000.120.2) <B3A58FED-01F5-3DEB-AB84-56A360C9E37D> /usr/lib/system/libcorecrypto.dylib
       0x184b14000 -        0x184b3fff3  libsystem_malloc.dylib (317.121.1) <009D3C3B-E487-36BE-83FC-6EAB61DAA5EC> /usr/lib/system/libsystem_malloc.dylib
       0x184b40000 -        0x184b84807  libdispatch.dylib (1271.120.2) <F6550274-5861-3B66-BE4B-C0544C4CB795> /usr/lib/system/libdispatch.dylib
       0x184b85000 -        0x184bbeae3  libobjc.A.dylib (824) <60D3BBDD-A4B2-353B-8BCD-57F133BB66FC> /usr/lib/libobjc.A.dylib
       0x184bbf000 -        0x184bc1ffb  libsystem_featureflags.dylib (28.60.1) <1901A100-8004-3B64-8B22-1A77D944C60E> /usr/lib/system/libsystem_featureflags.dylib
       0x184bc2000 -        0x184c43ffb  libsystem_c.dylib (1439.100.3) <EF81BFF2-9151-3386-9508-1BAAE249D84A> /usr/lib/system/libsystem_c.dylib
       0x184c44000 -        0x184c9fffb  libc++.1.dylib (905.6) <3937F450-366C-3790-99CB-5F8AF80C33B0> /usr/lib/libc++.1.dylib
       0x184ca0000 -        0x184cb7ffb  libc++abi.dylib (905.6) <E17CBF1D-9020-31D0-820D-9AD86150966D> /usr/lib/libc++abi.dylib
       0x184cb8000 -        0x184cebfff  libsystem_kernel.dylib (7195.121.3) <FCC78075-2A82-34F5-AC08-B555E39DB1DE> /usr/lib/system/libsystem_kernel.dylib
       0x184cec000 -        0x184cf8fff  libsystem_pthread.dylib (454.120.2) <E2FAA164-BEA2-37A2-935B-BBA138DDC9B6> /usr/lib/system/libsystem_pthread.dylib
       0x184cf9000 -        0x184d3afff  libdyld.dylib (852) <F775B9FF-1995-3613-A55A-3046E628AD8A> /usr/lib/system/libdyld.dylib
       0x184d3b000 -        0x184d41fef  libsystem_platform.dylib (254.80.2) <9E692E15-B0B4-313D-A7A1-C713845AE9BF> /usr/lib/system/libsystem_platform.dylib
       0x184d42000 -        0x184d6dfff  libsystem_info.dylib (542.40.3) <9A2DB28F-34B6-3833-AFBB-425138321913> /usr/lib/system/libsystem_info.dylib
       0x187101000 -        0x18710bff7  libsystem_darwin.dylib (1439.100.3) <193EC794-972E-3A94-857E-78621A7845F7> /usr/lib/system/libsystem_darwin.dylib
       0x187544000 -        0x18754ffff  libsystem_notify.dylib (279.40.4) <40EB921B-26F6-381F-A09D-2C81AC4FDD2D> /usr/lib/system/libsystem_notify.dylib
       0x189521000 -        0x189530ffb  libsystem_networkextension.dylib (1295.120.5) <87BBED5B-50E1-3EB9-AE9F-DC634054217C> /usr/lib/system/libsystem_networkextension.dylib
       0x189586000 -        0x18959dff3  libsystem_asl.dylib (385) <FDF27EA4-D035-30F4-9C8E-5F276533170F> /usr/lib/system/libsystem_asl.dylib
       0x18aaf3000 -        0x18aafafff  libsystem_symptoms.dylib (1431.120.1) <BC3928DE-7A97-3190-B06E-080A30D32463> /usr/lib/system/libsystem_symptoms.dylib
       0x18c94d000 -        0x18c95effb  libsystem_containermanager.dylib (318.100.4) <1FFA0A3E-EF38-314A-BE28-5348FF274778> /usr/lib/system/libsystem_containermanager.dylib
       0x18d5ca000 -        0x18d5cefff  libsystem_configuration.dylib (1109.120.1) <ECEA3DAA-ADFC-3D0D-8951-279CDDB553EF> /usr/lib/system/libsystem_configuration.dylib
       0x18d5cf000 -        0x18d5d3ff3  libsystem_sandbox.dylib (1441.120.5) <0D01ECDE-9F24-30DE-9F37-6A980752BE0B> /usr/lib/system/libsystem_sandbox.dylib
       0x18df90000 -        0x18df92ffb  libquarantine.dylib (119.40.2) <D48BB719-6CD2-3F08-9064-0992A490E4F2> /usr/lib/system/libquarantine.dylib
       0x18e4f3000 -        0x18e4f7ffb  libsystem_coreservices.dylib (127.1) <E281EB73-54F4-30A8-8E56-9208D17CEAEA> /usr/lib/system/libsystem_coreservices.dylib
       0x18e6ef000 -        0x18e71cfcb  libsystem_m.dylib (3186.100.3) <62AE5ECE-F59B-36CC-BE4F-935C4AAA5A50> /usr/lib/system/libsystem_m.dylib
       0x18e71e000 -        0x18e723ffb  libmacho.dylib (980) <A93DD379-6612-3200-9B02-84803274B6B9> /usr/lib/system/libmacho.dylib
       0x18e73c000 -        0x18e749ffb  libcommonCrypto.dylib (60178.120.3) <4F46EA59-019E-34AA-8EFA-44534DC4321F> /usr/lib/system/libcommonCrypto.dylib
       0x18e74a000 -        0x18e754fff  libunwind.dylib (201) <241E3D3F-802A-39EA-8F5F-2F03137BE8D3> /usr/lib/system/libunwind.dylib
       0x18e755000 -        0x18e75cfff  liboah.dylib (203.46) <F1CBF4AA-033C-3ABA-A13E-696ADC7A9E6A> /usr/lib/liboah.dylib
       0x18e75d000 -        0x18e765fff  libcopyfile.dylib (173.40.2) <54BE801A-ACD8-32B4-9462-215F6E28BE34> /usr/lib/system/libcopyfile.dylib
       0x18e766000 -        0x18e769fff  libcompiler_rt.dylib (102.2) <B71B5432-79C8-3D81-97C0-B48528BCFB28> /usr/lib/system/libcompiler_rt.dylib
       0x18e76a000 -        0x18e76cfff  libsystem_collections.dylib (1439.100.3) <BBCEB3ED-935C-322D-8E19-B9E1DFD28A72> /usr/lib/system/libsystem_collections.dylib
       0x18e76d000 -        0x18e76fffb  libsystem_secinit.dylib (87.60.1) <87E4EC68-41CF-31FF-BE03-1F281BEB2CDE> /usr/lib/system/libsystem_secinit.dylib
       0x18e770000 -        0x18e772fff  libremovefile.dylib (49.120.1) <890BF916-C32E-37CA-8469-155E62F7E8EC> /usr/lib/system/libremovefile.dylib
       0x18e773000 -        0x18e773ffb  libkeymgr.dylib (31) <F477F112-549F-3C72-B6BD-0281BC046E54> /usr/lib/system/libkeymgr.dylib
       0x18e774000 -        0x18e77cfab  libsystem_dnssd.dylib (1310.120.71) <89358F53-4E2F-39C9-A55C-FFA55B27BA1A> /usr/lib/system/libsystem_dnssd.dylib
       0x18e77d000 -        0x18e782ff7  libcache.dylib (83) <776133A5-A09C-310F-B0FE-4CA311433D94> /usr/lib/system/libcache.dylib
       0x18e783000 -        0x18e784ffb  libSystem.B.dylib (1292.120.1) <1ADA647F-F493-3C49-AD69-C24F0D76F491> /usr/lib/libSystem.B.dylib
       0x191ba4000 -        0x191ba4fff  liblaunch.dylib (2038.120.1) <477FFDB4-6279-3B73-ADF7-933CD1E9491E> /usr/lib/system/liblaunch.dylib
       0x194052000 -        0x194052fff  libsystem_product_info_filter.dylib (8.40.1) <188B6361-3ABE-3320-AFF7-C4C6A0F316EC> /usr/lib/system/libsystem_product_info_filter.dylib
Sample analysis of process 27341 written to file /dev/stdout

c0nn3r avatar Jul 04 '21 07:07 c0nn3r

Well, that is concerning. Thanks for the report @c0nn3r

Everything has been tested to work on MacOS though I suspect the test runners are not using an M1.

justinethier avatar Jul 05 '21 16:07 justinethier

I suspect atomic operations from concurrency kit (libck) are not working properly on M1. If that is the case perhaps they could be replaced, EG by using polyfills and/or atomic operations from C11.

justinethier avatar Jul 08 '21 02:07 justinethier

This seems to have been fixed, in particular, brew install -s --HEAD ck will build the patched ck from head.

BracketMaster avatar Aug 18 '21 22:08 BracketMaster

That's great news, thanks for the update @BracketMaster !

I wonder if this requires the latest changes from head or if it will also work with the 0.7.1 pre-release.

justinethier avatar Aug 19 '21 02:08 justinethier

@c0nn3r can you confirm if this is still an issue?

justinethier avatar Sep 15 '21 14:09 justinethier

Without upgrading concurrencykit with brew, this is still an issue.

c0nn3r avatar Sep 16 '21 16:09 c0nn3r

This is still an issue, is there some kind of fix?

joaogui1 avatar Feb 20 '22 10:02 joaogui1

@joaogui1 According to @BracketMaster you can do brew install -s --HEAD ck to install the latest libck and fix this. I would suggest giving that a try if you are running into this issue.

Please let me know how it goes. Unfortunately I do not have M1 hardware over here and cannot test this directly...

justinethier avatar Feb 21 '22 14:02 justinethier

That works, thanks! Sorry for the ping, I thought @c0nn3r's answer meant the fix had stopped working

joaogui1 avatar Feb 21 '22 19:02 joaogui1

@joaogui1 No worries. Unfortunately that reply is rather confusing.

Just so we are all on the same page is brew install -s --HEAD ck required?

justinethier avatar Feb 21 '22 20:02 justinethier

Yep, I first had to uninstall my version of libck and then run that

joaogui1 avatar Feb 21 '22 20:02 joaogui1