[racket] Problems trying to do non-blocking I/O and a reactor loop

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Sat Aug 4 12:40:59 EDT 2012

Greg Hendershott wrote at 08/03/2012 08:51 PM:
> I wonder can anyone else elicit these problems trying to run it, too?
>    

Your test seems to fail for me (on Debian Stable GNU/Linux, 32-bit x86) 
after around 26K to 27K requests (with "-c 10"), using a pre-release 
Racket from several days ago.  The Racket VM complains to be out of 
memory, and it dumps core.

$ /usr/local/racket-5.2.900.1-20120727/bin/racket bug-example.rkt
serve: port=8081 hostname=#f timeout=60
Racket virtual machine has run out of memory; aborting
Aborted (core dumped)

$ ab -n 100000 -c 10 http://127.0.0.1:8081/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 10000 requests
Completed 20000 requests
apr_socket_recv: Connection reset by peer (104)
Total of 26299 requests completed

The second attempt had almost identical output, except "ab" said it got 
to 27073 requests rather than 26299.  Third attempt was 25978.

Rest of this email is backtrace from second attempt.

#0  0xb7753424 in __kernel_vsyscall ()
#1  0xb75d9781 in raise () from /lib/i686/cmov/libc.so.6
#2  0xb75dcbb2 in abort () from /lib/i686/cmov/libc.so.6
#3  0x0806ef32 in scheme_out_of_memory_abort () at ./../src/salloc.c:330
#4  0x08254861 in out_of_memory () at ./newgc.c:316
#5  0x08259a6f in malloc_pages (gc=<value optimized out>, len=647430144, 
dirty=<value optimized out>, type=1,
     expect_mprotect=1, src_block=0x880b0d8, alignment=<value optimized 
out>) at ./newgc.c:426
#6  0x0825c83b in create_new_medium_page (request_size_bytes=<value 
optimized out>, type=<value optimized out>)
     at ./newgc.c:1006
#7  allocate_medium (request_size_bytes=<value optimized out>, 
type=<value optimized out>) at ./newgc.c:1112
#8  0x08227961 in scheme_alloc_runstack (len=1000) at ./../src/thread.c:2329
#9  0x08231446 in make_thread (config=0x3a06c718, cells=0xb2f24380, 
init_break_cell=0x3a0bb678, mgr=0x3a06c6c8,
     stack_base=0xbff2181c) at ./../src/thread.c:2188
#10 0x08232371 in make_subprocess (child_thunk=0xb2f24360, 
child_start=0xbff2181c, config=0x3a06c718, cells=0xb2f24380,
     break_cell=0x3a0bb678, mgr=0x0, normal_kill=1) at 
./../src/thread.c:2902
#11 0x0823259f in scheme_thread_w_details (thunk=0xb2f24360, config=0x0, 
cells=0x0, break_cell=0x0, mgr=0x0,
     suspend_to_kill=0) at ./../src/thread.c:3137
#12 0x08232659 in scheme_thread (thunk=0xb2f24360) at ./../src/thread.c:2946
#13 0x082326e2 in sch_thread (argc=1, args=0xb6290eb4) at 
./../src/thread.c:2954
#14 0xb5a882a0 in ?? ()
#15 0x0808ae14 in scheme_do_eval (obj=0x0, num_rands=141716928, 
rands=0xbff21c1c, get_value=1) at ./../src/eval.c:2837
#16 0x0809f87f in apply_k () at ./../src/fun.c:1336
#17 0x080ab5d8 in scheme_top_level_do_worker (k=0x809f7f0 <apply_k>, 
eb=1, new_thread=0, dyn_state=0x0)
     at ./../src/fun.c:1175
#18 0x080abff8 in scheme_top_level_do (k=0x809f7f0 <apply_k>, eb=1) at 
./../src/fun.c:1088
#19 0x082052d5 in nack_guard_evt_is_ready (o=0xb2f242e8, 
sinfo=0xbff21cc4) at ./../src/struct.c:3459
#20 0x0822e285 in syncing_ready (s=0xb2f1ec08, sinfo=0xbff21d40) at 
./../src/thread.c:6135
#21 0x0822df54 in scheme_block_until (_f=0x822e150 <syncing_ready>, 
fdf=0x8220f10 <syncing_needs_wakeup>,
     data=0xb2f1ec08, delay=0) at ./../src/thread.c:4807
