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

[Bug] Duplicate Allocation Error? #672

Closed
jtenner opened this issue Jun 17, 2019 · 3 comments
Closed

[Bug] Duplicate Allocation Error? #672

jtenner opened this issue Jun 17, 2019 · 3 comments
Labels

Comments

@jtenner
Copy link
Contributor

jtenner commented Jun 17, 2019

It's hard to pinpoint exactly what the problem is, but it looks like RTrace is reporting a duplicate allocation for some reason.

describe("an error", () => {
  it("should cause a duplicate allocation", () => {
    let result = new Array<string>(0);
    let source = "1234567890";
    let buff = changetype<ArrayBuffer>(source.toUTF8());

    let len = buff.byteLength - 1;
    let ptr = changetype<usize>(buff);

    for (let i = 0; i < len; i++) {
      result.push(String.fromCharCode(<i32>load<u8>(ptr + i)));
    }
  });
});

This as-pect testing suite reproduces the error (because I needed to bootstrap the RTrace interface to get the error to report).

I can't paste the entire wat file output here, but this is it with -O3 optimization.

https://gist.github.com/jtenner/645c8edc7f0795d8ca6e225841e8114a

@jtenner jtenner changed the title [Bug] Duplication Allocation Error? [Bug] Duplicate Allocation Error? Jun 17, 2019
@dcodeIO dcodeIO added the bug label Jun 17, 2019
@dcodeIO
Copy link
Member

dcodeIO commented Jun 17, 2019

Reducing a little more

{
  let result = new Array<string>(0);
  let source = "1";
  result.push(source.charAt(0));
  result.push(source.charAt(0));
  result.push(source.charAt(0));
  result.push(source.charAt(0));
  result.push(source.charAt(0));
  // result.push(source.charAt(0));
}

leaks what appear to be backing buffers, and uncommenting the last line then leads to a "duplicate alloc".

dcodeIO added a commit that referenced this issue Jun 17, 2019
Previously realloc falsely copied the RC of the old block and missed to inform rtrace of the implicit free
@dcodeIO
Copy link
Member

dcodeIO commented Jun 17, 2019

Should be fixed by the commit above. Didn't update dist files yet.

@jtenner
Copy link
Contributor Author

jtenner commented Jun 17, 2019

Thank you!

@dcodeIO dcodeIO closed this as completed Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants