#3694 closed defect (fixed)
Stack overflow in Modelica Parser
Reported by: | Henning Kiel | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | critical | Milestone: | 1.9.4 |
Component: | Parser | Version: | v1.9.4-dev-nightly |
Keywords: | Cc: |
Description
When loading the ScalableTestSuite I encounter a "Bus error: 10" on OSX (maybe stack overflow?)
With lldb I this backtrace. so maybe element_list
causes a too deep recursion level?
(lldb) bt * thread #2: tid = 0x4a1ded, 0x000000010004c630 libOpenModelicaRuntimeC.dylib`GC_clear_stack_inner(arg=0x0000000000000000, limit="") + 32 at misc.c:336, stop reason = EXC_BAD_ACCESS (code=2, address=0x70000028fcd8) * frame #0: 0x000000010004c630 libOpenModelicaRuntimeC.dylib`GC_clear_stack_inner(arg=0x0000000000000000, limit="") + 32 at misc.c:336 frame #1: 0x000000010004c64a libOpenModelicaRuntimeC.dylib`GC_clear_stack_inner(arg=0x0000000000000000, limit="") + 58 at misc.c:338 [...] frame #9: 0x000000010004c64a libOpenModelicaRuntimeC.dylib`GC_clear_stack_inner(arg=0x0000000000000000, limit="") + 58 at misc.c:338 frame #10: 0x0000000100048ae4 libOpenModelicaRuntimeC.dylib`GC_generic_malloc_many(lb=<unavailable>, k=<unavailable>, result=<unavailable>) + 948 at mallocx.c:443 frame #11: 0x0000000100051a02 libOpenModelicaRuntimeC.dylib`GC_malloc(bytes=<unavailable>) + 146 at thread_local_alloc.c:175 frame #12: 0x00000001010094d3 libOpenModelicaCompiler.dylib`type_specifier [inlined] mmc_alloc_words(nwords=4) + 10 at mmc_gc.h:99 frame #13: 0x00000001010094c9 libOpenModelicaCompiler.dylib`type_specifier [inlined] mmc_mk_box3(ctor=3, x0=<unavailable>, x1=0x0000000116411003) at meta_modelica_mk_box.h:26 frame #14: 0x00000001010094c9 libOpenModelicaCompiler.dylib`type_specifier(ctx=0x0000000102007800) + 713 at ModelicaParser.c:10149 frame #15: 0x0000000101008ac4 libOpenModelicaCompiler.dylib`component_clause(ctx=0x0000000102007800) + 180 at ModelicaParser.c:9556 frame #16: 0x0000000101006c4d libOpenModelicaCompiler.dylib`element(ctx=0x0000000102007800) + 1229 at ModelicaParser.c:8246 frame #17: 0x0000000101006047 libOpenModelicaCompiler.dylib`element_list(ctx=0x0000000102007800, ann=0x000070000030e8a0) + 247 at ModelicaParser.c:7610 [...] frame #4400: 0x0000000101006047 libOpenModelicaCompiler.dylib`element_list(ctx=0x0000000102007800, ann=0x000070000030e8a0) + 247 at ModelicaParser.c:7610
Change History (12)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Component: | *unknown* → Backend |
---|---|
Owner: | changed from | to
comment:3 by , 9 years ago
Component: | Backend → Parser |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:4 by , 9 years ago
Status: | assigned → accepted |
---|
I could not reproduce this using ScalableTestSuite on Linux as the minimum allowed stack size is 137 kB due to our stack overflow detection. I even tried to use -O0 -g
to compile the parser... It still handled it. With 200 000 elements in a 4MB custom-made file, I could manage to fill a 137 kB stack though.
comment:6 by , 9 years ago
I have a hopefully working fix. I don't want to change the result of parsing so close to a release. The parsing now needs to listReverse the element_list in order to be tail-recursive. I also fixed some problems with scaling in SCodeUtil/InstUtil when dealing with 100k+ elements in a list.
comment:7 by , 9 years ago
The change to Modelica.g fixed the described failure for element_list
, but now I get a stack overflow for equation_annotation_list
. Can you fix that one too?
frame #5332: 0x000000010100c807 libOpenModelicaCompiler.dylib`equation_annotation_list(ctx=0x0000000103801800, ann=0x000070000030ee80) + 951 at ModelicaParser.c:13129
What I am doing is to run a .mos with
loadFile("ScalableTestSuite/package.mo");
comment:8 by , 9 years ago
Does the current master work on OSX now? (It does on Linux using my 8MB test-file with just a huge list of elements followed by a huge list of equations followed by a huge list of algorithm statements)
comment:9 by , 9 years ago
The parser works now. So this ticket can be closed.
However, I still cannot load the library as I get the error
Error: Failed to load package ScalableTestSuite () using MODELICAPATH /Users/omc/src/libs/ScalableTestSuite:/Users/omc/src/OpenModelica/build/lib/omlibrary:/Users/omc/.openmodelica/libraries/.
comment:10 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
This is definitely a stack issue, because if I increase stack with ulimit the error occurs later.