#22 0x0822f174 in do_sync (name=0x828f7df "sync", argc=<value optimized 
out>, argv=0xb6290ed0, with_break=0,
     with_timeout=0, _tailok=1) at ./../src/thread.c:6521
#23 0x0822f74d in sch_sync (argc=12, argv=0xb6290ed0) at 
./../src/thread.c:6614
#24 0x0808d9f6 in _scheme_apply_from_native_fast (rator=0x0, argc=12, 
argv=0x6)
#25 _scheme_apply_from_native (rator=0x0, argc=12, argv=0x6) at 
./../src/schnapp.inc:64
#26 0xb5a87973 in ?? ()
#27 0x0808ae14 in scheme_do_eval (obj=0x0, num_rands=12, rands=0x0, 
get_value=-1) at ./../src/eval.c:2837
#28 0x0808d7a1 in _scheme_apply_multi_from_native (rator=0x0, argc=2, 
argv=0x6)
#29 0xb5a8b903 in ?? ()
#30 0x0808ae14 in scheme_do_eval (obj=0x0, num_rands=2, 
rands=0xbff22498, get_value=-1) at ./../src/eval.c:2837
#31 0x080a70b0 in scheme_finish_apply_for_prompt (prompt=0xb37cc8f0, 
_prompt_tag=0xb57225d0, proc=0x3a0f0a80, argc=2,
     argv=0xbff22498) at ./../src/fun.c:5847
#32 0x080a7212 in scheme_apply_for_prompt (prompt=0xb37cc8f0, 
prompt_tag=0xb57225d0, proc=0x3a0f0a80, argc=2,
     argv=0xbff22498) at ./../src/fun.c:5926
#33 0x080a92c9 in call_with_prompt (in_argc=5, in_argv=0xb6290f1c) at 
./../src/fun.c:6325
#34 0xb5a8b964 in ?? ()
#35 0xb43f9c84 in ?? ()
#36 0x0808ae14 in scheme_do_eval (obj=0x0, num_rands=141743128, 
rands=0xbff22804, get_value=-1) at ./../src/eval.c:2837
#37 0x0808d7a1 in _scheme_apply_multi_from_native (rator=0x0, argc=3, 
argv=0x6)
#38 0xb5a8b903 in ?? ()
#39 0x080a00c2 in _apply_native (obj=0x2a77d2b8, num_rands=6, 
rands=0x4af4) at ./../src/fun.c:3150
#40 0x080b44d4 in scheme_apply_chaperone (o=0x2a77d2c8, argc=3, 
argv=0xb6290fa0, auto_val=0x0, checks=0)
     at ./../src/fun.c:3389
#41 0x08089c6e in scheme_do_eval (obj=0x2a77d2c8, num_rands=3, 
rands=0xb6290fa0, get_value=-1) at ./../src/eval.c:2970
#42 0x0808d53f in apply_values_execute (data=0x2a77d330) at 
./../src/eval.c:2031
#43 0x0808a10b in scheme_do_eval (obj=0x2a77d330, num_rands=-1, 
rands=0x0, get_value=-1) at ./../src/eval.c:3666
#44 0x0812e3e9 in body_one_expr (prefix_plus_expr=0x2a77d340, argc=0, 
argv=0x0) at ./../src/module.c:5498
#45 0x08089842 in scheme_do_eval (obj=0x2a77d350, num_rands=0, 
rands=0x0, get_value=-1) at ./../src/eval.c:2991
#46 0x080a70b0 in scheme_finish_apply_for_prompt (prompt=0xb45be150, 
_prompt_tag=0xb661c878, proc=0x2a77d350, argc=0,
     argv=0x0) at ./../src/fun.c:5847
