View Issue Details

IDProjectCategoryView StatusLast Update
0000595LDMud 3.3Runtimepublic2018-01-29 21:57
Reporterpeng Assigned ToGnomi  
PriorityhighSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.3.718 
Target Version3.3.719Fixed in Version3.3.719 
Summary0000595: Crash in 718
DescriptionCrasher in 718, with FATAL.
See backtrace in appended file.
There is a custom pkg (stringcompiler) in our driver, so this is not out of the box. but since the additional efuns are not in the trace, this seems not to be the reason.
Core und binary is available, if neccesary.
TagsNo tags attached.
Attached Files
backtrace_20090115.txt (17,340 bytes)   
(gdb) bt full 
#0  0x080f1390 in fatal (fmt=0x811434c "Bad stack at F_RETURN, %ld values too low\n") at simulate.c:588
        ts = 0x8154e30 "\003"
#1  0x0809fb64 in eval_instruction (first_instruction=0xb4d16450 "\a4\030�@N\025\b", initial_sp=0x0) at interpret.c:8679
        __store_double_int_ = 0
        product = 0
        pc = (bytecode_p) 0xb4d16453 "�@N\025\b"
        fp = (svalue_t *) 0x8154e38
        sp = (svalue_t *) 0x8154e30
        num_arg = -1
        instruction = 24
        full_instr = 135614008
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154e38
        use_ap = false
#2  0x08089af0 in int_call_lambda (lsvp=0xb4d16450, num_arg=0, allowRefs=false) at interpret.c:18170
        f = 0
        def = 0
        code = "\a4\030�@N\025\b"
        p = (bytecode_p) 0xb4d16452 "\030�@N\025\b"
        min = 0
        max = 0
        i = -1261345712
        sp = (svalue_t *) 0x8154e30
        l = (lambda_t *) 0xb4d16452
#3  0x080abcc8 in v_funcall (sp=0x0, num_arg=1) at interpret.c:20451
        args = (svalue_t *) 0x8154e30
#4  0x0809740c in eval_instruction (
    first_instruction=0xb41413ae "a\001\005\017\022\002\004\025|\002*b�\v@�c|\001*\037\001�kY\037\001\0031|\003*\037\003�\020,|\004*j@\037\001\037\003\037\004>>\037\003\037\004>|\002\201*\037\001\037\003\037\004>\020A\016", initial_sp=0x0) at interpret.c:8297
        ob = (object_t *) 0x0
        pc = (bytecode_p) 0xb4141455 "c|\005*b�\vA\017�c]\037\005\030\031"
        fp = (svalue_t *) 0x8154df8
        sp = (svalue_t *) 0x8154e30
        num_arg = -1
        instruction = 446
        full_instr = 1
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154e30
        use_ap = false
#5  0x08097962 in eval_instruction (first_instruction=0xb10a340e "b\n:\n;\n<��c\0204k\abd��", initial_sp=0x0) at interpret.c:14796
        prog = (program_t *) 0xb413d094
        pc = (bytecode_p) 0xb10a3421 "c\030\031\210(\n�\001"
        fp = (svalue_t *) 0x8154df0
        sp = (svalue_t *) 0x8154df0
        num_arg = 0
        instruction = 166
        full_instr = -1273752660
        expected_stack = (svalue_t *) 0x8154df8
        ap = (svalue_t *) 0x8154df8
        use_ap = false
#6  0x080a8449 in apply_low (fun=0xb10a28ac, ob=0xb286cc38, num_arg=0, b_ign_prot=false, allowRefs=false) at interpret.c:16949
        funstart = (fun_hdr_p) 0xb10de3a8 "\002\ba\002\bb\b"
        progp = (program_t *) 0xb296bb04
        save_csp = (struct control_stack *) 0x815cbc4
        ix = 135613928
#7  0x0808a548 in int_apply (fun=0xb10a28ac, ob=0xb286cc38, num_arg=0, b_ign_prot=false, b_use_default=true) at interpret.c:17027
No locals.
#8  0x08097acb in eval_instruction (first_instruction=0xb2aa27e2 "a\004\005�", initial_sp=0x0) at interpret.c:16297
        prog = (program_t *) 0xb413d094
        pc = (bytecode_p) 0xb2aa2945 "c|\b*b\037"
        fp = (svalue_t *) 0x8154d80
        sp = (svalue_t *) 0x8154de8
        num_arg = 2
        instruction = 188
        full_instr = 5
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154de0
        use_ap = false
#9  0x08089f4d in int_call_lambda (lsvp=0x0, num_arg=3, allowRefs=false) at interpret.c:17913
        i = 3
        sp = (svalue_t *) 0x8154d10
        l = (lambda_t *) 0xacd49ca0
#10 0x080f867b in v_limited (sp=0x0, num_arg=5) at simulate.c:5278
        context = {rt = {last = 0xb4d18290, type = -2}, max_array = 0, max_mapping = 0, max_map_keys = 0, max_eval = 0, 
  max_byte = 0, max_file = 0, max_callouts = 0, use_cost = 1, eval_cost = 188019}
        argp = (svalue_t *) 0x8154cf0
        vec = (vector_t *) 0x0
        limits = {rt = {last = 0x18, type = 1}, max_array = 0, max_mapping = 0, max_map_keys = 0, max_eval = 3000000, 
  max_byte = 0, max_file = 0, max_callouts = 0, use_cost = 0, eval_cost = -1261341048}
        cl_args = 3
#11 0x0809740c in eval_instruction (first_instruction=0xb2aa2972 "a\003\004\037", initial_sp=0x0) at interpret.c:8297
        ob = (object_t *) 0x0
        pc = (bytecode_p) 0xb2aa29e6 "c\a5cwF*b\n\001\037\004\017\017C+\n%+\037\004+d��"
        fp = (svalue_t *) 0x8154ca0
        sp = (svalue_t *) 0x8154d10
        num_arg = -1
        instruction = 454
        full_instr = 1
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154cf0
        use_ap = false
#12 0x080a82e0 in apply_low (fun=0xb422f00c, ob=0xb2a9f26c, num_arg=3, b_ign_prot=false, allowRefs=false) at interpret.c:16836
        funstart = (fun_hdr_p) 0xb2aa2970 "\003\005a\003\004\037"
        progp = (program_t *) 0xb2aa25fc
        save_csp = (struct control_stack *) 0x815caf8
        ix = 8304
#13 0x0808a548 in int_apply (fun=0xb422f00c, ob=0xb2a9f26c, num_arg=3, b_ign_prot=false, b_use_default=true) at interpret.c:17027
No locals.
#14 0x08097acb in eval_instruction (first_instruction=0xac8ea67f "b�", initial_sp=0x0) at interpret.c:16297
        prog = (program_t *) 0x8081d1e
        pc = (bytecode_p) 0xb420a7fa "c]�\020"
        fp = (svalue_t *) 0x8154c50
        sp = (svalue_t *) 0x8154cb0
        num_arg = 5
        instruction = 188
        full_instr = 3
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154c90
        use_ap = false
#15 0x08089cf8 in int_call_lambda (lsvp=0x0, num_arg=135613504, allowRefs=false) at interpret.c:18170
        i = 0
        num_arg = -1399937411
        funstart = (fun_hdr_p) 0xac8ea67d ""
        sp = (svalue_t *) 0x8154c40
        l = (lambda_t *) 0xac8ea67d
