I have a piece of code causing a segfault on a client's device. The cpu is a Nvidia Tegra 250(Cortex-A9).
I'm sure i've done something stupid, but on all my test devices (x86, i.MX6S (cortex-a9), Exynos quad 4412 (cortex-a9), and ~6 that I dont know what they are) the code works as intended. The last time something like this happened it was a cpu hardware issue and I'm curious if any of you can point out what I've done wrong or if the client's chipset somehow doesnt support something im doing.
It's a simple unix server and from what I can gather from the client, the segfault is occuring in this area probably @ the memset but thats just a guess on my part
const char name[] = "\0TestServer";
int sockfd, newsockfd, servlen, n;
socklen_t clilen;
struct sockaddr_un cli_addr, serv_addr;
char buf[80];
int processors = std::thread::hardware_concurrency();
if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0){
error("creating socket");
}
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sun_family = AF_UNIX;
memcpy(serv_addr.sun_path, name, sizeof(name) - 1);
servlen = sizeof(name) - 1 + sizeof(serv_addr.sun_family);
//bind the server, make sure it isnt already running
int bindResult = bind(sockfd, (struct sockaddr *) &serv_addr, servlen);
if (bindResult == EADDRINUSE) {
error("socket address already in use, shutting down");
}
if (bindResult < 0) {
error("binding socket");
}
listen(sockfd, 5);
//init vars for bytestream data
char operation;
int sigil = 1; //loop control variable
int32_t result = 0; //scan result to return to client
int32_t msg = 0;
int32_t tmp = 0;
while (sigil) {
//wait for a new connection
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
The compiler is clang, if that matters.
Thanks in advance