Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

109 строки
2.8 KiB

13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
  1. %% a module that crashes in just about every way possible
  2. -module(crash).
  3. -behaviour(gen_server).
  4. -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
  5. -export([start/0]).
  6. -record(state, {
  7. host :: term(),
  8. port :: term()
  9. }).
  10. start() ->
  11. gen_server:start({local, ?MODULE}, ?MODULE, [], []).
  12. init(_) ->
  13. {ok, {}}.
  14. handle_call(undef, _, State) ->
  15. {reply, ?MODULE:booger(), State};
  16. handle_call(badfun, _, State) ->
  17. M = booger,
  18. {reply, M(), State};
  19. handle_call(bad_return, _, _) ->
  20. bleh;
  21. handle_call(bad_return_string, _, _) ->
  22. {tuple, {tuple, "string"}};
  23. handle_call(case_clause, _, State) ->
  24. case State of
  25. goober ->
  26. {reply, ok, State}
  27. end;
  28. handle_call(case_clause_string, _, State) ->
  29. Foo = atom_to_list(?MODULE),
  30. case Foo of
  31. State ->
  32. {reply, ok, State}
  33. end;
  34. handle_call(if_clause, _, State) ->
  35. if State == 1 ->
  36. {reply, ok, State}
  37. end;
  38. handle_call(try_clause, _, State) ->
  39. Res = try tuple_to_list(State) of
  40. [_A, _B] -> ok
  41. catch
  42. _:_ -> ok
  43. end,
  44. {reply, Res, State};
  45. handle_call(badmatch, _, State) ->
  46. {A, B, C} = State,
  47. {reply, [A, B, C], State};
  48. handle_call(badrecord, _, State) ->
  49. Host = State#state.host,
  50. {reply, Host, State};
  51. handle_call(function_clause, _, State) ->
  52. {reply, function(State), State};
  53. handle_call(badarith, _, State) ->
  54. Res = 1 / length(tuple_to_list(State)),
  55. {reply, Res, State};
  56. handle_call(badarg1, _, State) ->
  57. Res = list_to_binary(["foo", bar]),
  58. {reply, Res, State};
  59. handle_call(badarg2, _, State) ->
  60. Res = erlang:iolist_to_binary(["foo", bar]),
  61. {reply, Res, State};
  62. handle_call(system_limit, _, State) ->
  63. Res = list_to_atom(lists:flatten(lists:duplicate(256, "a"))),
  64. {reply, Res, State};
  65. handle_call(process_limit, _, State) ->
  66. %% run with +P 300 to make this crash
  67. [erlang:spawn(fun() -> timer:sleep(5000) end) || _ <- lists:seq(0, 500)],
  68. {reply, ok, State};
  69. handle_call(port_limit, _, State) ->
  70. [erlang:open_port({spawn, "ls"}, []) || _ <- lists:seq(0, 1024)],
  71. {reply, ok, State};
  72. handle_call(noproc, _, State) ->
  73. Res = gen_event:call(foo, bar, baz),
  74. {reply, Res, State};
  75. handle_call(noproc_proc_lib, _, State) ->
  76. Res = proc_lib:stop(foo),
  77. {reply, Res, State};
  78. handle_call(badarity, _, State) ->
  79. F = fun(A, B, C) -> A + B + C end,
  80. Res = F(State),
  81. {reply, Res, State};
  82. handle_call(throw, _, _State) ->
  83. throw(a_ball);
  84. handle_call(_Call, _From, State) ->
  85. {reply, ok, State}.
  86. handle_cast(_Cast, State) ->
  87. {noreply, State}.
  88. handle_info(_Info, State) ->
  89. {noreply, State}.
  90. terminate(_, _) ->
  91. ok.
  92. code_change(_, State, _) ->
  93. {ok, State}.
  94. function(X) when is_list(X) ->
  95. ok.