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

crashes in iallocate #4

Open
sourcefrog opened this issue Mar 14, 2020 · 1 comment · May be fixed by #5
Open

crashes in iallocate #4

sourcefrog opened this issue Mar 14, 2020 · 1 comment · May be fixed by #5

Comments

@sourcefrog
Copy link

sourcefrog commented Mar 14, 2020

It looks like this code passes 0 as the VM argument to allocCon and that causes a crash in iallocate in current Idris.

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x180)
  * frame #0: 0x0000000100023157 example`iallocate + 100
    frame #1: 0x0000000100000f61 example`allocConF + 49
    frame #2: 0x0000000100000f20 example`idris_makeArray + 32
    frame #3: 0x000000010000a018 example`_idris_Data_46_Array_46_prim_95_makeArray + 136
    frame #4: 0x0000000100017612 example`_idris_Data_46_Array_46_IOArray_46__123_fromList_95_7_125_ + 290
    frame #5: 0x0000000100006160 example`_idris_io_95_bind + 320
    frame #6: 0x0000000100020b76 example`_idris__123_runMain_95_0_125_ + 310
    frame #7: 0x0000000100022c9e example`main + 142
    frame #8: 0x00007fff6f29a7fd libdyld.dylib`start + 1
@sourcefrog
Copy link
Author

I guess I should use https://github.com/ejconlon/ixarray or Data.IOArray anyhow, but it seems like this is the fix:

diff --git a/Array.c b/Array.c
index b36a471..17bfb54 100644
--- a/Array.c
+++ b/Array.c
@@ -3,7 +3,7 @@

 VAL idris_makeArray(int len) {
        VAL arr;
-       allocCon(arr, 0, 0, len, 0);
+       allocCon(arr, get_vm(), 0, len, 0);
        return arr;
 }

sourcefrog added a commit to sourcefrog/idris-array that referenced this issue Mar 14, 2020
Prevents null dereference crash

Fixes idris-hackers#4
@sourcefrog sourcefrog linked a pull request Mar 14, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant