ARISE, OLD DEAD THREAD! Hey, this thread is almost legally allowed to drink >alcohol in the United States!
Anyways... Uwe Ludwig stumbled upon this and now I am stumbling on this
as well. Even if you code in the proper checks on the return value, you
will still get a SEGFAULT. There is something weird with lpthreads and >getpwuid (and also getlogin) and I don't quite know what it is. But,
yes... the combo of these two will always cause a SEGFAULT before you
can even check the return.
Stats:
- Ubuntu 20.04
- gcc version 9.4.0
- x86_64-linux-gnu
In article <e95d3f27-47ad-4ff4-8429-92821ad3e79en@googlegroups.com>, stryker2k2 <stryker2k2@gmail.com> wrote:
ARISE, OLD DEAD THREAD! Hey, this thread is almost legally allowed to drink >> alcohol in the United States!
Anyways... Uwe Ludwig stumbled upon this and now I am stumbling on this
as well. Even if you code in the proper checks on the return value, you
will still get a SEGFAULT. There is something weird with lpthreads and
getpwuid (and also getlogin) and I don't quite know what it is. But,
yes... the combo of these two will always cause a SEGFAULT before you
can even check the return.
Stats:
- Ubuntu 20.04
- gcc version 9.4.0
- x86_64-linux-gnu
Could you post code & build instructions?
Then we might at least have a chance at understanding what you're talking about, Willis...
On 1/4/2023 11:28 AM, Kenny McCormack wrote:
stryker2k2 <stryker2k2@gmail.com> wrote:
ARISE, OLD DEAD THREAD! Hey, this thread is almost legally allowed to drink >>> alcohol in the United States!Could you post code & build instructions?
Anyways... Uwe Ludwig stumbled upon this and now I am stumbling on this
as well. Even if you code in the proper checks on the return value, you
will still get a SEGFAULT. There is something weird with lpthreads and
getpwuid (and also getlogin) and I don't quite know what it is. But,
yes... the combo of these two will always cause a SEGFAULT before you
can even check the return.
Stats:
- Ubuntu 20.04
- gcc version 9.4.0
- x86_64-linux-gnu
Then we might at least have a chance at understanding what you're
talking
about, Willis...
Mar 5, 2003, 11:49:55 AM
https://groups.google.com/g/comp.unix.programmer/c/hs23vL73-y0
On 1/4/2023 11:28 AM, Kenny McCormack wrote:
In article <e95d3f27-47ad-4ff4-8429-92821ad3e79en@googlegroups.com>,
stryker2k2 <stryker2k2@gmail.com> wrote:
ARISE, OLD DEAD THREAD! Hey, this thread is almost legally allowed to drink >>> alcohol in the United States!
Anyways... Uwe Ludwig stumbled upon this and now I am stumbling on this
as well. Even if you code in the proper checks on the return value, you
will still get a SEGFAULT. There is something weird with lpthreads and
getpwuid (and also getlogin) and I don't quite know what it is. But,
yes... the combo of these two will always cause a SEGFAULT before you
can even check the return.
Stats:
- Ubuntu 20.04
- gcc version 9.4.0
- x86_64-linux-gnu
Could you post code & build instructions?
Then we might at least have a chance at understanding what you're talking
about, Willis...
Mar 5, 2003, 11:49:55 AM
https://groups.google.com/g/comp.unix.programmer/c/hs23vL73-y0
Paul <nospam@needed.invalid> writes:
On 1/4/2023 11:28 AM, Kenny McCormack wrote:
In article <e95d3f27-47ad-4ff4-8429-92821ad3e79en@googlegroups.com>,
stryker2k2 <stryker2k2@gmail.com> wrote:
ARISE, OLD DEAD THREAD! Hey, this thread is almost legally allowed to drink
alcohol in the United States!
Anyways... Uwe Ludwig stumbled upon this and now I am stumbling on this >>>> as well. Even if you code in the proper checks on the return value, you >>>> will still get a SEGFAULT. There is something weird with lpthreads and >>>> getpwuid (and also getlogin) and I don't quite know what it is. But,
yes... the combo of these two will always cause a SEGFAULT before you
can even check the return.
Stats:
- Ubuntu 20.04
- gcc version 9.4.0
- x86_64-linux-gnu
Could you post code & build instructions?
Then we might at least have a chance at understanding what you're talking >>> about, Willis...
Mar 5, 2003, 11:49:55 AM
https://groups.google.com/g/comp.unix.programmer/c/hs23vL73-y0
That program, with the undefined behaviour removed, but the curious
verbose style kept, is
#include <pwd.h>
#include <unistd.h>
#include <stdio.h>
char *a;
char *getuser(void)
{
char *username;
struct passwd *info;
info = getpwuid(getuid());
username = info->pw_name;
return username;
}
int main(void)
{
a = getuser();
printf(a);
printf("\n");
}
which compiles and runs fine on my system, with either the -pthread or >-lpthread option. Of course, since threads are not used, the linker may >simply be omitting the code that caused the problem 19 years ago.
The old post refers to -lpthreads (with and s) and my Ubuntu and gcc are >newer.
Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
Paul <nospam@needed.invalid> writes:
On 1/4/2023 11:28 AM, Kenny McCormack wrote:
In article <e95d3f27-47ad-4ff4-8429-92821ad3e79en@googlegroups.com>,
stryker2k2 <stryker2k2@gmail.com> wrote:
ARISE, OLD DEAD THREAD! Hey, this thread is almost legally allowed to drink
alcohol in the United States!
Anyways... Uwe Ludwig stumbled upon this and now I am stumbling on this >>>>> as well. Even if you code in the proper checks on the return value, you >>>>> will still get a SEGFAULT. There is something weird with lpthreads and >>>>> getpwuid (and also getlogin) and I don't quite know what it is. But, >>>>> yes... the combo of these two will always cause a SEGFAULT before you >>>>> can even check the return.
Stats:
- Ubuntu 20.04
- gcc version 9.4.0
- x86_64-linux-gnu
Could you post code & build instructions?
Then we might at least have a chance at understanding what you're talking >>>> about, Willis...
Mar 5, 2003, 11:49:55 AM
https://groups.google.com/g/comp.unix.programmer/c/hs23vL73-y0
That program, with the undefined behaviour removed, but the curious
verbose style kept, is
#include <pwd.h>
#include <unistd.h>
#include <stdio.h>
char *a;
char *getuser(void)
{
char *username;
struct passwd *info;
info = getpwuid(getuid());
username = info->pw_name;
return username;
}
int main(void)
{
a = getuser();
printf(a);
printf("\n");
}
which compiles and runs fine on my system, with either the -pthread or >>-lpthread option. Of course, since threads are not used, the linker may >>simply be omitting the code that caused the problem 19 years ago.
The old post refers to -lpthreads (with and s) and my Ubuntu and gcc are >>newer.
The code will fail if there is no password file entry matching
the current uid.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 299 |
Nodes: | 16 (2 / 14) |
Uptime: | 74:00:09 |
Calls: | 6,694 |
Calls today: | 4 |
Files: | 12,228 |
Messages: | 5,346,929 |
Posted today: | 1 |