What version of Racket are you using?
Racket BC v7.8.0.6., HEAD 502210748
Compiling the following file with stacktrace preservation crashes Racket. That is,
$ racket
Welcome to Racket v7.8.0.6.
> (require compiler/cm)
> (compile-context-preservation-enabled #t)
> (managed-compile-zo "txb.rkt")
Assertion failed: (((Scheme_IR_Local *)val)->mode == 3), function optimize_info_propagate_local, file /Users/shhyou/Works/Grp/racket/stable/racket/src/build/../racket/gc2/../src/optimize.c, line 10294.
Abort trap: 6
For the same reason, the crash can be triggered using DrRacket when there debugging and profiling are turned off and the stacktrace is preserved.
DrRacket config:
What program did you run?
Reordering the methods or turning on errortrace both avoid the issue.
Steps to compile:
$ racket
Welcome to Racket v7.8.0.6.
> (require compiler/cm)
> (compile-context-preservation-enabled #t)
> (managed-compile-zo "txb.rkt")
Assertion failed: (((Scheme_IR_Local *)val)->mode == 3), function optimize_info_propagate_local, file /Users/shhyou/Works/Grp/racket/stable/racket/src/build/../racket/gc2/../src/optimize.c, line 10294.
Abort trap: 6
File:
;; txb.rkt
#lang racket/base
(require racket/class
racket/match)
(define (->tex-tree root)
(send (new ->tex-tree% [root root])
->tree))
(define ->tex-tree%
(class object%
[init-field [(root-x root)]]
(define/private (remove-beginning-p x)
x)
(define/private (txexpr->tree x)
(match (remove-beginning-p x)
[x (txelements->forest x)]))
(define/private (txelements->forest xs)
(for/list ([x (in-list xs)])
(txexpr->tree x)))
(define/public (->tree)
(txelements->forest '......))
(super-new)))
If you got an error message, please include it here.
Additional crash information when launching from DrRacket:
$ drracket txb.rkt
Assertion failed: (((Scheme_IR_Local *)val)->mode == 3), function optimize_info_propagate_local, file ........./racket/src/build/../racket/gc2/../src/optimize.c, line 10294.
Abort trap: 6
Please include any other relevant details
Process: DrRacket [92761]
Path: /Users/USER/*/DrRacket.app/Contents/MacOS/DrRacket
Identifier: org.racket-lang.DrRacket
Version: 7.8.0.6 (7.8.0.6)
Code Type: X86-64 (Native)
Parent Process: bash [92651]
Responsible: Terminal [92643]
User ID: 501
Date/Time: 2020-07-26 13:10:03.230 +0800
OS Version: Mac OS X 10.15.2 (19C57)
System Integrity Protection: enabled
Crashed Thread: 13
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
Assertion failed: (((Scheme_IR_Local *)val)->mode == 3), function optimize_info_propagate_local, file ........./racket/src/build/../racket/gc2/../src/optimize.c, line 10294.
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff67d1325a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff67d135d0 mach_msg + 60
2 com.apple.CoreFoundation 0x00007fff30577d0b __CFRunLoopServiceMachPort + 322
3 com.apple.CoreFoundation 0x00007fff305768e7 __CFRunLoopRun + 1695
4 com.apple.CoreFoundation 0x00007fff30575bd3 CFRunLoopRunSpecific + 499
5 com.apple.HIToolbox 0x00007fff2f0cc65d RunCurrentEventLoopInMode + 292
6 com.apple.HIToolbox 0x00007fff2f0cc39d ReceiveNextEventCommon + 600
7 com.apple.HIToolbox 0x00007fff2f0cc127 _BlockUntilNextEventMatchingListInModeWithFilter + 64
8 com.apple.AppKit 0x00007fff2d73deb4 _DPSNextEvent + 990
9 com.apple.AppKit 0x00007fff2d73c690 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
10 Racket 0x00000001037d373c ffi_call_unix64 + 76
11 Racket 0x00000001037d3fb1 ffi_call + 897
12 Racket 0x00000001037ce908 ffi_do_call + 2264
13 Racket 0x00000001037cdf99 ffi_do_call_after_stack_check + 137
14 ??? 0x0000000105ac14d6 0 + 4390130902
15 ??? 0x000000010599bb0b 0 + 4388928267
16 Racket 0x000000010353467f scheme_do_eval + 4831 (eval.c:2513)
17 Racket 0x00000001037adbd1 sleep_via_thread + 97 (schthread.h:393)
18 Racket 0x00000001037a41bd check_sleep + 1581
19 Racket 0x000000010379b2c0 scheme_thread_block + 3488 (thread.c:5020)
20 Racket 0x00000001037a50ef scheme_block_until + 607 (thread.c:5157)
21 Racket 0x00000001037a8f65 do_sync + 1685 (schthread.h:393)
22 Racket 0x0000000103536ff3 _scheme_apply_multi_from_native + 451 (schnapp.inc:33)
23 ??? 0x000000010599c22a 0 + 4388930090
24 Racket 0x000000010353467f scheme_do_eval + 4831 (eval.c:2513)
25 Racket 0x0000000103536fb4 _scheme_apply_multi_from_native + 388 (schthread.h:393)
26 ??? 0x00000001059693db 0 + 4388721627
27 Racket 0x000000010353467f scheme_do_eval + 4831 (eval.c:2513)
28 Racket 0x000000010355d5aa apply_k + 170 (schthread.h:393)
29 Racket 0x000000010355ccb3 scheme_top_level_do_worker + 1523 (fun.c:1329)
30 Racket 0x00000001037a1134 start_child + 804 (thread.c:3374)
31 ??? 0x0000000105972140 0 + 4388757824
32 Racket 0x00000001037a1bca make_subprocess + 810 (thread.c:3430)
33 Racket 0x00000001037a1428 scheme_thread_w_details + 264 (thread.c:3688)
34 ??? 0x00007fd50e75f7d0 0 + 140553047373776
Thread 1:
0 libsystem_kernel.dylib 0x00007fff67d1325a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff67d135d0 mach_msg + 60
2 Racket 0x00000001037d4f35 exception_thread + 101 (vm_osx.c:366)
3 libsystem_pthread.dylib 0x00007fff67dd6e65 _pthread_start + 148
4 libsystem_pthread.dylib 0x00007fff67dd283b thread_start + 15
Thread 2:
0 libsystem_kernel.dylib 0x00007fff67d15ce6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff67dd7185 _pthread_cond_wait + 701
2 Racket 0x00000001036f9c25 green_thread_timer + 117 (port.c:6649)
3 Racket 0x0000000103673672 mzrt_thread_stub + 82 (mzrt.c:91)
4 libsystem_pthread.dylib 0x00007fff67dd6e65 _pthread_start + 148
5 libsystem_pthread.dylib 0x00007fff67dd283b thread_start + 15
Thread 3:
0 libsystem_pthread.dylib 0x00007fff67dd2818 start_wqthread + 0
Thread 4:
0 libsystem_pthread.dylib 0x00007fff67dd2818 start_wqthread + 0
Thread 5:
0 libsystem_pthread.dylib 0x00007fff67dd2818 start_wqthread + 0
Thread 6:
0 libsystem_pthread.dylib 0x00007fff67dd2818 start_wqthread + 0
Thread 7:: com.apple.CFSocket.private
0 libsystem_kernel.dylib 0x00007fff67d1b5be __select + 10
1 com.apple.CoreFoundation 0x00007fff305a0d8a __CFSocketManager + 632
2 libsystem_pthread.dylib 0x00007fff67dd6e65 _pthread_start + 148
3 libsystem_pthread.dylib 0x00007fff67dd283b thread_start + 15
Thread 8:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x00007fff67d1325a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff67d135d0 mach_msg + 60
2 com.apple.CoreFoundation 0x00007fff30577d0b __CFRunLoopServiceMachPort + 322
3 com.apple.CoreFoundation 0x00007fff305768e7 __CFRunLoopRun + 1695
4 com.apple.CoreFoundation 0x00007fff30575bd3 CFRunLoopRunSpecific + 499
5 com.apple.AppKit 0x00007fff2d8e0a72 _NSEventThread + 132
6 libsystem_pthread.dylib 0x00007fff67dd6e65 _pthread_start + 148
7 libsystem_pthread.dylib 0x00007fff67dd283b thread_start + 15
Thread 9:
0 libsystem_pthread.dylib 0x00007fff67dd2818 start_wqthread + 0
Thread 10:
0 libsystem_pthread.dylib 0x00007fff67dd2818 start_wqthread + 0
Thread 11:
0 libsystem_pthread.dylib 0x00007fff67dd2818 start_wqthread + 0
Thread 12:
0 libsystem_pthread.dylib 0x00007fff67dd2818 start_wqthread + 0
Thread 13 Crashed:
0 libsystem_kernel.dylib 0x00007fff67d197fa __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff67dd6bc1 pthread_kill + 432
2 libsystem_c.dylib 0x00007fff67ca0a1c abort + 120
3 libsystem_c.dylib 0x00007fff67c9fcd6 __assert_rtn + 314
4 Racket 0x00000001037f8023 optimize_expr.cold.4 + 35
5 Racket 0x00000001036c513b optimize_expr + 18715 (optimize.c:10295)
6 Racket 0x00000001036c42e6 optimize_expr + 15046 (optimize.c:4847)
7 Racket 0x00000001036c93ee optimize_lets + 3310 (optimize.c:7772)
8 Racket 0x00000001036c157a optimize_expr + 3418
9 Racket 0x00000001036c25ba optimize_expr + 7578
10 Racket 0x00000001036c93ee optimize_lets + 3310 (optimize.c:7772)
11 Racket 0x00000001036c157a optimize_expr + 3418
12 Racket 0x00000001036cab23 optimize_lets + 9251 (optimize.c:8242)
13 Racket 0x00000001036c157a optimize_expr + 3418
14 Racket 0x00000001036cce3c optimize_sequence + 316 (optimize.c:5478)
15 Racket 0x00000001036c115b optimize_expr + 2363
16 Racket 0x00000001036c25ba optimize_expr + 7578
17 Racket 0x00000001036c33c7 optimize_expr + 11175 (optimize.c:3857)
18 Racket 0x00000001036c198c optimize_expr + 4460 (optimize.c:6381)
19 Racket 0x00000001036bf67a scheme_optimize_linklet + 5818 (optimize.c:9377)
20 Racket 0x000000010365fe00 compile_and_or_optimize_linklet + 624 (linklet.c:1184)
21 Racket 0x000000010365d025 compile_linklet + 629 (linklet.c:459)
22 Racket 0x0000000103536ff3 _scheme_apply_multi_from_native + 451 (schnapp.inc:33)
23 ??? 0x00000001085fe55a 0 + 4435469658
24 ??? 0x000000010949dc3b 0 + 4450802747
25 ??? 0x00000001096795db 0 + 4452750811
26 ??? 0x000000010949d9ae 0 + 4450802094
27 ??? 0x000000010599c2cb 0 + 4388930251
28 ??? 0x0000000105b080cb 0 + 4390420683
29 ??? 0x00000001059773bd 0 + 4388778941
30 Racket 0x000000010353467f scheme_do_eval + 4831 (eval.c:2513)
31 Racket 0x0000000103536fb4 _scheme_apply_multi_from_native + 388 (schthread.h:393)
32 ??? 0x00000001059693db 0 + 4388721627
33 Racket 0x000000010353467f scheme_do_eval + 4831 (eval.c:2513)
34 Racket 0x000000010355d5aa apply_k + 170 (schthread.h:393)
35 Racket 0x000000010355ccb3 scheme_top_level_do_worker + 1523 (fun.c:1329)
36 Racket 0x00000001037a1134 start_child + 804 (thread.c:3374)
37 ??? 0x0000000105972140 0 + 4388757824
38 Racket 0x00000001037a1bca make_subprocess + 810 (thread.c:3430)
39 Racket 0x00000001037a1428 scheme_thread_w_details + 264 (thread.c:3688)
40 ??? 0x000070000f64c680 0 + 123145560573568
Thread 14:
0 libsystem_kernel.dylib 0x00007fff67d15bba __semwait_signal + 10
1 libsystem_c.dylib 0x00007fff67c990fa nanosleep + 196
2 libsystem_c.dylib 0x00007fff67c98ff4 usleep + 53
3 Racket 0x00000001036f9bdb green_thread_timer + 43 (port.c:6640)
4 Racket 0x0000000103673672 mzrt_thread_stub + 82 (mzrt.c:91)
5 libsystem_pthread.dylib 0x00007fff67dd6e65 _pthread_start + 148
6 libsystem_pthread.dylib 0x00007fff67dd283b thread_start + 15
Thread 15:
0 libsystem_kernel.dylib 0x00007fff67d1b5be __select + 10
1 Racket 0x00000001037ec01d rktio_sleep + 877 (rktio_poll_set.c:1179)
2 Racket 0x00000001037ecb53 do_background_sleep + 163 (rktio_sleep.c:74)
3 libsystem_pthread.dylib 0x00007fff67dd6e65 _pthread_start + 148
4 libsystem_pthread.dylib 0x00007fff67dd283b thread_start + 15
Thread 13 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x000070000f64d000 rcx: 0x000070000f649898 rdx: 0x0000000000000000
rdi: 0x0000000000013277 rsi: 0x0000000000000006 rbp: 0x000070000f6498c0 rsp: 0x000070000f649898
r8: 0x0000000000002836 r9: 0xcccccccccccccccd r10: 0x000070000f64d000 r11: 0x0000000000000246
r12: 0x0000000000013277 r13: 0x0000000136401000 r14: 0x0000000000000006 r15: 0x0000000000000016
rip: 0x00007fff67d197fa rfl: 0x0000000000000246 cr2: 0x0000000136401000
Logical CPU: 0
Error Code: 0x02000148
Trap Number: 133
Model: MacBookPro12,1, BootROM 188.0.0.0.0, 2 processors, Dual-Core Intel Core i7, 3.1 GHz, 16 GB, SMC 2.28f7
Graphics: kHW_IntelIris6100Item, Intel Iris Graphics 6100, spdisplays_builtin
Memory Module: BANK 0/DIMM0, 8 GB, DDR3, 1867 MHz, 0x02FE, 0x4544464232333241314D412D4A442D460000
Memory Module: BANK 1/DIMM0, 8 GB, DDR3, 1867 MHz, 0x02FE, 0x4544464232333241314D412D4A442D460000
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x133), Broadcom BCM43xx 1.0 (7.77.106.3 AirPortDriverBrcmNIC-1435.3)
Bluetooth: Version 7.0.2f4, 3 services, 18 devices, 1 incoming serial ports
Network Service: Northwestern, AirPort, en0
Serial ATA Device: APPLE SSD SM1024G, 1 TB
USB Device: USB 3.0 Bus
USB Device: Bluetooth USB Host Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 27.1
I can reproduce this in DrRacket (BC 7.7) but only if I also disable "_Enforce constant definitions_".
Expanded and minimized version
#lang racket/base
(letrec ([f (lambda () 0)]
[g (let ([g2
(lambda ()
(let ([x (f)])
(list (lambda () x) h)))])
g2)]
[h (letrec ([loop
(lambda ()
(let ([y (g)])
(list y loop)))])
loop)])
h)
This gives a slightly different error (still about mode), but works at the command line:
#lang racket/base
(define v
'(module m racket/base
(letrec-values ([(f) (lambda () 0)]
[(g) (let-values ([(g2)
(lambda ()
(let-values ([(x) (f)])
(list (lambda () x) h)))])
g2)]
[(h) (letrec-values ([(loop)
(lambda ()
(let-values ([(y) (g)])
(list y loop)))])
loop)])
h)))
(compile-context-preservation-enabled #t)
(current-namespace (make-base-namespace))
(eval v)
Error:
racket: ../../../racket/gc2/../src/resolve.c:2669: resolve_info_lookup: Assertion `var->mode == 4' failed.
Note that the program there (which I've edited to work in '#%kernel) only crashes if the language is racket/base, not #%kernel.
It looks like one possible fix is to change "optimize.c"
info->inline_fuel = 0; /* no more inlining; o->expr was already optimized */
and replace 0 with -1.
A 0 turns out to mean "inline only single-use", but the intent here is -1: "don't inline".
@samth: It causes an error in '#%kernel if you replace the last h with (display h). Otherwise the optimizer realizes that the whole expression does nothing and just drop it. (Or at least a big part of it, sometimes the optimizer is not smart enough.)
Looks like this was introduced in 0c38da0ee2b3a8c7e9ca about 5 years ago.