Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: out of memory. #5717

Closed
vicuna opened this issue Aug 3, 2012 · 12 comments
Closed

Fatal error: out of memory. #5717

vicuna opened this issue Aug 3, 2012 · 12 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Aug 3, 2012

Original bug ID: 5717
Reporter: julia
Assigned to: @damiendoligez
Status: closed (set by @xavierleroy on 2015-12-11T18:08:31Z)
Resolution: fixed
Priority: normal
Severity: major
Platform: x86-64
OS: Fedora
Version: 4.00.0
Target version: 4.00.2+dev
Category: ~DO NOT USE (was: OCaml general)
Duplicate of: #5707
Monitored by: mehdi "Richard Jones" @alainfrisch

Bug description

Coccinelle crashes when using the native code version on ocaml 4.00.0 on fedora. It does not crash with the bytecode version. It does not seem to crash on other OSes. Here are two stack traces. The runs do different things, but they
both crash in the same way.

$ COCCINELLE_HOME=. gdb --args ./spatch.opt -parse_c demos/simple.c
[...]
(gdb) bt
#0 __GI_exit (status=2) at exit.c:99
#1 0x00000000008f094a in caml_fatal_error ()
#2 0x00000000008f33f4 in caml_alloc_shr ()
#3 0x00000000008f253f in caml_oldify_one ()
#4 0x00000000008ef657 in caml_oldify_local_roots ()
#5 0x00000000008f2755 in caml_empty_minor_heap ()
#6 0x00000000008f289d in caml_minor_collection ()
#7 0x00000000008f079a in caml_garbage_collection ()
#8 0x0000000000902208 in caml_system__code_begin ()
#9 0x00000000008478a5 in camlCommon__fun_8307 () at common.ml:5611
#10 0x000000000085ae4b in camlCommon__complete_parse_info_large_4176 ()
at common.ml:5622
#11 0x0000000000705f8b in camlParse_c__fun_2895 () at parse_c.ml:242
#12 0x00000000006d7212 in camlToken_helpers__visitor_info_of_tok_1232 ()
at token_helpers.ml:374
#13 0x0000000000706149 in camlParse_c__tokens_aux_1114 () at common.ml:93
#14 0x0000000000706bf4 in camlParse_c__fun_2857 () at parse_c.ml:254
#15 0x0000000000843da8 in camlCommon__fun_6899 () at common.ml:3494
#16 0x00000000008485d8 in camlCommon__unwind_protect_1071 () at
common.ml:167
#17 0x0000000000706e46 in camlParse_c__fun_2957 () at parse_c.ml:383
#18 0x000000000084c201 in camlCommon__save_excursion_1678 () at
common.ml:1275
#19 0x0000000000709f21 in camlParse_c__init_defs_builtins_1310 ()
at parse_c.ml:796
#20 0x00000000006169b1 in camlMain__main_1248 () at ./main.ml:1115
#21 0x0000000000616c71 in camlMain__main_with_better_error_report_1274 ()
at ./main.ml:1214
#22 0x0000000000616ca0 in camlMain__fun_2260 () at ./main.ml:1227
#23 0x000000000084ba69 in camlCommon__pp_do_in_zero_box_1578 ()
at common.ml:1118
#24 0x000000000084865c in camlCommon__finalize_1075 () at common.ml:173
#25 0x00000000008536b9 in camlCommon__exn_to_real_unixexit_2862 ()
at common.ml:3622
#26 0x000000000061b2e0 in camlMain__entry () at ./main.ml:1226
#27 0x00000000005f56a9 in caml_program ()
#28 0x00000000009023e6 in caml_start_program ()
#29 0x00000000008eef59 in caml_main ()
#30 0x00000000005f494c in main ()


./spatch.opt -parse_cocci demos/simple.cocci

