| 1 |
;ACME 0.97 |
| 2 |
|
| 3 |
; "denial of service", first try: |
| 4 |
|
| 5 |
; this macro calls itself ten times with a decreased "depth" value. |
| 6 |
; because each macro call gets its own symbols, this takes not only |
| 7 |
; time, but also a lot of memory: |
| 8 |
!macro dos @depth { |
| 9 |
!if @depth > 0 { |
| 10 |
!for @i, 0, 9 { |
| 11 |
+dos @depth - 1 |
| 12 |
} |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
; +dos 0 ; returns immediately |
| 17 |
; +dos 1 ; returns immediately |
| 18 |
; +dos 2 ; returns immediately |
| 19 |
; +dos 3 ; returns immediately |
| 20 |
; +dos 4 ; returns immediately |
| 21 |
; +dos 5 ; takes <1s |
| 22 |
; +dos 6 ; takes a few seconds |
| 23 |
; +dos 7 ; may take 30 minutes... |
| 24 |
; +dos 8 ; don't do this |
| 25 |
|
| 26 |
|
| 27 |
; "denial of service", second try: |
| 28 |
|
| 29 |
; this uses global symbols and therefore only takes time: |
| 30 |
!macro dos2 { |
| 31 |
!if depth > 0 { |
| 32 |
!set depth = depth - 1 |
| 33 |
+dos2 : +dos2 : +dos2 : +dos2 : +dos2 |
| 34 |
+dos2 : +dos2 : +dos2 : +dos2 : +dos2 |
| 35 |
!set depth = depth + 1 |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
; depths 0..4 return immediately, |
| 40 |
; 5 takes .2s |
| 41 |
; 6 takes 2s |
| 42 |
; 7 takes 20s |
| 43 |
; 8 takes about 3 minutes |
| 44 |
; 9 may take 30 minutes... |
| 45 |
; etc. pp. |
| 46 |
!set depth = 8 |
| 47 |
+dos2 |
| 48 |
|