#47 0x080a7212 in scheme_apply_for_prompt (prompt=0xb45be150, 
prompt_tag=0xb661c878, proc=0x2a77d350, argc=0, argv=0x0)
     at ./../src/fun.c:5926
#48 0x080a92c9 in call_with_prompt (in_argc=3, in_argv=0xbff22f28) at 
./../src/fun.c:6325
#49 0x0808a95b in scheme_do_eval (obj=0x872d418, num_rands=3, 
rands=0xbff22f28, get_value=-1) at ./../src/eval.c:2582
#50 0x080acb20 in do_call_with_prompt (f=<value optimized out>, 
data=<value optimized out>, multi=0, top_level=0)
     at ./../src/fun.c:6525
#51 0x0812e67e in scheme_module_run_finish (menv=0x2a77d588, 
env=0x3a06c780) at ./../src/module.c:5593
#52 0xb5a87375 in ?? ()
#53 0x0811d630 in scheme_module_run_start (menv=0x2a77d588, 
env=0x3a06c780, name=0x2a77d698) at ./../src/jitstack.c:492
#54 0x0812b4e3 in eval_module_body (menv=0x2a77d588, env=0x3a06c780) at 
./../src/module.c:5487
#55 0x0812b5b1 in do_start_module (m=<value optimized out>, 
menv=0xb45bed58, env=0xb56447d0, restart=0)
     at ./../src/module.c:5281
#56 0x0813d8be in start_module (m=<value optimized out>, env=0x3a06c780, 
restart=<value optimized out>,
     syntax_idx=0x3a06d0f8, eval_exp=-1, eval_run=1, base_phase=0, 
cycle_list=0x82d0670, not_new=0)
     at ./../src/module.c:5378
#57 0x0813e21b in parse_requires (form=0x3a06d0f8, at_phase=<value 
optimized out>, base_modidx=0x82cfccc,
     main_env=0x3a06c780, for_m=0x0, rn_set=0x2a77d6b8, 
post_ex_rn_set=0x0, ck=0, data=0x0, redef_modname=0x0,
     unpack_kern=1, copy_vars=0, can_save_marshal=0, eval_exp=-1, 
eval_run=<value optimized out>, all_simple=0x0,
     modidx_cache=0x0, submodule_names=0x0) at ./../src/module.c:11738
#58 0x0813ff86 in do_namespace_require (env=0x3a06c780, argc=<value 
optimized out>, argv=0xbff238f4, copy=0, etonly=0)
     at ./../src/module.c:1295
#59 0x0808a95b in scheme_do_eval (obj=0x872fae8, num_rands=1, 
rands=0xbff238f4, get_value=1) at ./../src/eval.c:2582
#60 0x0809f87f in apply_k () at ./../src/fun.c:1336
#61 0x080ab5d8 in scheme_top_level_do_worker (k=0x809f7f0 <apply_k>, 
eb=1, new_thread=0, dyn_state=0x0)
     at ./../src/fun.c:1175
#62 0x080abff8 in scheme_top_level_do (k=0x809f7f0 <apply_k>, eb=1) at 
./../src/fun.c:1088
#63 0x0806b074 in finish_cmd_line_run (fa=0x2b1c5628, repl=<value 
optimized out>)
#64 0x0806c598 in run_from_cmd_line (data=0xbff23af8)
#65 main_after_stack (data=0xbff23af8) at ./../main.c:365
#66 0x0806f0d3 in do_main_stack_setup (no_auto_statics=1, 
_main=0x806bb60 <main_after_stack>, data=0xbff23af8)
     at ./../src/salloc.c:194
#67 scheme_main_stack_setup (no_auto_statics=1, _main=0x806bb60 
<main_after_stack>, data=0xbff23af8)
     at ./../src/salloc.c:296
#68 0x0806a503 in main_after_dlls (argc=2, argv=0xbff23bb4) at 
./../main.c:302
#69 main (argc=2, argv=0xbff23bb4) at ./../main.c:278

Neil V.


Posted on the users mailing list.