Last modified: 2025-02-19 23:09:47
< 2025-02-18 2025-02-20 >Next steps were:
makeElementBooleanAsync()
And then fixing issues:
I've "staged" my current progress but not committed.
Now I'm stuck on a stupid issue where pipe()
gives you file descriptors but all
the code I have for reading/writing between the processes uses C++ streams, and there
is no way to convert a fd into a stream? I am finding C++ to be a deeply uninspiring
language.
I think rewrite the code to work on fds instead of streams.
OK, current status is BooleanWorker
builds, I have make makeElementBooleanAsync()
and AsyncProcessHandle
, and I've made FeatureTransformed
call makeElementBooleanAsync()
,
and then immediately handle.join()
, so no facility to abort yet, just making sure
it works end-to-end through the child process.
Finally got it to build and run, but it segfaults inside makeElementBooleanAsync()
in constructing some C++ string.
https://github.com/jes/FreeCAD/commit/b36f1ac44f1c25c7f72a3c77481fcc8f04947810
Program received signal SIGSEGV, Segmentation fault.
#0 /lib/x86_64-linux-gnu/libc.so.6(+0x45330) [0x7f14ef5e8330]
#1 /lib/x86_64-linux-gnu/libc.so.6(+0x18b75d) [0x7f14ef72e75d]
#2 0x7f14ef91e9b9 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(char const*) from /lib/x86_64-linux-gnu/libstdc++.so.6+0x19
#3 0x7f14c30c1b97 in Part::TopoShape::makeElementBooleanAsync(char const*, std::vector<Part::TopoShape, std::allocator<Part::TopoShape> > const&, char const*, double) from /home/jes/projects/FreeCAD/build/Mod/Part/Part.so+0xa9d
It's because BooleanOperation.op
is a string but the op
argument to the function
is a char*
, and it is null, and apparently assigning a null char*
to a string causes
a segfault. So I need a way to pass a null pointer over the pipe? Or else figure out
a sensible default that doesn't change any of the behaviour.
Setting it to "" has fixed the segfault.
Whoa! Working. So good. Even on the complicated pattern operations that it was failing on yesterday.
So next step is to hook up the "Abort" button so that it kills the worker. Then demo video and draft PR.
The build is failing because I can't assign an AsyncProcessHandle
because of something
to do with move semantics? Is this some "Modern C++" stuff?
I have got Cursor to write me a "move constructor" and an implementation for operator=
,
but this seems weird and crazy. May have to revisit.
OK, it is building and working again, but now if a job is long-running enough for the "Abort" dialog to pop up, then it never completes? Although clicking "Abort" does get us back to a working FreeCAD GUI.
And it looks like the job actually does complete, because I can see the "BooleanWorker" process start up and then finish.
Oh, I think I see the problem. It calls waitpid
before it reads the result, so if
the result is too big for the buffer then waitpid
never returns.
OK, fixed that, but the "Abort" button isn't actually working. Continues hanging after I press "Abort".
When I kill it manually it aborts. So best guess is it's not actually aborting, but why?
I added some logging, don't think I changed anything else, and it is working now.
Logging commented out, now it is broken again!
It might be that it is broken on some types of shapes and not others, and the logging changes are incidental.
I think the problem is actually that if it is still writing shape data to the pipe
then the processHandle
hasn't been assigned yet! So the abort button does nothing.
OK, I see another problem. The number of shapes is only a uint8
! Needs to be uint32
at least. I'll just make everything a uint64.
To fix the "not assigned yet" problem, I'll make makeElementBooleanAsync()
take a
pointer to your AsyncProcessHandle
, and populate it as soon as it can.
OK, next problem is if you accidentally make the "Occurrences" much too high, then it still takes forever collecting up the input shapes.
I made it check the wantAbort
flag in more cases. Seems good now.
https://www.youtube.com/watch?v=c9CPuT3z1OM
https://github.com/FreeCAD/FreeCAD/pull/19710
Yesterday I saw a car ramp toy, it was lots of angled ramps stacked up, so that you could let a car roll down from the top, and it would drive back and forth down the ramps to the bottom.
I could pretty easily make one of these for Lucy.
I want the car to flip over and drive upside down every time it changes direction.
Something like this:
The curved pieces can be 3d-printed. The straight pieces can just be wooden.
And then it just wants some sort of frame to hold it all up, which I should be able to make from plywood on the CNC machine.
The frame can provide the "side rails" to stop the car from falling off the side of the road.
Or alternatively we just have a frame on one side and screw 3d-printed road to it.
I quite like the idea of 3d-printed road, because then you can imagine having it pinned at one end, and screwed through a slot at the other, and you can change the angle of the ramp. Also less woodwork, which saves time.
< 2025-02-18 2025-02-20 >