#0 GI_exit (status=2) at exit.c:99
#1 0x00000000008f094a in caml_fatal_error ()
#2 0x00000000008f33f4 in caml_alloc_shr ()
#3 0x00000000008f253f in caml_oldify_one ()
#4 0x00000000008ef657 in caml_oldify_local_roots ()
#5 0x00000000008f2755 in caml_empty_minor_heap ()
#6 0x00000000008f289d in caml_minor_collection ()
#7 0x00000000008f3987 in caml_alloc_string ()
#8 0x00000000008a9dc5 in camlPervasives
$5e_1102 ()
#9 0x00000000006d1b88 in camlLexer_c____ocaml_lex_string_rec_1216 ()
at lexer_c.mll:927
#10 0x00000000006d1b88 in camlLexer_c____ocaml_lex_string_rec_1216 ()
at lexer_c.mll:927
#11 0x00000000006d1b88 in camlLexer_c____ocaml_lex_string_rec_1216 ()
at lexer_c.mll:927
#12 0x00000000006d1b88 in camlLexer_c____ocaml_lex_string_rec_1216 ()
at lexer_c.mll:927
#13 0x00000000006d1b88 in camlLexer_c____ocaml_lex_string_rec_1216 ()
at lexer_c.mll:927
#14 0x00000000006d1b88 in camlLexer_c____ocaml_lex_string_rec_1216 ()
at lexer_c.mll:927
#15 0x00000000006d43a4 in camlLexer_c____ocaml_lex_token_rec_1210 ()
at lexer_c.mll:781
#16 0x00000000007060d6 in camlParse_c__tokens_aux_1114 () at parse_c.ml:235
#17 0x0000000000706bf4 in camlParse_c__fun_2857 () at parse_c.ml:254
#18 0x0000000000843da8 in camlCommon__fun_6899 () at common.ml:3494
#19 0x00000000008485d8 in camlCommon__unwind_protect_1071 () at
common.ml:167
#20 0x0000000000706e46 in camlParse_c__fun_2957 () at parse_c.ml:383
#21 0x000000000084c201 in camlCommon__save_excursion_1678 () at
common.ml:1275
#22 0x0000000000709f21 in camlParse_c__init_defs_builtins_1310 ()
at parse_c.ml:796
#23 0x00000000006169b1 in camlMain__main_1248 () at ./main.ml:1115
#24 0x0000000000616c71 in camlMain__main_with_better_error_report_1274 ()
at ./main.ml:1214
#25 0x0000000000616ca0 in camlMain__fun_2260 () at ./main.ml:1227
#26 0x000000000084ba69 in camlCommon__pp_do_in_zero_box_1578 ()
at common.ml:1118
#27 0x000000000084865c in camlCommon__finalize_1075 () at common.ml:173
#28 0x00000000008536b9 in camlCommon__exn_to_real_unixexit_2862 ()
at common.ml:3622
#29 0x000000000061b2e0 in camlMain__entry () at ./main.ml:1226
#30 0x00000000005f56a9 in caml_program ()
#31 0x00000000009023e6 in caml_start_program ()
#32 0x00000000008eef59 in caml_main ()
#33 0x00000000005f494c in main ()

Steps to reproduce

Coccinelle can be obtained from http://coccinelle.lip6.fr/distrib/coccinelle-1.0.0-rc14.tgz

To compile, do: ./configure then make opt then make install

demos is a subdirectory of coccinelle

Additional information

Information about the configuration of ocaml is here:

http://pkgs.fedoraproject.org/cgit/ocaml.git/tree/
http://git.fedorahosted.org/cgit/fedora-ocaml.git/

File attachments

@vicuna
Copy link
Author

vicuna commented Aug 5, 2012

Comment author: @damiendoligez

I've installed Fedora 17 from scratch on a new virtual machine, compile OCaml 4.00.0 with and without the Fedora patches, and failed to reproduce this bug.

@vicuna
Copy link
Author

vicuna commented Aug 5, 2012

Comment author: Richard Jones

We only see the bug on Rawhide (Fedora 18 pre-release). Can you install fedora-release-rawhide and then 'yum update' everything? I think this matters because Rawhide has different (and much newer) glibc, kernel and gcc.

@vicuna
Copy link
Author

vicuna commented Aug 5, 2012

