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

Memory leak due to wrong main function signature #141

Open
anjalismith opened this issue Feb 20, 2023 · 0 comments
Open

Memory leak due to wrong main function signature #141

anjalismith opened this issue Feb 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@anjalismith
Copy link
Contributor

anjalismith commented Feb 20, 2023

As discussed in today's weekly meeting, we discovered that the following program causes a memory leak because the main function is missing the cin argument:

main ( cout : & Int ) -> () =
//main : &Int -> & Int -> () =
  //fun (cint : &Int) (cout : &Int)
    after 10 , (cout : & Int) <- 65
    wait (cout : & Int)

We commented out the lines of code that would make the program correctly print out the character 'A'. Currently, this program is printing output to cin.

Here's the error produced in runtests.log:

###### Testing memory-leak-main-func
stack exec sslc -- tests/memory-leak-main-func.ssl > out/memory-leak-main-func.c
sizeof(struct ssm_mm) = 4
page size 4096
pages allocated 2
objects allocated 4
objects freed 3
live objects 1
4 pools
pool   0: pages   0  block-size    16  free-blocks     0
pool   1: pages   1  block-size    64  free-blocks    63
pool   2: pages   1  block-size   256  free-blocks    16
pool   3: pages   0  block-size  1024  free-blocks     0

FAILED: 1 live objects leaked at the end
###### FAILED

It's not desirable for users to encounter a memory leak when using the wrong function signature for main, and they should be notified through a different type of error with a communicative error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant