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: smith-normal-form test failure due to bytesRequested larger than one block at limit check #126

Open
shwestrick opened this issue Sep 8, 2020 · 0 comments
Labels

Comments

@shwestrick
Copy link
Collaborator

The smith-normal-form regression test is causing a segfault.

For example, on commit dfddbd5:

[mpl/regression]$ ../build/bin/mpl smith-normal-form.sml
[mpl/regression]$ ./smith-normal-form
...
Segmentation fault (core dumped)

I looked into it a little bit, and found that the mutator is requesting too many bytes at a limit check:

[mpl/regression]$ ../build/bin/mpl -debug true -debug-runtime true -keep g smith-normal-form.sml
[mpl/regression]$ ./smith-normal-form
...
smith-normal-form: gc/garbage-collection.c:98: GC_collect: Assertion `bytesRequested + sizeof(struct HM_chunk) <= s->controls->blockSize' failed.

In gdb, the specific bytesRequested is 4831. The default block size is 4096.

If I instead run with @mpl block-size 8K --, then the test makes more progress, but eventually still exits with a segfault, this time requesting 11983 bytes.

In principle this should be impossible because mlton/backend/limit-check.fun is supposed to ensure that less than 4K bytes are requested at limit checks:

(* SAM_NOTE: I chose 512*7 because the smallest block size that we
* use is 4K, and each chunk has a chunk descriptor of some small
* size at the beginning of each chunk. To be correct, the chunk
* descriptor can be at most 512 bytes! The current runtime
* uses chunk descriptors of size much smaller than 512 bytes.
*
* TODO: This is a dirty hack. Ideally, at compile time, a block
* size should be chosen and we should pass the parameter:
* blockSize - sizeOfChunkDescriptor
*)
val maxBytesAlloc =
Bytes.- (Bytes.fromInt (512*7), Runtime.limitSlop)
in
insertCoalesce (f, maxBytesAlloc, handlesSignals)
end

Should be fun to debug 😎

@shwestrick shwestrick added the bug label Sep 8, 2020
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

1 participant