Skip to content

Instantly share code, notes, and snippets.

@msantos
Created March 9, 2010 19:54
Show Gist options
  • Save msantos/327028 to your computer and use it in GitHub Desktop.
Save msantos/327028 to your computer and use it in GitHub Desktop.
%%% Crash compiling regexp on Mac OS X
%%%
%%% bin/cerl -smp -debug -smp
%%%
%%% 1> N = 612, re:compile([lists:duplicate(N, $(), lists:duplicate(N, $))]).
%%%
%%% Program received signal EXC_BAD_ACCESS, Could not access memory.
%%% Reason: KERN_PROTECTION_FAILURE at address: 0xb01d0ffc
%%% [Switching to process 7206]
%%% 0x001c04e4 in compile_branch (optionsptr=0x0, codeptr=0x0, ptrptr=0x0, errorcodeptr=0x0, firstbyteptr=0x0, reqbyteptr=0x0, bcptr=0x0, cd=0x0\
%%% , lengthptr=0x0) at pcre_compile.c:2355
%%%
%%% The backtrace is huge:
%%%
%%% <...>
%%% #1000 0x001c6008 in compile_branch (optionsptr=0xb024e400, codeptr=0xb024e3e8, ptrptr=0xb024e3ec, errorcodeptr=0xb024ed24, firstbyteptr=0xb0\
%%% 24e3d0, reqbyteptr=0xb024e3cc, bcptr=0xb024e3ac, cd=0xb024ec8c, lengthptr=0xb024e3c8) at pcre_compile.c:4901
%%% #1001 0x001c6a75 in compile_regex (options=0, oldims=0, codeptr=0xb024e694, ptrptr=0xb024e688, errorcodeptr=0xb024ed24, lookbehind=0, reset_\
%%% bracount=0, skipbytes=2, firstbyteptr=0xb024e630, reqbyteptr=0xb024e634, bcptr=0xb024e7ac, cd=0xb024ec8c, lengthptr=0xb024e6a0) at pcre_comp\
%%% ile.c:5366
%%% #1002 0x001c6008 in compile_branch (optionsptr=0xb024e800, codeptr=0xb024e7e8, ptrptr=0xb024e7ec, errorcodeptr=0xb024ed24, firstbyteptr=0xb0\
%%% 24e7d0, reqbyteptr=0xb024e7cc, bcptr=0xb024e7ac, cd=0xb024ec8c, lengthptr=0xb024e7c8) at pcre_compile.c:4901
%%% #1003 0x001c6a75 in compile_regex (options=0, oldims=0, codeptr=0xb024ea94, ptrptr=0xb024ea88, errorcodeptr=0xb024ed24, lookbehind=0, reset_\
%%% bracount=0, skipbytes=2, firstbyteptr=0xb024ea30, reqbyteptr=0xb024ea34, bcptr=0xb024ebac, cd=0xb024ec8c, lengthptr=0xb024eaa0) at pcre_comp\
%%% ile.c:5366
%%% #1004 0x001c6008 in compile_branch (optionsptr=0xb024ec00, codeptr=0xb024ebe8, ptrptr=0xb024ebec, errorcodeptr=0xb024ed24, firstbyteptr=0xb0\
%%% 24ebd0, reqbyteptr=0xb024ebcc, bcptr=0xb024ebac, cd=0xb024ec8c, lengthptr=0xb024ebc8) at pcre_compile.c:4901
%%% #1005 0x001c6a75 in compile_regex (options=0, oldims=0, codeptr=0xb024ed14, ptrptr=0xb024ed0c, errorcodeptr=0xb024ed24, lookbehind=0, reset_\
%%% bracount=0, skipbytes=0, firstbyteptr=0xb024ed30, reqbyteptr=0xb024ed2c, bcptr=0x0, cd=0xb024ec8c, lengthptr=0xb024ed34) at pcre_compile.c:5\
%%% 366
%%% #1006 0x001c7b45 in erts_pcre_compile2 (pattern=0x386020 '(' <repeats 200 times>..., options=0, errorcodeptr=0xb024fda0, errorptr=0xb024fd9c\
%%% , erroroffset=0xb024fd98, tables=0x213840 "") at pcre_compile.c:6008
%%% #1007 0x0011a9ec in re_compile_2 (A__p=0x61271c, A_1=7470745, A_2=4294967291) at beam/erl_bif_re.c:456
%%% #1008 0x0011aa72 in re_compile_1 (A__p=0x61271c, A_1=7470745) at beam/erl_bif_re.c:468
%%% #1009 0x001406fa in process_main () at beam/beam_emu.c:3048
%%% #1010 0x0008dca7 in sched_thread_func (vesdp=0x56a7d0) at beam/erl_process.c:3060
%%% #1011 0x001e3a01 in thr_wrapper (vtwd=0xbfffeedc) at common/ethread.c:475
%%% #1012 0x94a8afbd in _pthread_start ()
%%% #1013 0x94a8ae42 in thread_start ()
-module(smp).
-export([crash/0]).
crash() ->
case erlang:system_info(smp_support) of
true -> ok;
false -> error_logger:info_report([{smp, disabled}])
end,
N = 612,
re:compile([lists:duplicate(N, $(), lists:duplicate(N, $))]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment