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

[CN] segfault with large global array #872

Open
peterohanley opened this issue Feb 14, 2025 · 0 comments
Open

[CN] segfault with large global array #872

peterohanley opened this issue Feb 14, 2025 · 0 comments
Labels
bug Something isn't working cn

Comments

@peterohanley
Copy link

long a[10000000] = 0;
% cn verify big.c
zsh: segmentation fault  cn verify big.c
% cat big.c 
long a[10000000] = 0;
% cn --version
git-85e538b14-dirty [2025-02-07 16:59:43 +0000]
% lldb cn
(lldb) target create "cn"
Current executable set to '/Users/guso/.opam/default/bin/cn' (arm64).
(lldb) run verify big.c
Process 41142 launched: '/Users/guso/.opam/default/bin/cn' (arm64)
Process 41142 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x16f603ff0)
    frame #0: 0x0000000199dafed8 libsystem_malloc.dylib`_nanov2_free + 4
libsystem_malloc.dylib`_nanov2_free:
->  0x199dafed8 <+4>:  stp    x24, x23, [sp, #-0x40]!
    0x199dafedc <+8>:  stp    x22, x21, [sp, #0x10]
    0x199dafee0 <+12>: stp    x20, x19, [sp, #0x20]
    0x199dafee4 <+16>: stp    x29, x30, [sp, #0x30]
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x16f603ff0)
  * frame #0: 0x0000000199dafed8 libsystem_malloc.dylib`_nanov2_free + 4
    frame #1: 0x0000000199d8fe38 libsystem_malloc.dylib`nanov2_realloc + 360
    frame #2: 0x0000000199dbbc60 libsystem_malloc.dylib`_malloc_zone_realloc + 144
    frame #3: 0x0000000199dbc47c libsystem_malloc.dylib`_realloc + 468
    frame #4: 0x0000000102140310 libgmp.10.dylib`__gmp_default_reallocate + 32
    frame #5: 0x00000001021522d8 libgmp.10.dylib`__gmpz_realloc + 68
    frame #6: 0x000000010214fd98 libgmp.10.dylib`__gmpz_n_pow_ui + 1276
    frame #7: 0x0000000100af9dc4 cn`ml_z_pow + 336
    frame #8: 0x0000000100b298f4 cn`caml_call_gc + 352
(lldb) 

Without the initialization it's just a stack overflow, looks like #778

% cn verify big.c
cn: internal error, uncaught exception:
    Stack overflow
    Raised at Stdlib__Hashtbl.find in file "hashtbl.ml", line 543, characters 17-32
    Called from C_lexer.__ocaml_lex_initial_rec in file "parsers/c/c_lexer.mll", line 618, characters 8-31
% cat big.c
long a[10000000];
@ZippeyKeys12 ZippeyKeys12 added bug Something isn't working cn labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cn
Projects
None yet
Development

No branches or pull requests

2 participants