[cs631apue] Differences in FTS between Linux and BSD

Elliot Wasem ewasem at stevens.edu
Wed Oct 2 10:47:25 EDT 2019


Hey Professor,

NetBSD:
So I'm running into an issue where somewhere in libc.so.12, there's a segfault relating to what appears to be (based on errno) the system running out of memory.

What's happening is that when I call fts_children(my_FTS_ptr, 0) after calling fts_read(my_FTS_ptr), it's segfaulting. If I print strerror(errno) right before calling fts_children(...), it says that it failed to allocate memory. When I run $gdb ./ls ./ls.core, it just says there's an error at ?? (literally prints ??) at libc.so.12.
Linux:
So when I realized where I was having issues, I thought I'd try valgrind to help analyze my memory management. It doesn't appear valgrind is available for BSD, so I made the necessary alterations to my code and makefile to run on Linux and.... it runs beautifully. No more segfault. I mean I have some memory leaks to hunt down and take care of, but the code runs and finishes.

ANYWAY
I'm not using any exorbitant amounts of memory anywhere, I don't do any memory allocation within recursive calls, and my NetBSD system seems to be running on <100MB of ram (I have 4GB allocated for NetBSD in VirtualBox).

My question, therefore, is if you know of any serious differences between NetBSD's fts.c and Linux's fts.c, if there even are any, and why I might be running into such a strange issue?
If not, I'll keep plugging away til I figure this one out.
Thanks,
Elliot Wasem
https://elliotwasem.xyz

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20191002/e45eabe4/attachment.html>


More information about the cs631apue mailing list