-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation Fault in C program using select / poll / socket #1813
Comments
What is your output of |
Packages CPU architecture: sources.listdeb https://dl.bintray.com/termux/termux-packages-24/ stable main game-repo (sources.list.d/game.list)deb https://dl.bintray.com/grimler/game-packages-24 games stable science-repo (sources.list.d/science.list)deb https://dl.bintray.com/grimler/science-packages-24 science stable root-repo (sources.list.d/root.list)deb https://dl.bintray.com/grimler/termux-root-packages-24 root stable x11-repo (sources.list.d/x11.list)deb https://dl.bintray.com/xeffyr/x11-packages x11 main |
Could you provide a compilable example that segfaults for you? |
Submit FULL code next time.
Android is different from typical GNU/Linux at least by having a different libc (Bionic).
Very unlikely. We have lots of networking software which works perfectly. But even if there is "bug", it exists somewhere in libc and not subject for fixing in Termux as we use libraries provided by Android OS. Following code using
So |
Also note that termux-app/issues is not a place where we will debug third-party code (i.e. which is not part of Termux). Termux bug tracker is not a StackOverflow or similar. |
Hello Xeffyr and Grimler91, You were faster than me to put the response code 👍 , I was preparing it. My initial purpose was only to know if select ,poll and socket was supposed to work in Termux because my code works in another env. Regards, |
Hello Termux team,
I have an error launching an installed C program using socket in Termux (on Android TV (freebox player pop device))
Here is the code :
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <unistd.h>
...
static SOCKET g_cancel_fds[2] = {INVALID_SOCKET, INVALID_SOCKET};
...
fd_set fd;
int ret;
int max_fds = s_sock > g_cancel_fds[0] ? s_sock : g_cancel_fds[0];
SOCKET c_sock = INVALID_SOCKET;
FD_ZERO(&fd);
FD_SET(s_sock, &fd);
FD_SET(g_cancel_fds[0], &fd);
// use select for the timeout feature, ignore fd
// s_sock+1 allows us to check fd "s_sock" but ignore the rest
if ((ret = select(max_fds+1, &fd, NULL, NULL, NULL)) == SOCKET_ERROR) <-- Error Segmentation Fault at this line
{
...
Same error if I use poll function instead of select.
This code works on a linux server.
Does socket run correctly on Android or is it a Termux issue ?
The text was updated successfully, but these errors were encountered: