-
Notifications
You must be signed in to change notification settings - Fork 94
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 allocation bug #74
Comments
/cc me |
Just for information, this is the valgrind report before the patch:
|
Signed-off-by: pitust <[email protected]>
^ I submitted a PR to fix this |
Yeah, the PR is still open. |
As far I understand, the compiler is capable to detect the object is not used outside the current scope (i.e. the function) and perform the free before exiting (thus not using the "GC" mechanism). In this case, I think would be better to just allocate the object in the stack instead of using heap memory. |
When I compile this JavaScript program to C, it prints
0
instead of1
. This appears to be due to a memory allocation bug, where theobj
variable is freed before returning from the function:This is the compiler's output:
It might be possible to solve this problem using a garbage collector (like the Boehm garbage collector or tgc).
The text was updated successfully, but these errors were encountered: