Repository navigation
Conversation
Add brain-dead support for __OpenBSD__ in the tangle of ifdefs surrounding memalign().
Araneidae
left a comment
There was a problem hiding this comment.
Thank you, this looks like a very straightforward fix. OpenBSD is quite a blast from the past for me (though I spent more time with FreeBSD)! I guess there are similar issues with FreeBSD, but I imagine you've not tried that?
| #if !defined(__APPLE__) | ||
| #if !defined(__OpenBSD__) |
There was a problem hiding this comment.
We don't need nested #if here, instead just note that __APPLE__ and __OpenBSD__ are equivalent in this context. Write this instead as
#if !(defined(__APPLE__) || defined(__OpenBSD__))
or maybe (more direct but less clear)
#if !defined(__APPLE__) && !defined(__OpenBSD__)
|
@Araneidae thanks for your response! I haven't tried FreeBSD. It's very likely to work the same as OpenBSD, as you say, but I am reluctant to add that feature without testing it. And no, I don't currently have any *BSD machines available to me besides OpenBSD 8.0. After probing a bit more, I see my standards for "Works For Me" are pretty low. It has to install to keep pip happy installing cocotb. I have my doubts that my tests involving cocotb actually pull in cothread. If I simply I don't know if I'm qualified to debug this. Any hints? |
|
Thank you, that looks very straightforward. I was just about to merge, but then our CI seems to be busted at the moment ... and I see you now have a deeper problem. I can make an educated guess. Cothread allocates blocks of memory for fresh areas of stack, and the "not MAP_STACK" message suggest to me that OpenBSD is (somehow) checking that the stack pointer is pointing to a block of memory without this magic MAP_STACK flag (this appears to be an option to This is fixable, I think, but it's not easy. We'd need to rework Lines 239 to 271 in 0eaef07 Line 250 in 0eaef07 MAP_STACK capable block of memory.
It's possible that OpenBSD already has a mechanism for this, or we'd have to use I think the PR is still valid, and can be a placeholder for further *BSD support. |
|
I've just fixed the CI in PR #88. Please rebase your branch to pick up the changes. |
Less than perfect -- can't easily free() this memory
|
I merged the latest "upstream" changes (thanks, @AlexanderWells-diamond !), used the mmap() suggestion from @Araneidae, and pushed again. Are there any obvious self-tests I should run, as well? I don't (yet) have any epics installed. |
|
I wrote a comment against the latest commit 9e58d11#commitcomment-207892143. I wonder if I should copy it into this thread? Hmm. We're going to need to improve the testing here! I wonder if it would be possible to run the https://github.com/DiamondLightSource/pythonSoftIOC test bench on OpenBSD? @AlexanderWells-diamond, do you think you'll be able to help @ldoolitt with this? I suspect it might be a slightly miserable experience, but it's probably worth a try. |
| #define FREE_ALIGNED(mem) ((void) 0) | ||
| /* XXX will leak memory; maybe won't crash with short-lived processes */ |
There was a problem hiding this comment.
There was a problem hiding this comment.
Actually, here's the short form. Try:
#define FREE_ALIGNED(mem, length) munmap(mem, length)and make all the associated required changes (including adding length to all the other #defines and fixing the call), and see if this works.
This is more expensive than malloc/free ... but then we're doing system calls for the guard pages anyway, so this is probably ok.
|
To run the I'm not sure exactly what will happen if you don't have EPICS on your PATH. The tests will likely have some failures. Let us know the results and we can take a look. We have a more extensive testbench available in the pythonSoftIOC repo. If you are willing, downloading and installing that will likely provide a better set of tests. To try that do: That version should include |
My first attempt, at least, bombed out trying to build the pipdeptree (4.2.13) dependency.
OpenBSD is not on I'm fond of drawing an analogy between the modern state of software dependencies and In that spirit, I may be able to disconnect my immediate task from cothread entirely! |
|
@ldoolitt, I'm full of sympathy with your feelings about modern dependency webs. Before tangling with Python integration I'd suggest just trying to compile EPICS base out of the box; I mean, just download EPICS base and try to build it. I'm going to guess that that will be full of enough surprises on OpenBSD to keep you entertained. Before EPICS v7 I could download EPICS base, change into the root directory, type |
Add brain-dead support for OpenBSD in the tangle of ifdefs surrounding memalign().
Better would be for an SME to simplify the ifdefs, not add a new one.
But I'm not that SME.
Without this patch, attempting a pip install of cothreads on OpenBSD gives a build error:
With this fix, pip install works, and the result is good enough to run cocotb.