@vicuna
Copy link
Author

vicuna commented Aug 5, 2012

Comment author: Richard Jones

The other thing that might make a difference are the C flags that all Fedora projects use. These are added by RPM so you won't get the same flags if you just checked out the OCaml sources and compiled them.

To find out what flags RPM will add, do:

rpm --eval '%{optflags}'

(This evaluates to the same as $RPM_OPT_FLAGS in the spec file)

Note these flags could differ depending on version of rpm and version of Fedora. On Rawhide currently they are:

-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic

@vicuna
Copy link
Author

vicuna commented Aug 7, 2012

Comment author: @damiendoligez

I followed the Fedora 18 update instructions. Fedora 18 has a few problems (some packages don't work, and the graphical login window doesn't appear). I switched to text mode, and compiled OCaml, menhir, and coccinelle.

I've tried compiling OCaml with and without the patches, with and without the RPM optflags. I compiled coccinelle with each version, and I still don't see the bug.

BTW, in order to compile coccinelle, I have to "make", then patch bundles/extlib/extlib-1.5.2/extHashtbl.ml, then "make" again, then "make opt".

@vicuna
Copy link
Author

vicuna commented Aug 7, 2012

Comment author: Richard Jones

I'm having my house rewired at the moment, but please leave this bug open for now and I will try to produce a more concrete reproducer or test case when I'm back online.

@vicuna
Copy link
Author

vicuna commented Sep 10, 2012

Comment author: @alainfrisch

Richard: we're trying to finalize a bug-fix release soon, and this ticket is one of the few potential blocking issues. Have you had a chance to investigate the issue?

@vicuna
Copy link
Author

vicuna commented Sep 11, 2012

Comment author: Richard Jones

No - now I'm on holiday ... I still think there is some sort of bug here, albeit impossible to reproduce reliably. Can't we miss this release and leave the bug open?

@vicuna
Copy link
Author

vicuna commented Dec 2, 2012

Comment author: vbraun

I see this bug with Fedora 18 beta and Unison-2.40.102 (unofficial update). The problem is that it allocates an astronomical amount of heap space during a GC cycle:

[vbraun@volker-desktop ~]$ strace unison-2.40
...
readlink("/proc/self/exe", "/usr/bin/unison-2.40", 256) = 20
stat("/usr/bin/unison-2.40", {st_mode=S_IFREG|0755, st_size=5033208, ...}) = 0
brk(0) = 0xee0000
brk(0xf02000) = 0xf02000
lseek(0, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
lseek(1, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
lseek(2, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
brk(0) = 0xf02000
brk(0xf26000) = 0xf26000
mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1fc5ba2000
mmap(NULL, 259407338535944192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
brk(0) = 0xf26000
brk(0x39999999a845000) = 0xf26000
mmap(NULL, 259407338536075264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f1fbdba2000
munmap(0x7f1fbdba2000, 38133760) = 0
munmap(0x7f1fc4000000, 28975104) = 0
mprotect(0x7f1fc0000000, 135168, PROT_READ|PROT_WRITE) = 0
mmap(NULL, 259407338535944192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
write(2, "Fatal error: out of memory.\n", 28Fatal error: out of memory.
) = 28
exit_group(2) = ?
+++ exited with 2 +++

gdb backtrace attached.

@vicuna
Copy link
Author

vicuna commented Dec 15, 2012

Comment author: Richard Jones

We finally got to the bottom of this. It's a duplicate of

However I do not know how to mark this bug as a duplicate.

Also it is fixed in Fedora 18 in this update:
https://admin.fedoraproject.org/updates/FEDORA-2012-20337

@vicuna
Copy link
Author

vicuna commented Dec 19, 2012

Comment author: @alainfrisch

If I understand correctly the previous note, the issue is already fixed in the trunk.

@vicuna
Copy link
Author

vicuna commented Dec 19, 2012

Comment author: @xavierleroy

Thanks, Richard, for the detective work. I'm happy to learn that this is the same issue as #5707, although it was absolutely not obvious!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants