Skip to content

A fix for "Cannot allocate memory" at macOS with CI pinning#3720

Draft
GulinSS wants to merge 4 commits intoidris-lang:mainfrom
GulinSS:issues/3719
Draft

A fix for "Cannot allocate memory" at macOS with CI pinning#3720
GulinSS wants to merge 4 commits intoidris-lang:mainfrom
GulinSS:issues/3719

Conversation

@GulinSS
Copy link
Contributor

@GulinSS GulinSS commented Jan 23, 2026

Just to track the attempt to fix of macOS readdir issue

@GulinSS GulinSS changed the title Fix #3719 A fix for https://github.com/idris-lang/Idris2/issues/3719 Jan 23, 2026
@GulinSS GulinSS changed the title A fix for https://github.com/idris-lang/Idris2/issues/3719 A fix for "Cannot allocate memory" at macOS with CI pinning Jan 23, 2026
@GulinSS GulinSS marked this pull request as draft January 23, 2026 10:44
GulinSS and others added 4 commits January 26, 2026 16:05
- Pin Node.js installation from latest to version 24 for consistency (version 24 is currently the latest)
- Pin Chez Scheme installation to specific version 10.3.0 (10.x is required by coming idris-lang#3704)
- Add pinned Racket installation via Homebrew cask to run Racket backend tests on macOS

(cherry picked from commit 0ac7e79)
@GulinSS
Copy link
Contributor Author

GulinSS commented Jan 28, 2026

An attempt to fix via using with-interrupts-disabled as a wrapper for idris2_nextDirEntry foreign calls.

let call = "((foreign-procedure" ++ callConv ++ " " ++ showB cfn ++ " ("
++ sepBy " " argTypes ++ ") " ++ retType ++ ") "
++ sepBy " " !(traverse buildArg args) ++ ")"
let builded_args = !(traverse buildArg args)
Copy link
Collaborator

@dunhamsteve dunhamsteve Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to use a scheme FFI call and do this in scheme, if we need it. Hardcoding the name here is a big fragile. (If this is just for experimenting, that's fine.) Although we would have to reconcile the other backends.

Also, I don't know if this is going to do the trick here. Wouldn't a single with-interrupts-disabled need to be wrapped around both the call to nextdir and an fetch of the errno.

If we fetched the errno within the nextDirEntry, we might be good. The question is how to return the equivalent of Either Error AnyPtr. I don't know that Idris allows returning inductive types and if we hard code assumptions about data shape, that too might be fragile - PureScript passes in constructors to accomplish this, but Idris doesn't like those types in FFI calls.

Ideally we could return Either Int (Ptr String) for nextDirEntry, but I can't think of a good way to make that happen.

One option that comes to mind is to make our own errno - create a structure that has both DirInfo * and errno in it, and a call to ask it for its errno. Return that for opendir and free it in closedir. We update its errno value inside idris2_nextDirEntry and the idris side looks up the errno from this Directory object rather than the global one. (If RefC, Javascript, etc are not concerned with this issue, they could simply look at errno to implement getDirError.)

@GulinSS
Copy link
Contributor Author

GulinSS commented Jan 28, 2026

Yeah, it is just a draft/sample of attempts over our existing CI at idris-lang/Idris2

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 this pull request may close these issues.

3 participants