#16 0x080f867b in v_limited (sp=0x0, num_arg=2) at simulate.c:5278
        context = {rt = {last = 0xb4d189a0, type = -2}, max_array = 5000, max_mapping = 0, max_map_keys = 15000, 
  max_eval = 3008894, max_byte = 50000, max_file = 50000, max_callouts = 0, use_cost = 0, eval_cost = 9355}
        argp = (svalue_t *) 0x8154c38
        vec = (vector_t *) 0x0
        limits = {rt = {last = 0x8130370, type = -1399937428}, max_array = 0, max_mapping = 0, max_map_keys = 0, max_eval = 0, 
  max_byte = 0, max_file = 0, max_callouts = 0, use_cost = 1, eval_cost = -1261337848}
        cl_args = 0
#17 0x0809740c in eval_instruction (first_instruction=0xb420a902 "\f\024\f\033\037", initial_sp=0x0) at interpret.c:8297
        ob = (object_t *) 0x0
        pc = (bytecode_p) 0xb420a87f "c]\031"
        fp = (svalue_t *) 0x8154c28
        sp = (svalue_t *) 0x8154c38
        num_arg = -1
        instruction = 454
        full_instr = 1
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154c38
        use_ap = false
#18 0x080a8449 in apply_low (fun=0xb4414938, ob=0xb420bc68, num_arg=1, b_ign_prot=true, allowRefs=false) at interpret.c:16949
        funstart = (fun_hdr_p) 0x0
        progp = (program_t *) 0xb4206014
        save_csp = (struct control_stack *) 0xb4d188c4
        ix = 135613464
#19 0x0808a548 in int_apply (fun=0xb4414938, ob=0xb420bc68, num_arg=1, b_ign_prot=true, b_use_default=false) at interpret.c:17027
No locals.
#20 0x0808ac27 in sapply_int (fun=0xb4414938, ob=0xb420bc68, num_arg=1, b_find_static=true, b_use_default=false)
    at interpret.c:17188
        expected_sp = (svalue_t *) 0x8154c10
#21 0x0808b1aa in apply_master_ob (fun=0xb4414938, num_arg=1, external=true) at interpret.c:17491
        eval_cost_reserve = 2048
        reserve_used = false
        error_recovery_info = {rt = {last = 0xb4d1a1f0, type = 2}, flags = 1136477056, con = {text = {{__jmpbuf = {135613464, 
          136207904, -1261335900, -1261335960, -1261336208, 134787286}, __mask_was_saved = 0, __saved_mask = {__val = {3033631220, 
            1140078756, 13639, 1139776825, 1, 65536, 0 <repeats 26 times>}}}}}}
        save_sp = (svalue_t *) 0x8154c18
        save_csp = (struct control_stack *) 0x815c9a4
        result = (svalue_t *) 0x0
#22 0x080f152a in fatal (fmt=0x8154c18 "\003") at simulate.c:643
        ts = 0x81e5e20 "2009.01.15 22:03:19"
#23 0x0809fb64 in eval_instruction (first_instruction=0xb4d19030 "\a4\030� L\025\b", initial_sp=0x0) at interpret.c:8679
        __store_double_int_ = -1303115628
        product = 0
        pc = (bytecode_p) 0xb4d19033 "� L\025\b"
        fp = (svalue_t *) 0x8154c18
        sp = (svalue_t *) 0x8154c10
        num_arg = -1
        instruction = 24
        full_instr = 135613464
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154c18
        use_ap = false
#24 0x08089af0 in int_call_lambda (lsvp=0xb4d19030, num_arg=0, allowRefs=false) at interpret.c:18170
        f = 0
        def = 0
        code = "\a4\030� L\025\b"
        p = (bytecode_p) 0xb4d19032 "\030� L\025\b"
        min = 0
        max = 0
        i = -1261334480
        sp = (svalue_t *) 0x8154c10
        l = (lambda_t *) 0xb4d19032
#25 0x080abcc8 in v_funcall (sp=0x0, num_arg=1) at interpret.c:20451
        args = (svalue_t *) 0x8154c10
#26 0x0809740c in eval_instruction (
    first_instruction=0xb41413ae "a\001\005\017\022\002\004\025|\002*b�\v@�c|\001*\037\001�kY\037\001\0031|\003*\037\003�\020,|\004*j@\037\001\037\003\037\004>>\037\003\037\004>|\002\201*\037\001\037\003\037\004>\020A\016", initial_sp=0x0) at interpret.c:8297
        ob = (object_t *) 0x0
        pc = (bytecode_p) 0xb4141455 "c|\005*b�\vA\017�c]\037\005\030\031"
        fp = (svalue_t *) 0x8154bd8
        sp = (svalue_t *) 0x8154c10
        num_arg = -1
        instruction = 446
        full_instr = 1
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154c10
        use_ap = false
#27 0x08097962 in eval_instruction (first_instruction=0xb10a340e "b\n:\n;\n<��c\0204k\abd��", initial_sp=0x0) at interpret.c:14796
        prog = (program_t *) 0xb413d094
        pc = (bytecode_p) 0xb10a3421 "c\030\031\210(\n�\001"
        fp = (svalue_t *) 0x8154bd0
        sp = (svalue_t *) 0x8154bd0
        num_arg = 0
        instruction = 166
        full_instr = -1273752660
        expected_stack = (svalue_t *) 0x8154bd8
        ap = (svalue_t *) 0x8154bd8
        use_ap = false
#28 0x080a8449 in apply_low (fun=0xb10a28ac, ob=0xac8c6040, num_arg=0, b_ign_prot=false, allowRefs=false) at interpret.c:16949
        funstart = (fun_hdr_p) 0x81e6c40 "secure/master"
        progp = (program_t *) 0xb29e9e10
        save_csp = (struct control_stack *) 0xb4d19bb8
        ix = 135613384
#29 0x0808a548 in int_apply (fun=0xb10a28ac, ob=0xac8c6040, num_arg=0, b_ign_prot=false, b_use_default=true) at interpret.c:17027
No locals.
#30 0x08097acb in eval_instruction (first_instruction=0xb2aa27e2 "a\004\005�", initial_sp=0x0) at interpret.c:16297
        prog = (program_t *) 0xb413d094
        pc = (bytecode_p) 0xb2aa2945 "c|\b*b\037"
        fp = (svalue_t *) 0x8154b60
        sp = (svalue_t *) 0x8154bc8
        num_arg = 2
        instruction = 188
        full_instr = 5
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154bc0
        use_ap = false
#31 0x08089f4d in int_call_lambda (lsvp=0x0, num_arg=3, allowRefs=false) at interpret.c:17913
        i = 3
        sp = (svalue_t *) 0x8154af0
        l = (lambda_t *) 0xacf16320
#32 0x080f867b in v_limited (sp=0x0, num_arg=5) at simulate.c:5278
        context = {rt = {last = 0xb4d1b540, type = -2}, max_array = 5000, max_mapping = 0, max_map_keys = 15000, 
  max_eval = 1500000, max_byte = 50000, max_file = 50000, max_callouts = 0, use_cost = -100, eval_cost = 8894}
        argp = (svalue_t *) 0x8154ad0
        vec = (vector_t *) 0x0
        limits = {rt = {last = 0x18, type = 1}, max_array = 5000, max_mapping = 0, max_map_keys = 15000, max_eval = 3000000, 
  max_byte = 50000, max_file = 50000, max_callouts = 0, use_cost = 0, eval_cost = -1261329816}
        cl_args = 3
#33 0x0809740c in eval_instruction (first_instruction=0xb2aa2972 "a\003\004\037", initial_sp=0x0) at interpret.c:8297
        ob = (object_t *) 0x0
        pc = (bytecode_p) 0xb2aa29e6 "c\a5cwF*b\n\001\037\004\017\017C+\n%+\037\004+d��"
        fp = (svalue_t *) 0x8154a80
        sp = (svalue_t *) 0x8154af0
        num_arg = -1
        instruction = 454
        full_instr = 1
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154ad0
        use_ap = false
#34 0x080a8449 in apply_low (fun=0xb422f00c, ob=0xb2a9f26c, num_arg=1, b_ign_prot=false, allowRefs=false) at interpret.c:16949
        funstart = (fun_hdr_p) 0x81e6c40 "secure/master"
        progp = (program_t *) 0xb2aa25fc
        save_csp = (struct control_stack *) 0xb4d1a838
        ix = 135613112
#35 0x0808a548 in int_apply (fun=0xb422f00c, ob=0xb2a9f26c, num_arg=1, b_ign_prot=false, b_use_default=true) at interpret.c:17027
No locals.
#36 0x08097acb in eval_instruction (first_instruction=0xb2bc7576 "a", initial_sp=0x0) at interpret.c:16297
        prog = (program_t *) 0xb413d094
        pc = (bytecode_p) 0xb2bc7729 "c]�k\vb\n\225\022\005d��"
        fp = (svalue_t *) 0x8154a48
        sp = (svalue_t *) 0x8154a80
        num_arg = 3
        instruction = 188
        full_instr = 3
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154a70
        use_ap = false
#37 0x080a8449 in apply_low (fun=0xb4218644, ob=0xacad9a48, num_arg=0, b_ign_prot=false, allowRefs=false) at interpret.c:16949
        funstart = (fun_hdr_p) 0x6f2f6c6f <Address 0x6f2f6c6f out of bounds>
        progp = (program_t *) 0xb2a0b05c
        save_csp = (struct control_stack *) 0x6c726576
        ix = 135613024
#38 0x0808a548 in int_apply (fun=0xb4218644, ob=0xacad9a48, num_arg=0, b_ign_prot=false, b_use_default=true) at interpret.c:17027
No locals.
#39 0x08097acb in eval_instruction (first_instruction=0xb42095ce "b\037", initial_sp=0x0) at interpret.c:16297
        prog = (program_t *) 0xacad9a48
        pc = (bytecode_p) 0xb42095dc "c]\031"
        fp = (svalue_t *) 0x8154a28
        sp = (svalue_t *) 0x8154a40
        num_arg = 2
        instruction = 188
        full_instr = 5
        expected_stack = (svalue_t *) 0x0
        ap = (svalue_t *) 0x8154a38
        use_ap = false
#40 0x080a8449 in apply_low (fun=0xb440d854, ob=0xb420bc68, num_arg=2, b_ign_prot=true, allowRefs=false) at interpret.c:16949
        funstart = (fun_hdr_p) 0x2 <Address 0x2 out of bounds>
        progp = (program_t *) 0xb4206014
        save_csp = (struct control_stack *) 0xacad9a48
        ix = 135612968
#41 0x0808a548 in int_apply (fun=0xb440d854, ob=0xb420bc68, num_arg=2, b_ign_prot=true, b_use_default=false) at interpret.c:17027
No locals.
#42 0x0808ac27 in sapply_int (fun=0xb440d854, ob=0xb420bc68, num_arg=2, b_find_static=true, b_use_default=false)
    at interpret.c:17188
        expected_sp = (svalue_t *) 0x8154a20
#43 0x0808b1aa in apply_master_ob (fun=0xb440d854, num_arg=2, external=true) at interpret.c:17491
        eval_cost_reserve = 2048
        reserve_used = false
        error_recovery_info = {rt = {last = 0x81e6b80, type = 2}, flags = 0, con = {text = {{__jmpbuf = {-1398183788, 135612976, 
          -1397908920, -1261324792, -1261325040, 134787286}, __mask_was_saved = 0, __saved_mask = {__val = {3033642584, 134633702, 
            6, 2902374584, 4294967295, 144, 2968705080, 3021216620, 0, 0, 2904568100, 0, 0, 0, 0, 16777216, 134236760, 2896783689, 
            2896783684, 2896783688, 12, 0, 0, 0, 4294967291, 0, 135613072, 1, 2901228248, 2978177744, 4294967295, 4294967295}}}}}}
        save_sp = (svalue_t *) 0x8154a30
        save_csp = (struct control_stack *) 0x815c784
        result = (svalue_t *) 0x0
#44 0x08062435 in remove_interactive (ob=0xacad9a48, force=false) at comm.c:3552
        remaining = (string_t *) 0x0
        numRemaining = 135612976
        save = (object_t *) 0x0
        i = 11
        interactive = (interactive_t *) 0xaca96894
        curobj_save = (object_t *) 0x0
        save_privilege = 0
#45 0x08067ac5 in get_message (buff=0xb4d1bc90 "ende") at comm.c:2539
        erqp = (svalue_t *) 0xaca96894
        ob = (object_t *) 0xad130980
        user = (wiz_list_t *) 0xffffffff
        num_arg = 0
        keep_handle = 177
        msglen = 14
        rest = -1
        handle = 11
        rp = 0x43fac5a0 "\204(��"
        l = -1325266508
        nfds = 13
        res = 0
        twait = 1
        retries = -1
        addr = {sin_family = 20425, sin_port = 2053, sin_addr = {s_addr = 0}, sin_zero = "���C\001\000\000"}
        length = 16
        timeout = {tv_sec = 0, tv_usec = 898000}
        readfds = {fds_bits = {6144, 0 <repeats 31 times>}}
        writefds = {fds_bits = {0 <repeats 32 times>}}
        NextCmdGiver = -1
        CmdsGiven = 0
        i = 11
        ip = (interactive_t *) 0xaca96894
        exceptfds = {fds_bits = {-1321398588, 0, -1261323480, 0, -1261323472, -1261323120, -1261323400, 134539017, 135500444, 
    -1261323440, 1, -1261323456, 1139890882, 135612960, 69136, -1271033952, -1321398588, 0, -1261323448, 16777218, 136211328, -1, 
    -1397908920, 0, 0, 0, 1139886418, 135194048, 0, -1384541752, -1261323400, 134565564}}
#46 0x08055cde in backend () at backend.c:604
        buff = "ende\000uch\000s tony\000rau hier\000ny\000entlich :)\000im echten\000gs funktioniert jedenfalls noch\000s?!\000e phase erinnern *G*\000ch ich den artikel am brett doch besser\000+send +send.href +send.hint +send.xch_cmd +send.xch_hi"...
        prevent_object_cleanup = false
#47 0x080b7e2c in main (argc=21, argv=0xb4d1d6d4) at main.c:625
        tmp = 0x1 <Address 0x1 out of bounds>
        i = 0
        set = {__val = {8192, 0 <repeats 31 times>}}
        rc = 0
        
backtrace_20090115.txt (17,340 bytes)   
config.h (20,521 bytes)
machine.h (13,740 bytes)
Makefile (26,371 bytes)   
# TODO: Add some of the symbols in here to configure
# These lines are needed on some machines.
MAKE=make
SHELL=/bin/sh
INSTALL=/usr/bin/install -c
mkinstalldirs=$(SHELL) ./mkinstalldirs
#
CC=gcc -std=gnu99
CC_FOR_BUILD=$(CC)
#
YACC = bison -y
YACCTAB = y.tab.
#
RM = rm -f
MV = mv
CP = cp
#
# some standard stuff...
prefix= /mud
exec_prefix= ${prefix}
#
#
# Set MUD_LIB to the directory which contains the mud data.
MUD_LIB = /mud/mudlib
# Set MUD_LIB_INCLUDE to the directory where the driver include files
# shall live.
MUD_LIB_INCLUDE = ${prefix}/include
#
# Set BINDIR to the directory where you want to install the executables.
BINDIR = ${exec_prefix}/bin
#
# Set ERQ_DIR to directory which contains the stuff which ERQ can
# execute (hopefully) savely. Was formerly defined in config.h!
ERQ_DIR= /mud/erq
#
# Set MANDIR to the directory where to install the manpages.
MANDIR= ${prefix}/share/man
#
# Typical profiling, warning and optimizing options.
#   -p -DMARK: together they enable customized profiling of VM instructions.
#              MARK needs to be defined to a statement taking the
#              instruction code as parameter; additionally interpret.c will
#              #include "profile.h" for additional custom declarations.
#
#   Additional profiling can be activated in config.h .
#PROFIL=-pg -DMARK
#PROFIL=-pg
PROFIL=

# Enable warnings from the compiler, if wanted.
NO_WARN= # no warning options - will work with all compilers :-)
GCC_WARN= -Wall -Wshadow -Wparentheses # gcc settings
CFG_WARN=  -Wall -Wparentheses -Wshadow # Warn options discovered by configure

WARN= $(CFG_WARN)


# Optimization and source level debugging options.
# adding a -fomit-frame-pointer on the NeXT (gcc version 1.93 (68k, MIT syntax))
# will corrupt the driver.

HIGH_OPTIMIZE = -O4 -fomit-frame-pointer  -g # high optimization
MED_OPTIMIZE= -O2 -g # medium optimization
LOW_OPTIMIZE = -O -g # minimal optimization
NO_OPTIMIZE= -g # no optimization; for frequent recompilations.

OPTIMIZE= $(MED_OPTIMIZE)

#
# Debugging options:
#   Debugging options should be set in config.h to guarantee a clean
#   recompile.
#DEBUG = -DDEBUG # -DDEBUG_TELNET
DEBUG=

# Flags for compiling the SFMT random number generator.
SFMT_FLAGS = -fno-strict-aliasing
# for machines with sse2 support you may use:
#SFMT_FLAGS = -msse2 -fno-strict-aliasing -DHAVE_SSE2=1
# for machines with altivec support you may use:
#SFMT_FLAGS = -faltivec -fno-strict-aliasing -DHAVE_ALTIVEC=1

#
MPATH=-DMUD_LIB='"$(MUD_LIB)"' -DBINDIR='"$(BINDIR)"' -DERQ_DIR='"$(ERQ_DIR)"'
#
CFLAGS= -I/usr/include/mysql  $(OPTIMIZE) $(DEBUG) $(WARN) $(MPATH) $(PROFIL)
#
LIBS=-lnsl -lm  -lcrypt -lidn  -lgnutls -lpcre -lmysqlclient -L/lib -lsqlite3 -lz
#
LDFLAGS=$(PROFIL) 
#
#Note that, if you use smalloc with SBRK_OK(which is the default), and
#don't link statically, it could happen that the system malloc is linked
#along with the one from smalloc; this combination is bound to cause crashes.
MFLAGS = "BINDIR=$(BINDIR)" "MUD_LIB=$(MUD_LIB)"
#
SRC = access_check.c actions.c array.c backend.c bitstrings.c call_out.c \
      closure.c comm.c \
      dumpstat.c ed.c efuns.c files.c gcollect.c hash.c heartbeat.c \
      interpret.c \
      lex.c main.c mapping.c md5.c mempools.c mregex.c mstrings.c object.c \
      otable.c\
      parser.c parse.c pkg-alists.c pgk-iksemel.c pkg-idna.c \
      pkg-mccp.c pkg-mysql.c pkg-pcre.c \
      pkg-pgsql.c pkg-sqlite.c pkg-stringcompiler.c pkg-tls.c \
      ptmalloc.c port.c ptrtable.c \
      random.c regexp.c sha1.c simulate.c simul_efun.c stdstrings.c \
      strfuns.c structs.c sprintf.c swap.c wiz_list.c xalloc.c 
OBJ = access_check.o actions.o array.o backend.o bitstrings.o call_out.o \
      closure.o comm.o \
      dumpstat.o ed.o efuns.o files.o gcollect.o hash.o heartbeat.o \
      interpret.o \
      lex.o main.o mapping.o md5.o mempools.o mregex.o mstrings.o object.o \
      otable.o \
      parser.o parse.o pkg-alists.o pkg-iksemel.o pkg-idna.o \
      pkg-mccp.o pkg-mysql.o pkg-pcre.o \
      pkg-pgsql.o pkg-sqlite.o pkg-stringcompiler.o pkg-tls.o \
      ptmalloc.o port.o ptrtable.o \
      random.o regexp.o sha1.o simulate.o simul_efun.o stdstrings.o \
      strfuns.o structs.o sprintf.o swap.o wiz_list.o xalloc.o  

all: make-patchlevel ldmud

ldmud: $(OBJ)
	$(CC) $(OPTIMIZE) $(LDFLAGS) $(OBJ) -o $@ $(LIBS)

docs: ldmud
	-help2man --name=ldmud -N --help-option=--longhelp --include=ldmud-man.txt --output=../doc/man/ldmud.1 ./ldmud
	
install-all: install-driver install-headers install-utils

install: install-driver
	@echo "To install header files, use 'make install-headers'."
	@echo "To install utility programs (incl. erq), use 'make install-utils'."
	@echo "To install everything in one go, use 'make install-all'."

install-driver: ldmud docs
	$(mkinstalldirs) $(BINDIR) $(MANDIR)/man1
	$(INSTALL) -c ldmud $(BINDIR)/ldmud
	$(INSTALL) -c ../doc/man/ldmud.1 $(MANDIR)/man1/ldmud.1

install-headers: 
	$(mkinstalldirs) $(MUD_LIB_INCLUDE)
	$(INSTALL) -c ../mudlib/sys/* $(MUD_LIB_INCLUDE)

install-utils:
	(cd util; $(MAKE) $(MFLAGS) install)

utils:
	(cd util; $(MAKE) $(MFLAGS))

lint: *.c
	lint *.c

clean:
	$(RM) $(YACCTAB)h $(YACCTAB)c make_func.c *.o mkfunc$(EXEEXT)
	$(RM) dftables$(EXEEXT) pcre/chartables.c
	$(RM) stdstrings.c stdstrings.h
	$(RM) efun_defs.c instrs.h lang.y lang.h lang.c y.output tags TAGS
	$(RM) ldmud core mudlib/core mudlib/debug.log lpmud.log
	(cd util ; echo "Cleaning in util." ; $(MAKE) clean)

distclean: clean
	$(RM) ldmud config.status machine.h Makefile config.cache config.log
	$(RM) config.h config.status config.status.old
	$(RM) util/Makefile util/erq/Makefile util/xerq/Makefile util/indent/Makefile

tags: $(SRC)
	ctags $(SRC)

TAGS: $(SRC)
	etags $(SRC)

patchlevel.h : make-patchlevel

make-patchlevel:
	./mk-patchlevel.sh

make_func.c: make_func.y
	$(YACC) make_func.y
	$(MV) $(YACCTAB)c make_func.c
	

hash_b.o : hash.h
	$(CC_FOR_BUILD) $(CFLAGS) -c hash.c -o hash_b.o

mkfunc.o : make_func.c ../mudlib/sys/driver_hook.h hash.h exec.h \
    my-alloca.h driver.h bytecode.h typedefs.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h
	$(CC_FOR_BUILD) $(CFLAGS) -c mkfunc.c

mkfunc$(EXEEXT): mkfunc.o hash_b.o exec.h
	$(CC_FOR_BUILD) $(OPTIMIZE) $(LDFLAGS) mkfunc.o hash_b.o -o mkfunc$(EXEEXT)

dftables.o : pcre/dftables.c pcre/maketables.c pcre/config.h
	$(CC_FOR_BUILD) $(CFLAGS) -c pcre/dftables.c -o dftables.o

dftables$(EXEEXT) : dftables.o
	$(CC_FOR_BUILD) $(OPTIMIZE) $(LDFLAGS) dftables.o -o dftables$(EXEEXT)

lang.y: mkfunc$(EXEEXT) prolang.y config.h
	$(RM) lang.y
	./mkfunc$(EXEEXT) lang

efun_defs.c instrs.h: func_spec mkfunc$(EXEEXT) config.h machine.h
	$(RM) instrs.h
	$(RM) efun_defs.c
	./mkfunc$(EXEEXT) instrs

stdstrings.c stdstrings.h: string_spec mkfunc$(EXEEXT) config.h machine.h
	$(RM) stdstrings.c
	$(RM) stdstrings.h
	./mkfunc$(EXEEXT) strings

lang.c lang.h: lang.y
	$(YACC) -d -v lang.y
	$(MV) $(YACCTAB)c lang.c
	
	$(MV) $(YACCTAB)h lang.h

pcre/chartables.c : dftables$(EXEEXT)
	./dftables$(EXEEXT) pcre/chartables.c

random.o : random.c config.h driver.h
	$(CC) $(CFLAGS) $(SFMT_FLAGS) -c random.c -o random.o

#--------------------------------------------------------
# The dependency generation uses the program 'mkdepend' and assumes GNUmake.

# Generated source files (overlaps with of SRC) which need to be
# present for mkdepend to work.
    GENSRC = make_func.c stdstrings.c lang.c instrs.h pcre/chartables.c

# Macros for MkDepend:
    SKELETON = $(SRC) mkfunc.c pcre/dftables.c
    EXCEPT = -x efun_defs.c
    SELECT = -S instrs.h -S stdstrings.h -S make_func.c -S lang.c -S lang.h -S efun_defs.c

depend: $(SRC) $(GENSRC)
	@$(SHELL) -ec "if type mkdepend > /dev/null 2>&1; then \
          echo Updating dependencies.; \
          mkdepend $(SKELETON) -I. -Ipcre -Iptmalloc $(EXCEPT) -m -p .c:%n.o -fMakefile; \
          mkdepend $(SKELETON) -I. -Ipcre -Iptmalloc $(EXCEPT) $(SELECT) -m -p .c:%n.o -fMakefile; \
          echo Updating dependencies in Makefile.in.; \
          mkdepend $(SKELETON) -I. -Ipcre -Iptmalloc $(EXCEPT) -m -p .c:%n.o -fMakefile.in; \
          mkdepend $(SKELETON) -I. -Ipcre -Iptmalloc $(EXCEPT) $(SELECT) -m -p .c:%n.o -fMakefile.in; \
        else\
          echo mkdepend utility not available.; \
        fi"

.PHONY dependall: depend depend-generic

depend-generic: $(SRC) $(GENSRC)
	@$(SHELL) -ec "if type mkdepend > /dev/null 2>&1; then \
          echo Updating dependencies in hosts/be/Makefile.; \
          mkdepend $(SKELETON) -I. -Ipcre -Iptmalloc $(EXCEPT) -m -p .c:$$\(OBJ\)/%n.o -fhosts/be/Makefile; \
          mkdepend $(SKELETON) -I. -Ipcre -Iptmalloc $(EXCEPT) $(SELECT) -m -p .c:$$\(OBJ\)/%n.o -fhosts/be/Makefile; \
        else\
          echo mkdepend utility not available.; \
        fi"


#--------------------------------------------------------
# Dependencies, manual and automatic.

# --- DO NOT MODIFY THIS LINE -- AUTO-DEPENDS FOLLOW ---
access_check.o : xalloc.h filestat.h comm.h access_check.h driver.h \
    svalue.h strfuns.h pkg-tls.h simulate.h typedefs.h config.h port.h \
    sent.h bytecode.h hosts/unix.h hosts/be/be.h machine.h

actions.o : ../mudlib/sys/driver_hook.h ../mudlib/sys/commands.h xalloc.h \
    wiz_list.h svalue.h simulate.h sent.h stdstrings.h object.h mstrings.h \
    mapping.h interpret.h efuns.h dumpstat.h comm.h closure.h backend.h \
    array.h actions.h my-alloca.h typedefs.h driver.h strfuns.h bytecode.h \
    hash.h pkg-tls.h main.h port.h config.h hosts/unix.h hosts/be/be.h \
    machine.h

array.o : i-svalue_cmp.h xalloc.h wiz_list.h swap.h svalue.h simulate.h \
    stdstrings.h object.h mstrings.h mempools.h mapping.h main.h \
    interpret.h closure.h backend.h array.h my-alloca.h typedefs.h driver.h \
    strfuns.h sent.h bytecode.h hash.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

backend.o : ../mudlib/sys/debug_message.h ../mudlib/sys/driver_hook.h \
    i-eval_cost.h xalloc.h wiz_list.h swap.h svalue.h stdstrings.h \
    simulate.h random.h otable.h object.h mstrings.h mregex.h mapping.h \
    main.h lex.h interpret.h heartbeat.h gcollect.h filestat.h exec.h ed.h \
    comm.h closure.h call_out.h array.h actions.h backend.h my-alloca.h \
    typedefs.h driver.h strfuns.h sent.h bytecode.h hash.h pkg-tls.h port.h \
    config.h hosts/unix.h hosts/be/be.h machine.h

bitstrings.o : xalloc.h svalue.h simulate.h mstrings.h interpret.h \
    bitstrings.h typedefs.h driver.h strfuns.h sent.h bytecode.h hash.h \
    backend.h port.h config.h main.h hosts/unix.h hosts/be/be.h machine.h

call_out.o : ../mudlib/sys/debug_info.h i-eval_cost.h xalloc.h wiz_list.h \
    swap.h svalue.h strfuns.h stdstrings.h simulate.h object.h mstrings.h \
    main.h interpret.h gcollect.h exec.h comm.h closure.h backend.h array.h \
    actions.h call_out.h typedefs.h driver.h sent.h bytecode.h hash.h \
    pkg-tls.h port.h config.h hosts/unix.h hosts/be/be.h machine.h

closure.o : i-svalue_cmp.h xalloc.h switch.h swap.h svalue.h structs.h \
    stdstrings.h simul_efun.h simulate.h prolang.h object.h mstrings.h \
    main.h lex.h interpret.h instrs.h exec.h backend.h array.h closure.h \
    my-alloca.h typedefs.h driver.h strfuns.h hash.h ptrtable.h sent.h \
    bytecode.h port.h config.h hosts/unix.h hosts/be/be.h machine.h

comm.o : util/erq/erq.h ../mudlib/sys/input_to.h \
    ../mudlib/sys/driver_hook.h ../mudlib/sys/comm.h i-eval_cost.h xalloc.h \
    wiz_list.h swap.h svalue.h stdstrings.h simulate.h sent.h pkg-tls.h \
    pkg-pgsql.h pkg-mccp.h object.h mstrings.h main.h interpret.h \
    gcollect.h filestat.h exec.h ed.h closure.h array.h actions.h \
    access_check.h comm.h ../mudlib/sys/telnet.h my-alloca.h typedefs.h \
    driver.h strfuns.h bytecode.h hash.h backend.h config.h port.h \
    hosts/unix.h hosts/be/be.h machine.h

dumpstat.o : xalloc.h svalue.h structs.h stdstrings.h simulate.h ptrtable.h \
    object.h mstrings.h mapping.h instrs.h filestat.h exec.h closure.h \
    array.h dumpstat.h typedefs.h driver.h strfuns.h hash.h sent.h \
    bytecode.h port.h config.h hosts/unix.h hosts/be/be.h machine.h

ed.o : ../mudlib/sys/regexp.h xalloc.h svalue.h stdstrings.h simulate.h \
    object.h mstrings.h mregex.h main.h lex.h interpret.h gcollect.h \
    filestat.h comm.h actions.h ed.h typedefs.h driver.h strfuns.h sent.h \
    bytecode.h hash.h backend.h pkg-tls.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

efuns.o : ../mudlib/sys/time.h ../mudlib/sys/strings.h \
    ../mudlib/sys/regexp.h ../mudlib/sys/objectinfo.h \
    ../mudlib/sys/driver_hook.h ../mudlib/sys/debug_info.h i-eval_cost.h \
    xalloc.h wiz_list.h svalue.h swap.h structs.h strfuns.h simulate.h \
    stdstrings.h sha1.h random.h ptrtable.h otable.h object.h mstrings.h \
    mregex.h md5.h mempools.h mapping.h main.h lex.h interpret.h \
    heartbeat.h exec.h dumpstat.h comm.h closure.h call_out.h backend.h \
    array.h actions.h efuns.h my-rusage.h my-alloca.h typedefs.h driver.h \
    hash.h sent.h bytecode.h my-stdint.h pkg-tls.h port.h config.h \
    hosts/unix.h hosts/be/be.h machine.h

files.o : ../mudlib/sys/files.h xalloc.h svalue.h stdstrings.h simulate.h \
    mstrings.h mempools.h main.h lex.h interpret.h filestat.h comm.h \
    array.h files.h my-alloca.h typedefs.h driver.h strfuns.h sent.h \
    bytecode.h hash.h backend.h pkg-tls.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

gcollect.o : ../mudlib/sys/driver_hook.h i-eval_cost.h xalloc.h wiz_list.h \
    swap.h structs.h stdstrings.h simul_efun.h simulate.h sent.h random.h \
    ptrtable.h prolang.h pkg-pgsql.h parse.h otable.h object.h mstrings.h \
    mregex.h mempools.h mapping.h main.h lex.h instrs.h interpret.h \
    heartbeat.h filestat.h ed.h comm.h closure.h call_out.h backend.h \
    array.h actions.h gcollect.h typedefs.h driver.h svalue.h strfuns.h \
    hash.h exec.h bytecode.h pkg-tls.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

hash.o : hash.h

heartbeat.o : ../mudlib/sys/debug_info.h i-eval_cost.h xalloc.h wiz_list.h \
    svalue.h strfuns.h simulate.h sent.h object.h mstrings.h interpret.h \
    gcollect.h exec.h comm.h backend.h array.h actions.h heartbeat.h \
    typedefs.h driver.h bytecode.h hash.h pkg-tls.h main.h port.h config.h \
    hosts/unix.h hosts/be/be.h machine.h

interpret.o : ../mudlib/sys/debug_info.h ../mudlib/sys/driver_hook.h \
    i-eval_cost.h xalloc.h wiz_list.h switch.h swap.h svalue.h structs.h \
    stdstrings.h simul_efun.h simulate.h prolang.h parse.h otable.h \
    object.h mstrings.h mapping.h lex.h instrs.h heartbeat.h gcollect.h \
    filestat.h exec.h efuns.h ed.h comm.h closure.h call_out.h backend.h \
    array.h actions.h interpret.h my-alloca.h typedefs.h driver.h strfuns.h \
    hash.h ptrtable.h sent.h bytecode.h pkg-tls.h main.h port.h config.h \
    hosts/unix.h hosts/be/be.h machine.h

lex.o : efun_defs.c ../mudlib/sys/driver_hook.h i-eval_cost.h xalloc.h \
    wiz_list.h svalue.h strfuns.h stdstrings.h simul_efun.h simulate.h \
    prolang.h patchlevel.h object.h mstrings.h mempools.h main.h lang.h \
    interpret.h instrs.h hash.h gcollect.h filestat.h exec.h comm.h \
    closure.h backend.h array.h lex.h my-alloca.h typedefs.h driver.h \
    ptrtable.h sent.h bytecode.h pkg-tls.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

main.o : ../mudlib/sys/regexp.h i-eval_cost.h pkg-mysql.h xalloc.h \
    wiz_list.h swap.h svalue.h stdstrings.h simul_efun.h simulate.h \
    random.h pkg-tls.h patchlevel.h otable.h object.h mstrings.h mregex.h \
    mempools.h mapping.h lex.h interpret.h gcollect.h filestat.h comm.h \
    array.h backend.h main.h my-alloca.h typedefs.h driver.h strfuns.h \
    ptrtable.h exec.h sent.h bytecode.h hash.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

mapping.o : i-svalue_cmp.h xalloc.h wiz_list.h svalue.h structs.h \
    simulate.h object.h mstrings.h main.h interpret.h gcollect.h closure.h \
    backend.h array.h mapping.h my-alloca.h typedefs.h driver.h strfuns.h \
    hash.h exec.h sent.h bytecode.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

md5.o : strfuns.h md5.h machine.h typedefs.h driver.h port.h config.h \
    hosts/unix.h hosts/be/be.h

mempools.o : ../mudlib/sys/debug_info.h xalloc.h svalue.h strfuns.h \
    simulate.h gcollect.h mempools.h driver.h typedefs.h sent.h bytecode.h \
    port.h config.h hosts/unix.h hosts/be/be.h machine.h

mregex.o : ../mudlib/sys/regexp.h ../mudlib/sys/driver_hook.h \
    ../mudlib/sys/debug_info.h xalloc.h svalue.h strfuns.h simulate.h \
    regexp.h pkg-pcre.h mstrings.h main.h interpret.h hash.h gcollect.h \
    comm.h mregex.h driver.h typedefs.h sent.h bytecode.h pcre/pcre.h \
    backend.h pkg-tls.h port.h config.h hosts/unix.h hosts/be/be.h \
    machine.h

mstrings.o : ../mudlib/sys/debug_info.h xalloc.h svalue.h strfuns.h \
    stdstrings.h simulate.h main.h hash.h gcollect.h mstrings.h driver.h \
    typedefs.h sent.h bytecode.h port.h config.h hosts/unix.h hosts/be/be.h \
    machine.h

object.o : ../mudlib/sys/inherit_list.h ../mudlib/sys/include_list.h \
    ../mudlib/sys/functionlist.h ../mudlib/sys/driver_hook.h xalloc.h \
    wiz_list.h svalue.h swap.h structs.h strfuns.h stdstrings.h \
    simul_efun.h simulate.h sent.h random.h ptrtable.h prolang.h otable.h \
    mstrings.h mempools.h mapping.h main.h lex.h instrs.h interpret.h \
    filestat.h comm.h closure.h backend.h array.h actions.h object.h \
    my-alloca.h typedefs.h driver.h ../mudlib/sys/lpctypes.h hash.h exec.h \
    bytecode.h pkg-tls.h port.h config.h hosts/unix.h hosts/be/be.h \
    machine.h

otable.o : ../mudlib/sys/debug_info.h xalloc.h svalue.h simulate.h \
    strfuns.h object.h mstrings.h hash.h gcollect.h backend.h otable.h \
    typedefs.h driver.h sent.h bytecode.h main.h port.h config.h \
    hosts/unix.h hosts/be/be.h machine.h

parse.o : xalloc.h wiz_list.h svalue.h stdstrings.h simulate.h object.h \
    mstrings.h main.h lex.h interpret.h gcollect.h array.h actions.h \
    parse.h typedefs.h driver.h strfuns.h sent.h bytecode.h hash.h \
    backend.h port.h config.h hosts/unix.h hosts/be/be.h machine.h

parser.o : lang.c ../mudlib/sys/driver_hook.h i-eval_cost.h xalloc.h \
    wiz_list.h switch.h swap.h svalue.h structs.h stdstrings.h simul_efun.h \
    simulate.h object.h mstrings.h mapping.h main.h lex.h instrs.h \
    interpret.h gcollect.h exec.h closure.h backend.h array.h prolang.h \
    my-alloca.h typedefs.h driver.h strfuns.h hash.h ptrtable.h sent.h \
    bytecode.h port.h config.h hosts/unix.h hosts/be/be.h machine.h

dftables.o : pcre/maketables.c pcre/internal.h pcre/pcre.h pcre/config.h

pkg-alists.o : i-svalue_cmp.h xalloc.h svalue.h simulate.h mstrings.h \
    main.h interpret.h array.h my-alloca.h pkg-alists.h typedefs.h driver.h \
    closure.h strfuns.h sent.h bytecode.h hash.h backend.h port.h config.h \
    hosts/unix.h hosts/be/be.h machine.h

pkg-idna.o : ../mudlib/sys/idn.h xalloc.h simulate.h mstrings.h interpret.h \
    typedefs.h pkg-idna.h driver.h svalue.h strfuns.h sent.h bytecode.h \
    hash.h backend.h port.h config.h main.h hosts/unix.h hosts/be/be.h \
    machine.h

pkg-mccp.o : ../mudlib/sys/telnet.h xalloc.h svalue.h object.h mstrings.h \
    comm.h array.h pkg-mccp.h typedefs.h driver.h strfuns.h sent.h hash.h \
    pkg-tls.h simulate.h port.h config.h bytecode.h hosts/unix.h \
    hosts/be/be.h machine.h

pkg-mysql.o : xalloc.h svalue.h stdstrings.h simulate.h mstrings.h main.h \
    instrs.h interpret.h array.h pkg-mysql.h my-alloca.h typedefs.h \
    driver.h strfuns.h sent.h bytecode.h hash.h exec.h backend.h port.h \
    config.h hosts/unix.h hosts/be/be.h machine.h

pkg-pcre.o : pcre/study.c pcre/maketables.c pcre/get.c pcre/pcre.c \
    simulate.h interpret.h pkg-pcre.h driver.h pcre/internal.h \
    pcre/chartables.c svalue.h strfuns.h sent.h bytecode.h typedefs.h \
    backend.h pcre/pcre.h port.h config.h pcre/config.h main.h hosts/unix.h \
    hosts/be/be.h machine.h

pkg-pgsql.o : ../mudlib/sys/pgsql.h xalloc.h stdstrings.h simulate.h \
    mstrings.h mapping.h main.h interpret.h instrs.h gcollect.h array.h \
    actions.h pkg-pgsql.h my-alloca.h typedefs.h driver.h svalue.h \
    strfuns.h sent.h bytecode.h hash.h backend.h exec.h port.h config.h \
    hosts/unix.h hosts/be/be.h machine.h

pkg-sqlite.o : xalloc.h stdstrings.h object.h svalue.h simulate.h \
    mstrings.h interpret.h array.h my-alloca.h typedefs.h driver.h \
    strfuns.h sent.h bytecode.h hash.h backend.h port.h config.h main.h \
    hosts/unix.h hosts/be/be.h machine.h

pkg-stringcompiler.o : xalloc.h stdstrings.h object.h svalue.h simulate.h \
    mstrings.h interpret.h array.h my-alloca.h typedefs.h driver.h \
    strfuns.h sent.h bytecode.h hash.h backend.h port.h config.h main.h \
    hosts/unix.h hosts/be/be.h machine.h

pkg-tls.o : ../mudlib/sys/tls.h xalloc.h svalue.h sha1.h object.h \
    mstrings.h main.h interpret.h comm.h array.h actions.h pkg-tls.h \
    machine.h driver.h strfuns.h typedefs.h my-stdint.h sent.h hash.h \
    bytecode.h backend.h simulate.h port.h config.h hosts/unix.h \
    hosts/be/be.h

port.o : hosts/crypt.c main.h backend.h my-rusage.h driver.h machine.h \
    typedefs.h port.h config.h hosts/unix.h hosts/be/be.h

ptmalloc.o : ptmalloc/malloc.c machine.h config.h ptmalloc/hooks.c \
    ptmalloc/arena.c ptmalloc/thread-m.h ptmalloc/malloc.h \
    ptmalloc/config.h

ptrtable.o : simulate.h mempools.h ptrtable.h driver.h svalue.h strfuns.h \
    sent.h bytecode.h typedefs.h port.h config.h hosts/unix.h hosts/be/be.h \
    machine.h

random.o : random.h driver.h port.h config.h hosts/unix.h hosts/be/be.h \
    machine.h

regexp.o : i-eval_cost.h main.h xalloc.h simulate.h regexp.h driver.h \
    interpret.h typedefs.h svalue.h strfuns.h sent.h bytecode.h pkg-pcre.h \
    port.h config.h backend.h pcre/pcre.h hosts/unix.h hosts/be/be.h \
    machine.h

sha1.o : sha1.h my-stdint.h driver.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

simul_efun.o : xalloc.h swap.h svalue.h stdstrings.h simulate.h prolang.h \
    ptrtable.h object.h mstrings.h lex.h interpret.h gcollect.h exec.h \
    array.h simul_efun.h my-alloca.h typedefs.h driver.h strfuns.h sent.h \
    bytecode.h hash.h backend.h port.h config.h main.h hosts/unix.h \
    hosts/be/be.h machine.h

simulate.o : ../mudlib/sys/rtlimits.h ../mudlib/sys/regexp.h \
    ../mudlib/sys/files.h ../mudlib/sys/driver_hook.h \
    ../mudlib/sys/debug_info.h i-eval_cost.h xalloc.h wiz_list.h svalue.h \
    swap.h structs.h strfuns.h stdstrings.h simul_efun.h sent.h prolang.h \
    pkg-sqlite.h pkg-tls.h otable.h object.h mstrings.h mregex.h mempools.h \
    mapping.h main.h lex.h heartbeat.h gcollect.h filestat.h ed.h comm.h \
    closure.h call_out.h backend.h array.h actions.h simulate.h my-alloca.h \
    typedefs.h driver.h interpret.h hash.h exec.h ptrtable.h bytecode.h \
    port.h config.h hosts/unix.h hosts/be/be.h machine.h

sprintf.o : xalloc.h swap.h svalue.h structs.h stdstrings.h simul_efun.h \
    simulate.h sent.h random.h ptrtable.h object.h mstrings.h mapping.h \
    main.h interpret.h comm.h closure.h array.h actions.h sprintf.h \
    my-alloca.h typedefs.h driver.h strfuns.h hash.h exec.h bytecode.h \
    backend.h pkg-tls.h port.h config.h hosts/unix.h hosts/be/be.h \
    machine.h

stdstrings.o : mstrings.h stdstrings.h typedefs.h driver.h hash.h port.h \
    config.h hosts/unix.h hosts/be/be.h machine.h

strfuns.o : xalloc.h svalue.h stdstrings.h simulate.h object.h mstrings.h \
    mapping.h main.h interpret.h comm.h strfuns.h my-alloca.h typedefs.h \
    driver.h sent.h bytecode.h hash.h backend.h pkg-tls.h port.h config.h \
    hosts/unix.h hosts/be/be.h machine.h

structs.o : ../mudlib/sys/struct_info.h ../mudlib/sys/debug_info.h xalloc.h \
    wiz_list.h stdstrings.h simulate.h object.h mstrings.h mapping.h main.h \
    interpret.h gcollect.h exec.h array.h structs.h driver.h \
    ../mudlib/sys/lpctypes.h svalue.h strfuns.h typedefs.h sent.h \
    bytecode.h hash.h backend.h port.h config.h hosts/unix.h hosts/be/be.h \
    machine.h

swap.o : ../mudlib/sys/debug_info.h xalloc.h wiz_list.h svalue.h structs.h \
    strfuns.h stdstrings.h simul_efun.h simulate.h random.h prolang.h \
    otable.h object.h mstrings.h mempools.h mapping.h main.h interpret.h \
    gcollect.h comm.h closure.h backend.h array.h swap.h typedefs.h \
    driver.h hash.h exec.h ptrtable.h sent.h bytecode.h pkg-tls.h port.h \
    config.h hosts/unix.h hosts/be/be.h machine.h

wiz_list.o : xalloc.h svalue.h stdstrings.h simulate.h object.h mstrings.h \
    mapping.h main.h interpret.h gcollect.h backend.h array.h \
    ../mudlib/sys/wizlist.h wiz_list.h my-alloca.h typedefs.h driver.h \
    strfuns.h sent.h bytecode.h hash.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

xalloc.o : xptmalloc.c sysmalloc.c slaballoc.c smalloc.c mstrings.h \
    object.h exec.h simulate.h interpret.h gcollect.h backend.h xalloc.h \
    driver.h ../mudlib/sys/debug_info.h ptmalloc/malloc.h svalue.h \
    stdstrings.h sysmalloc.h array.h slaballoc.h typedefs.h smalloc.h \
    hash.h sent.h bytecode.h strfuns.h main.h port.h config.h hosts/unix.h \
    hosts/be/be.h machine.h

# --- DO NOT MODIFY THIS LINE -- AUTO-DEPENDS PRECEDE ---
# --- DO NOT MODIFY THIS LINE -- SELECTED AUTO-DEPENDS FOLLOW ---
actions.o : stdstrings.h

array.o : stdstrings.h

backend.o : stdstrings.h

call_out.o : stdstrings.h

closure.o : stdstrings.h instrs.h

comm.o : stdstrings.h

dumpstat.o : stdstrings.h instrs.h

ed.o : stdstrings.h

efuns.o : stdstrings.h

files.o : stdstrings.h

gcollect.o : stdstrings.h instrs.h

interpret.o : stdstrings.h instrs.h

lex.o : efun_defs.c stdstrings.h lang.h instrs.h

main.o : stdstrings.h

mkfunc.o : make_func.c

mstrings.o : stdstrings.h

object.o : stdstrings.h instrs.h

parse.o : stdstrings.h

parser.o : lang.c stdstrings.h instrs.h

pkg-mysql.o : stdstrings.h instrs.h

pkg-pgsql.o : stdstrings.h instrs.h

pkg-sqlite.o : stdstrings.h

simul_efun.o : stdstrings.h

simulate.o : stdstrings.h

sprintf.o : stdstrings.h

stdstrings.o : stdstrings.h

strfuns.o : stdstrings.h

structs.o : stdstrings.h

swap.o : stdstrings.h

wiz_list.o : stdstrings.h

xalloc.o : stdstrings.h

# --- DO NOT MODIFY THIS LINE -- SELECTED AUTO-DEPENDS PRECEDE ---
Makefile (26,371 bytes)   
save_object_crash.diff (520 bytes)   
Index: src/object.c
===================================================================
--- src/object.c	(Revision 2490)
+++ src/object.c	(Arbeitskopie)
@@ -6906,9 +6906,9 @@
          * data pending in the save_buffer.
          */
 
