Opened 7 years ago

Last modified 3 years ago

#5645 new bug

Sharing across functions causing space leak

Reported by: tener Owned by: Alexander.Pakhomov
Priority: normal Milestone:
Component: Compiler Version: 7.2.1
Keywords: Cc: pho@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I have two test functions in code that both have a lazy list declared like this:

  let elements = [0 .. someBigInt]

If, from main, I run both of them, the compiler decides to share this list among them. In effect the memory is exhausted.

If only one function is called, the memory used is constant and low.

The workaround is to declare on of them like this:

  let elements = [0] ++ [1 .. someBigInt]

But this is very ugly.

What worries me most is that this is very non-obvious behaviour: if the list is declared locally inside a function, the compiler shouldn't (?) share it between two functions. It feels wrong.

If one of the functions is declared in different module, this behavior disappears. Seems like CSE is not done across modules boundaries.

Another workaround (tested) is to disable CSE with -fno-cse switch. You can test it works with "make workaround". The bug can be tested with "make bug".

The compiler behaves this way across the versions. I've tested 6.12.3, 7.0.2, 7.0.3, 7.0.4, 7.2.1, 7.2.2.

My platform should be irrelevant, but for the sake of completeness:

Linux raptor 3.1.0-4-ARCH #1 SMP PREEMPT Mon Nov 7 22:47:18 CET 2011 x86_64 Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz GenuineIntel GNU/Linux

The code for reproducing is attached. Again, run it with "make bug" or simply "make".

I'm experimenting with high-performance FIFO queues. The implementation attached is quite potent, capable of processing 40M messages / second on my machine in one-producer one-consumer case.

Attachments (1)

report.7z (1.4 KB) - added by tener 7 years ago.

Download all attachments as: .zip

Change History (10)

Changed 7 years ago by tener

Attachment: report.7z added

comment:1 Changed 7 years ago by tener

Type of failure: None/UnknownRuntime performance bug

comment:2 Changed 7 years ago by igloo

Milestone: 7.6.1

thanks for the report.

comment:3 Changed 7 years ago by PHO

Cc: pho@… added

comment:4 Changed 6 years ago by igloo


comment:5 Changed 5 years ago by thoughtpolice


Moving to 7.10.1.

comment:6 Changed 5 years ago by Alexander.Pakhomov

difficulty: Unknown
Owner: set to Alexander.Pakhomov

I hope this could be done with GC modifications.

comment:7 Changed 4 years ago by thoughtpolice


Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:8 Changed 3 years ago by thoughtpolice


Milestone renamed

comment:9 Changed 3 years ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.