-        /* free the error handler and the arguments (numarg + 1  from sp).
+        /* free the arguments (numarg from sp).
          */
-        sp = pop_n_elems(numarg + 1, sp);
+        sp = pop_n_elems(numarg, sp);
       
         sp++; /* for the result */
         if (failed)
save_object_crash.diff (520 bytes)   

Activities

peng

2009-01-15 15:37

reporter   ~0000894

Ups, forgotten to append the debug.log:

2009.01.15 22:03:18 Bad stack at F_RETURN, 1 values too low
2009.01.15 22:03:18 Current object was obj/money#1852
2009.01.15 22:03:18 Dump of the call chain:
' disconnect' in 'secure/master.c (/secure/master/connections.inc)' (' secure/master') line 270
' net_dead' in ' i/player/login.c' (' obj/jnaii#1660') line 1596
' dosave' in ' apps/dasaved.c' (' apps/dasaved') line 218
' rsave' in ' apps/dasaved.c' (' apps/dasaved') line 112
' rsave' in ' apps/dasaved.c' (' apps/dasaved') line 152
' save_item' in ' i/item.c' (' obj/money#1852') line 412
' save_object' in 'secure/simul_efun/simul_efun.c (/secure/simul_efun/save.inc)' ('secure/simul_efun/simul_efun') line 53
#'save_object for ' i/money/money.c' (' obj/money#1852')

Gnomi

2009-01-16 04:19

manager   ~0000895

Calling save_object without a filename crashes, because in this case no error handler will be put on the stack (none is needed), but afterwards save_object tries to remove the error handler from the stack. The attached patch fixes this.

Gnomi

2009-01-16 17:02

manager   ~0000910

Committed as r2498.

Issue History

Date Modified Username Field Change
2009-01-15 15:35 peng New Issue
2009-01-15 15:35 peng File Added: backtrace_20090115.txt
2009-01-15 15:37 peng Note Added: 0000894
2009-01-15 16:20 peng File Added: config.h
2009-01-15 16:21 peng File Added: machine.h
2009-01-15 16:21 peng File Added: Makefile
2009-01-16 04:15 Gnomi File Added: save_object_crash.diff
2009-01-16 04:19 Gnomi Note Added: 0000895
2009-01-16 04:19 Gnomi Assigned To => Gnomi
2009-01-16 04:19 Gnomi Priority normal => high
2009-01-16 04:19 Gnomi Reproducibility have not tried => always
2009-01-16 04:19 Gnomi Status new => assigned
2009-01-16 04:19 Gnomi Target Version => 3.3.719
2009-01-16 17:02 Gnomi Note Added: 0000910
2009-01-16 17:02 Gnomi Status assigned => resolved
2009-01-16 17:02 Gnomi Fixed in Version => 3.3.719
2009-01-16 17:02 Gnomi Resolution open => fixed
2010-11-16 09:42 Gnomi Source_changeset_attached => ldmud.git master e6ac517e
2018-01-29 18:59 Gnomi Source_changeset_attached => ldmud.git master e6ac517e
2018-01-29 21:57 Gnomi Source_changeset_attached => ldmud.git master e6ac517e