mailing list of musl libc
 help / color / mirror / code / Atom feed
* Build on linux 2.6 and run on linux 2.4?
@ 2014-03-20 20:58 John Mudd
  2014-03-20 23:14 ` Rich Felker
  0 siblings, 1 reply; 14+ messages in thread
From: John Mudd @ 2014-03-20 20:58 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 147 bytes --]

Probably a dumb question. Is part of the value of musl that I can build an
app using musl on linux 2.6 and then run the binary on linux 2.4?

John

[-- Attachment #2: Type: text/html, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-20 20:58 Build on linux 2.6 and run on linux 2.4? John Mudd
@ 2014-03-20 23:14 ` Rich Felker
  2014-03-21  0:51   ` Rich Felker
  2014-03-21 13:02   ` John Mudd
  0 siblings, 2 replies; 14+ messages in thread
From: Rich Felker @ 2014-03-20 23:14 UTC (permalink / raw)
  To: musl; +Cc: John Mudd

On Thu, Mar 20, 2014 at 04:58:49PM -0400, John Mudd wrote:
> Probably a dumb question. Is part of the value of musl that I can build an
> app using musl on linux 2.6 and then run the binary on linux 2.4?

The version of Linux you build on has no bearing on the binary that
comes out, so that's not a problem.

However, Linux 2.4 is not officially supported since it lacks a lot of
functionality needed to provide a modern POSIX conforming environment.
The most notable is that it can't do threads. If you're ok with that,
the other problems might be small enough that you don't mind. I
remember some people in Freenode #musl trying out 2.4 recently and
finding that a few of the busybox applets didn't work right, though,
due to missing statfs64 syscall.

This page has details on which kernel versions added which syscalls:

http://man7.org/linux/man-pages/man2/syscalls.2.html

so it may be helpful in evaluating if there's anything critical you'd
be missing. If a syscall has two versions, one with "64" on the end,
musl needs the one that ends in "64".

This is definitely a topic we could attempt to document better if more
people are interested in trying to use 2.4.

Rich


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-20 23:14 ` Rich Felker
@ 2014-03-21  0:51   ` Rich Felker
  2014-03-26  6:22     ` Rich Felker
  2014-03-21 13:02   ` John Mudd
  1 sibling, 1 reply; 14+ messages in thread
From: Rich Felker @ 2014-03-21  0:51 UTC (permalink / raw)
  To: musl

On Thu, Mar 20, 2014 at 07:14:12PM -0400, Rich Felker wrote:
> On Thu, Mar 20, 2014 at 04:58:49PM -0400, John Mudd wrote:
> > Probably a dumb question. Is part of the value of musl that I can build an
> > app using musl on linux 2.6 and then run the binary on linux 2.4?
> 
> The version of Linux you build on has no bearing on the binary that
> comes out, so that's not a problem.
> 
> However, Linux 2.4 is not officially supported since it lacks a lot of
> functionality needed to provide a modern POSIX conforming environment.
> The most notable is that it can't do threads. If you're ok with that,
> the other problems might be small enough that you don't mind. I
> remember some people in Freenode #musl trying out 2.4 recently and
> finding that a few of the busybox applets didn't work right, though,
> due to missing statfs64 syscall.
> 
> This page has details on which kernel versions added which syscalls:
> 
> http://man7.org/linux/man-pages/man2/syscalls.2.html

I looked through this list, and statfs64/fstatfs64 seem to be the only
two syscalls where the 32-bit off_t version was all that's available
in 2.4 and the 64-bit version was added in 2.6. So if we could provide
a fallback for them, this might make 2.4 a fairly viable target for
single-threaded programs built with musl. (Despite 2.4 being ancient
and generally a bad idea to use, there are some devices where
replacing the kernel is hard or where the patches to support the
device have not been ported to 2.6, so this isn't just a useless
exercise.)

The big question that remains of course is how ugly the fallbacks
would be, and whether we'd need a lot more arch-specific definitions
_purely_ for 2.4 fallback.

Rich


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-20 23:14 ` Rich Felker
  2014-03-21  0:51   ` Rich Felker
@ 2014-03-21 13:02   ` John Mudd
  2014-03-21 16:40     ` Rich Felker
  2014-03-21 17:54     ` John Mudd
  1 sibling, 2 replies; 14+ messages in thread
From: John Mudd @ 2014-03-21 13:02 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]

Thanks for your reply.

I ran a test using an example thread app. I compiled the cond1.c example
from http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html using
musl-gcc on Ubuntu 13.04, 2.6 kernel obviously. The executable runs on 2.6
as well as 2.4. I actually expected some kind of failure on 2.4. Did I pick
a poor example or am I not understanding still?


On Thu, Mar 20, 2014 at 7:14 PM, Rich Felker <dalias@aerifal.cx> wrote:

> On Thu, Mar 20, 2014 at 04:58:49PM -0400, John Mudd wrote:
> > Probably a dumb question. Is part of the value of musl that I can build
> an
> > app using musl on linux 2.6 and then run the binary on linux 2.4?
>
> The version of Linux you build on has no bearing on the binary that
> comes out, so that's not a problem.
>
> However, Linux 2.4 is not officially supported since it lacks a lot of
> functionality needed to provide a modern POSIX conforming environment.
> The most notable is that it can't do threads. If you're ok with that,
> the other problems might be small enough that you don't mind. I
> remember some people in Freenode #musl trying out 2.4 recently and
> finding that a few of the busybox applets didn't work right, though,
> due to missing statfs64 syscall.
>
> This page has details on which kernel versions added which syscalls:
>
> http://man7.org/linux/man-pages/man2/syscalls.2.html
>
> so it may be helpful in evaluating if there's anything critical you'd
> be missing. If a syscall has two versions, one with "64" on the end,
> musl needs the one that ends in "64".
>
> This is definitely a topic we could attempt to document better if more
> people are interested in trying to use 2.4.
>
> Rich
>

[-- Attachment #2: Type: text/html, Size: 2379 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21 13:02   ` John Mudd
@ 2014-03-21 16:40     ` Rich Felker
  2014-03-21 17:54     ` John Mudd
  1 sibling, 0 replies; 14+ messages in thread
From: Rich Felker @ 2014-03-21 16:40 UTC (permalink / raw)
  To: musl

On Fri, Mar 21, 2014 at 09:02:09AM -0400, John Mudd wrote:
> Thanks for your reply.
> 
> I ran a test using an example thread app. I compiled the cond1.c example
> from http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html using
> musl-gcc on Ubuntu 13.04, 2.6 kernel obviously. The executable runs on 2.6
> as well as 2.4. I actually expected some kind of failure on 2.4. Did I pick
> a poor example or am I not understanding still?

Yes, I did too; the intent is that pthread_create is supposed to
return failure on kernels where things are not going to work right
(i.e. clone does not support the necessary flags to provide threads);
this is in turn supposed to result from a failure in pthread_self.

Could you provide the output of running the program under strace on
2.4?

Rich


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21 13:02   ` John Mudd
  2014-03-21 16:40     ` Rich Felker
@ 2014-03-21 17:54     ` John Mudd
  2014-03-21 18:02       ` Rich Felker
  1 sibling, 1 reply; 14+ messages in thread
From: John Mudd @ 2014-03-21 17:54 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 4277 bytes --]

Here is the regular and strace output on 2.4 kernel, more specifically
Linux 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003 i686 i686 i386 GNU/Linux.

$ test_threads2
Counter value functionCount1: 1
Counter value functionCount1: 2
Counter value functionCount1: 3
Counter value functionCount2: 4
Counter value functionCount2: 5
Counter value functionCount2: 6
Counter value functionCount2: 7
Counter value functionCount1: 8
Counter value functionCount1: 9
Counter value functionCount1: 10
Final count: 10
$

$ strace test_threads2
execve("/home/jmudd/test_threads2", ["test_threads2"], [/* 26 vars */]) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0x804e540, limit:1048575,
seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
seg_not_present:0, useable:1}) = 0
set_tid_address(0x804e558)              = 25884
mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb75ea000
mprotect(0xb75eb000, 86016, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0xb75fff30,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
parent_tidptr=0xb75fff58, {entry_number:6, base_addr:0xb75fff40,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
seg_not_present:0, useable:1}, child_tidptr=0xb75fff58) = 25885
mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb75d4000
mprotect(0xb75d5000, 86016, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0xb75e9f30,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
parent_tidptr=0xb75e9f58, {entry_number:6, base_addr:0xb75e9f40,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
seg_not_present:0, useable:1}, child_tidptr=0xb75e9f58) = 25886
futex(0xb75fff58, FUTEX_WAIT, 25885, NULLCounter value functionCount1: 1
Counter value functionCount1: 2
Counter value functionCount1: 3
Counter value functionCount2: 4
Counter value functionCount2: 5
Counter value functionCount2: 6
Counter value functionCount2: 7
Counter value functionCount1: 8
Counter value functionCount1: 9
Counter value functionCount1: 10
) = 0
munmap(0xb75ea000, 90112)               = 0
munmap(0xb75d4000, 90112)               = 0
writev(1, [{"Final count: 10", 15}, {"\n", 1}], 2Final count: 10
) = 16
exit_group(0)                           = ?
$


>

On Fri, Mar 21, 2014 at 9:02 AM, John Mudd <johnbmudd@gmail.com> wrote:

> Thanks for your reply.
>
> I ran a test using an example thread app. I compiled the cond1.c example
> from http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.htmlusing musl-gcc on Ubuntu 13.04, 2.6 kernel obviously. The executable runs
> on 2.6 as well as 2.4. I actually expected some kind of failure on 2.4. Did
> I pick a poor example or am I not understanding still?
>
>
> On Thu, Mar 20, 2014 at 7:14 PM, Rich Felker <dalias@aerifal.cx> wrote:
>
>> On Thu, Mar 20, 2014 at 04:58:49PM -0400, John Mudd wrote:
>> > Probably a dumb question. Is part of the value of musl that I can build
>> an
>> > app using musl on linux 2.6 and then run the binary on linux 2.4?
>>
>> The version of Linux you build on has no bearing on the binary that
>> comes out, so that's not a problem.
>>
>> However, Linux 2.4 is not officially supported since it lacks a lot of
>> functionality needed to provide a modern POSIX conforming environment.
>> The most notable is that it can't do threads. If you're ok with that,
>> the other problems might be small enough that you don't mind. I
>> remember some people in Freenode #musl trying out 2.4 recently and
>> finding that a few of the busybox applets didn't work right, though,
>> due to missing statfs64 syscall.
>>
>> This page has details on which kernel versions added which syscalls:
>>
>> http://man7.org/linux/man-pages/man2/syscalls.2.html
>>
>> so it may be helpful in evaluating if there's anything critical you'd
>> be missing. If a syscall has two versions, one with "64" on the end,
>> musl needs the one that ends in "64".
>>
>> This is definitely a topic we could attempt to document better if more
>> people are interested in trying to use 2.4.
>>
>> Rich
>>
>
>

[-- Attachment #2: Type: text/html, Size: 6274 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21 17:54     ` John Mudd
@ 2014-03-21 18:02       ` Rich Felker
  2014-03-21 18:24         ` John Mudd
  0 siblings, 1 reply; 14+ messages in thread
From: Rich Felker @ 2014-03-21 18:02 UTC (permalink / raw)
  To: John Mudd; +Cc: musl

On Fri, Mar 21, 2014 at 01:54:34PM -0400, John Mudd wrote:
> Here is the regular and strace output on 2.4 kernel, more specifically
> Linux 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003 i686 i686 i386 GNU/Linux.
> 
> $ test_threads2
> Counter value functionCount1: 1
> Counter value functionCount1: 2
> Counter value functionCount1: 3
> Counter value functionCount2: 4
> Counter value functionCount2: 5
> Counter value functionCount2: 6
> Counter value functionCount2: 7
> Counter value functionCount1: 8
> Counter value functionCount1: 9
> Counter value functionCount1: 10
> Final count: 10
> $
> 
> $ strace test_threads2
> execve("/home/jmudd/test_threads2", ["test_threads2"], [/* 26 vars */]) = 0
> rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
> set_thread_area({entry_number:-1 -> 6, base_addr:0x804e540, limit:1048575,
> seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> seg_not_present:0, useable:1}) = 0
> set_tid_address(0x804e558)              = 25884
> mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb75ea000
> mprotect(0xb75eb000, 86016, PROT_READ|PROT_WRITE) = 0
> clone(child_stack=0xb75fff30,
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
> parent_tidptr=0xb75fff58, {entry_number:6, base_addr:0xb75fff40,
> limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> seg_not_present:0, useable:1}, child_tidptr=0xb75fff58) = 25885
> mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb75d4000
> mprotect(0xb75d5000, 86016, PROT_READ|PROT_WRITE) = 0
> clone(child_stack=0xb75e9f30,
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
> parent_tidptr=0xb75e9f58, {entry_number:6, base_addr:0xb75e9f40,
> limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> seg_not_present:0, useable:1}, child_tidptr=0xb75e9f58) = 25886
> futex(0xb75fff58, FUTEX_WAIT, 25885, NULLCounter value functionCount1: 1
> Counter value functionCount1: 2
> Counter value functionCount1: 3
> Counter value functionCount2: 4
> Counter value functionCount2: 5
> Counter value functionCount2: 6
> Counter value functionCount2: 7
> Counter value functionCount1: 8
> Counter value functionCount1: 9
> Counter value functionCount1: 10
> ) = 0
> munmap(0xb75ea000, 90112)               = 0
> munmap(0xb75d4000, 90112)               = 0
> writev(1, [{"Final count: 10", 15}, {"\n", 1}], 2Final count: 10
> ) = 16
> exit_group(0)                           = ?
> $

Is this a stock 2.4.x kernel or a distro-modified one that might have
things backported from 2.6?

Can you re-run the strace with:

    strace -f -o logfile test_threads2

-f is needed to trace anything but the main thread/original process,
and -o to a file produces nicer output (pid/tid on each line) than the
usual default.

Rich


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21 18:02       ` Rich Felker
@ 2014-03-21 18:24         ` John Mudd
  2014-03-21 19:09           ` Rich Felker
  2014-03-21 19:48           ` John Mudd
  0 siblings, 2 replies; 14+ messages in thread
From: John Mudd @ 2014-03-21 18:24 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 9239 bytes --]

$ cat /etc/*-release
LSB_VERSION="1.3"
Red Hat Enterprise Linux AS release 3 (Taroon)
[jmudd@ares jmudd]$ lsb_release -a
LSB Version:    1.3
Distributor ID: RedHatEnterpriseAS
Description:    Red Hat Enterprise Linux AS release 3 (Taroon)
Release:        3
Codename:       Taroon
$ uname -mrs
Linux 2.4.21-4.EL i686
$ cat /proc/version
Linux version 2.4.21-4.EL (bhcompile@daffy.perf.redhat.com) (gcc version
3.2.3 20030502 (Red Hat Linux 3.2.3-20)) #1 Fri Oct 3 18:13:58 EDT 2003
$


logfile:
25920 execve("/home/jmudd/test_threads2", ["test_threads2"], [/* 26 vars
*/]) = 0
25920 rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
25920 set_thread_area({entry_number:-1 -> 6, base_addr:0x804e540,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
seg_not_present:0, useable:1}) = 0
25920 set_tid_address(0x804e558)        = 25920
25920 mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xb75ea000
25920 mprotect(0xb75eb000, 86016, PROT_READ|PROT_WRITE) = 0
25920 clone(child_stack=0xb75fff30,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
parent_tidptr=0xb75fff58, {entry_number:6, base_addr:0xb75fff40,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
seg_not_present:0, useable:1}, child_tidptr=0xb75fff58) = 25921
25920 mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xb75d4000
25920 mprotect(0xb75d5000, 86016, PROT_READ|PROT_WRITE) = 0
25920 clone(child_stack=0xb75e9f30,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
parent_tidptr=0xb75e9f58, {entry_number:6, base_addr:0xb75e9f40,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
seg_not_present:0, useable:1}, child_tidptr=0xb75e9f58) = 25922
25920 futex(0xb75fff58, FUTEX_WAIT, 25921, NULL <unfinished ...>
25922 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
25922 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
25920 <... futex resumed> )             = -1 EINTR (Interrupted system call)
25922 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
25920 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
25920 futex(0xb75fff58, FUTEX_WAIT, 25921, NULL <unfinished ...>
25921 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
25921 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
25920 <... futex resumed> )             = -1 EINTR (Interrupted system call)
25921 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
25920 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
25920 futex(0xb75fff58, FUTEX_WAIT, 25921, NULL <unfinished ...>
25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 futex(0x804e0e8, FUTEX_WAIT, 0, NULL <unfinished ...>
25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
25921 writev(1, [{"Counter value functionCount1: 1", 31}, {"\n", 1}], 2) =
32
25921 futex(0x804e0e8, FUTEX_WAIT, 1, NULL <unfinished ...>
25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 writev(1, [{"Counter value functionCount1: 2", 31}, {"\n", 1}], 2) =
32
25921 futex(0x804e0e8, FUTEX_WAIT, 2, NULL <unfinished ...>
25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 writev(1, [{"Counter value functionCount1: 3", 31}, {"\n", 1}], 2) =
32
25921 futex(0x804e0e8, FUTEX_WAIT, 3, NULL <unfinished ...>
25922 writev(1, [{"Counter value functionCount2: 4", 31}, {"\n", 1}], 2) =
32
25922 writev(1, [{"Counter value functionCount2: 5", 31}, {"\n", 1}], 2) =
32
25922 writev(1, [{"Counter value functionCount2: 6", 31}, {"\n", 1}], 2) =
32
25922 writev(1, [{"Counter value functionCount2: 7", 31}, {"\n", 1}], 2) =
32
25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 writev(1, [{"Counter value functionCount1: 8", 31}, {"\n", 1}], 2) =
32
25921 futex(0x804e0e8, FUTEX_WAIT, 4, NULL <unfinished ...>
25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 writev(1, [{"Counter value functionCount1: 9", 31}, {"\n", 1}], 2) =
32
25921 futex(0x804e0e8, FUTEX_WAIT, 5, NULL <unfinished ...>
25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
25921 <... futex resumed> )             = 0
25921 writev(1, [{"Counter value functionCount1: 10", 32}, {"\n", 1}], 2) =
33
25921 rt_sigprocmask(SIG_BLOCK, ~[], [], 8) = 0
25921 _exit(0)                          = ?
25920 <... futex resumed> )             = 0
25920 munmap(0xb75ea000, 90112)         = 0
25920 futex(0xb75e9f58, FUTEX_WAIT, 25922, NULL <unfinished ...>
25922 rt_sigprocmask(SIG_BLOCK, ~[], [], 8) = 0
25922 _exit(0)                          = ?
25920 <... futex resumed> )             = 0
25920 munmap(0xb75d4000, 90112)         = 0
25920 writev(1, [{"Final count: 10", 15}, {"\n", 1}], 2) = 16
25920 exit_group(0)                     = ?



On Fri, Mar 21, 2014 at 2:02 PM, Rich Felker <dalias@aerifal.cx> wrote:

> On Fri, Mar 21, 2014 at 01:54:34PM -0400, John Mudd wrote:
> > Here is the regular and strace output on 2.4 kernel, more specifically
> > Linux 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003 i686 i686 i386
> GNU/Linux.
> >
> > $ test_threads2
> > Counter value functionCount1: 1
> > Counter value functionCount1: 2
> > Counter value functionCount1: 3
> > Counter value functionCount2: 4
> > Counter value functionCount2: 5
> > Counter value functionCount2: 6
> > Counter value functionCount2: 7
> > Counter value functionCount1: 8
> > Counter value functionCount1: 9
> > Counter value functionCount1: 10
> > Final count: 10
> > $
> >
> > $ strace test_threads2
> > execve("/home/jmudd/test_threads2", ["test_threads2"], [/* 26 vars */])
> = 0
> > rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
> > set_thread_area({entry_number:-1 -> 6, base_addr:0x804e540,
> limit:1048575,
> > seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> > seg_not_present:0, useable:1}) = 0
> > set_tid_address(0x804e558)              = 25884
> > mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0xb75ea000
> > mprotect(0xb75eb000, 86016, PROT_READ|PROT_WRITE) = 0
> > clone(child_stack=0xb75fff30,
> >
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
> > parent_tidptr=0xb75fff58, {entry_number:6, base_addr:0xb75fff40,
> > limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
> limit_in_pages:1,
> > seg_not_present:0, useable:1}, child_tidptr=0xb75fff58) = 25885
> > mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0xb75d4000
> > mprotect(0xb75d5000, 86016, PROT_READ|PROT_WRITE) = 0
> > clone(child_stack=0xb75e9f30,
> >
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
> > parent_tidptr=0xb75e9f58, {entry_number:6, base_addr:0xb75e9f40,
> > limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
> limit_in_pages:1,
> > seg_not_present:0, useable:1}, child_tidptr=0xb75e9f58) = 25886
> > futex(0xb75fff58, FUTEX_WAIT, 25885, NULLCounter value functionCount1: 1
> > Counter value functionCount1: 2
> > Counter value functionCount1: 3
> > Counter value functionCount2: 4
> > Counter value functionCount2: 5
> > Counter value functionCount2: 6
> > Counter value functionCount2: 7
> > Counter value functionCount1: 8
> > Counter value functionCount1: 9
> > Counter value functionCount1: 10
> > ) = 0
> > munmap(0xb75ea000, 90112)               = 0
> > munmap(0xb75d4000, 90112)               = 0
> > writev(1, [{"Final count: 10", 15}, {"\n", 1}], 2Final count: 10
> > ) = 16
> > exit_group(0)                           = ?
> > $
>
> Is this a stock 2.4.x kernel or a distro-modified one that might have
> things backported from 2.6?
>
> Can you re-run the strace with:
>
>     strace -f -o logfile test_threads2
>
> -f is needed to trace anything but the main thread/original process,
> and -o to a file produces nicer output (pid/tid on each line) than the
> usual default.
>
> Rich
>

[-- Attachment #2: Type: text/html, Size: 11726 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21 18:24         ` John Mudd
@ 2014-03-21 19:09           ` Rich Felker
  2014-03-21 19:48           ` John Mudd
  1 sibling, 0 replies; 14+ messages in thread
From: Rich Felker @ 2014-03-21 19:09 UTC (permalink / raw)
  To: musl

On Fri, Mar 21, 2014 at 02:24:09PM -0400, John Mudd wrote:
> $ cat /etc/*-release
> LSB_VERSION="1.3"
> Red Hat Enterprise Linux AS release 3 (Taroon)

It looks to me like this comes from around the time RH was developing
NPTL, and they may have already added the necessary kernel-side stuff
into their 2.4 kernel. Try running:

getconf GNU_LIBPTHREAD_VERSION

and see if it reports NPTL or LinuxThreads.

> logfile:
> 25920 execve("/home/jmudd/test_threads2", ["test_threads2"], [/* 26 vars
> */]) = 0
> 25920 rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
> 25920 set_thread_area({entry_number:-1 -> 6, base_addr:0x804e540,
> limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> seg_not_present:0, useable:1}) = 0
> 25920 set_tid_address(0x804e558)        = 25920
> 25920 mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0xb75ea000
> 25920 mprotect(0xb75eb000, 86016, PROT_READ|PROT_WRITE) = 0
> 25920 clone(child_stack=0xb75fff30,
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
> parent_tidptr=0xb75fff58, {entry_number:6, base_addr:0xb75fff40,
> limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> seg_not_present:0, useable:1}, child_tidptr=0xb75fff58) = 25921
> 25920 mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0xb75d4000
> 25920 mprotect(0xb75d5000, 86016, PROT_READ|PROT_WRITE) = 0
> 25920 clone(child_stack=0xb75e9f30,
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
> parent_tidptr=0xb75e9f58, {entry_number:6, base_addr:0xb75e9f40,
> limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> seg_not_present:0, useable:1}, child_tidptr=0xb75e9f58) = 25922
> 25920 futex(0xb75fff58, FUTEX_WAIT, 25921, NULL <unfinished ...>
> 25922 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25922 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 <... futex resumed> )             = -1 EINTR (Interrupted system call)
> 25922 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 futex(0xb75fff58, FUTEX_WAIT, 25921, NULL <unfinished ...>
> 25921 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25921 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 <... futex resumed> )             = -1 EINTR (Interrupted system call)
> 25921 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---

These SIGSTOPs are weird, but otherwise I don't see anything strange.
In particular set_thread_area and set_tid_address worked; AFAIK they
should have failed on a "real" 2.4 kernel.

Rich


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21 18:24         ` John Mudd
  2014-03-21 19:09           ` Rich Felker
@ 2014-03-21 19:48           ` John Mudd
  2014-03-21 19:53             ` Rich Felker
  1 sibling, 1 reply; 14+ messages in thread
From: John Mudd @ 2014-03-21 19:48 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 9869 bytes --]

$ getconf GNU_LIBPTHREAD_VERSION
NPTL 0.60
$

So that's it, I lucked out? I can start building my apps on a modern Linux
and still run on my older ones? If so then this is like being told time
travel is possible.



On Fri, Mar 21, 2014 at 2:24 PM, John Mudd <johnbmudd@gmail.com> wrote:

> $ cat /etc/*-release
> LSB_VERSION="1.3"
> Red Hat Enterprise Linux AS release 3 (Taroon)
> [jmudd@ares jmudd]$ lsb_release -a
> LSB Version:    1.3
> Distributor ID: RedHatEnterpriseAS
> Description:    Red Hat Enterprise Linux AS release 3 (Taroon)
> Release:        3
> Codename:       Taroon
> $ uname -mrs
> Linux 2.4.21-4.EL i686
> $ cat /proc/version
> Linux version 2.4.21-4.EL (bhcompile@daffy.perf.redhat.com) (gcc version
> 3.2.3 20030502 (Red Hat Linux 3.2.3-20)) #1 Fri Oct 3 18:13:58 EDT 2003
> $
>
>
> logfile:
> 25920 execve("/home/jmudd/test_threads2", ["test_threads2"], [/* 26 vars
> */]) = 0
> 25920 rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
> 25920 set_thread_area({entry_number:-1 -> 6, base_addr:0x804e540,
> limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> seg_not_present:0, useable:1}) = 0
> 25920 set_tid_address(0x804e558)        = 25920
> 25920 mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0xb75ea000
> 25920 mprotect(0xb75eb000, 86016, PROT_READ|PROT_WRITE) = 0
> 25920 clone(child_stack=0xb75fff30,
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
> parent_tidptr=0xb75fff58, {entry_number:6, base_addr:0xb75fff40,
> limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> seg_not_present:0, useable:1}, child_tidptr=0xb75fff58) = 25921
> 25920 mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0xb75d4000
> 25920 mprotect(0xb75d5000, 86016, PROT_READ|PROT_WRITE) = 0
> 25920 clone(child_stack=0xb75e9f30,
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
> parent_tidptr=0xb75e9f58, {entry_number:6, base_addr:0xb75e9f40,
> limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
> seg_not_present:0, useable:1}, child_tidptr=0xb75e9f58) = 25922
> 25920 futex(0xb75fff58, FUTEX_WAIT, 25921, NULL <unfinished ...>
> 25922 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25922 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 <... futex resumed> )             = -1 EINTR (Interrupted system
> call)
> 25922 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 futex(0xb75fff58, FUTEX_WAIT, 25921, NULL <unfinished ...>
> 25921 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25921 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 <... futex resumed> )             = -1 EINTR (Interrupted system
> call)
> 25921 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25920 --- SIGSTOP (Stopped (signal)) @ 0 (0) ---
> 25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
> 25920 futex(0xb75fff58, FUTEX_WAIT, 25921, NULL <unfinished ...>
> 25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 futex(0x804e0e8, FUTEX_WAIT, 0, NULL <unfinished ...>
> 25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
> 25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
> 25921 writev(1, [{"Counter value functionCount1: 1", 31}, {"\n", 1}], 2) =
> 32
> 25921 futex(0x804e0e8, FUTEX_WAIT, 1, NULL <unfinished ...>
> 25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
> 25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 writev(1, [{"Counter value functionCount1: 2", 31}, {"\n", 1}], 2) =
> 32
> 25921 futex(0x804e0e8, FUTEX_WAIT, 2, NULL <unfinished ...>
> 25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
> 25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 writev(1, [{"Counter value functionCount1: 3", 31}, {"\n", 1}], 2) =
> 32
> 25921 futex(0x804e0e8, FUTEX_WAIT, 3, NULL <unfinished ...>
> 25922 writev(1, [{"Counter value functionCount2: 4", 31}, {"\n", 1}], 2) =
> 32
> 25922 writev(1, [{"Counter value functionCount2: 5", 31}, {"\n", 1}], 2) =
> 32
> 25922 writev(1, [{"Counter value functionCount2: 6", 31}, {"\n", 1}], 2) =
> 32
> 25922 writev(1, [{"Counter value functionCount2: 7", 31}, {"\n", 1}], 2) =
> 32
> 25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
> 25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 writev(1, [{"Counter value functionCount1: 8", 31}, {"\n", 1}], 2) =
> 32
> 25921 futex(0x804e0e8, FUTEX_WAIT, 4, NULL <unfinished ...>
> 25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
> 25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 writev(1, [{"Counter value functionCount1: 9", 31}, {"\n", 1}], 2) =
> 32
> 25921 futex(0x804e0e8, FUTEX_WAIT, 5, NULL <unfinished ...>
> 25922 futex(0x804e0e8, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 futex(0x804e0c4, FUTEX_WAIT, -2147483632, NULL <unfinished ...>
> 25922 futex(0x804e0c4, FUTEX_WAKE, 1)   = 1
> 25921 <... futex resumed> )             = 0
> 25921 writev(1, [{"Counter value functionCount1: 10", 32}, {"\n", 1}], 2)
> = 33
> 25921 rt_sigprocmask(SIG_BLOCK, ~[], [], 8) = 0
> 25921 _exit(0)                          = ?
> 25920 <... futex resumed> )             = 0
> 25920 munmap(0xb75ea000, 90112)         = 0
> 25920 futex(0xb75e9f58, FUTEX_WAIT, 25922, NULL <unfinished ...>
> 25922 rt_sigprocmask(SIG_BLOCK, ~[], [], 8) = 0
> 25922 _exit(0)                          = ?
> 25920 <... futex resumed> )             = 0
> 25920 munmap(0xb75d4000, 90112)         = 0
> 25920 writev(1, [{"Final count: 10", 15}, {"\n", 1}], 2) = 16
> 25920 exit_group(0)                     = ?
>
>
>
> On Fri, Mar 21, 2014 at 2:02 PM, Rich Felker <dalias@aerifal.cx> wrote:
>
>> On Fri, Mar 21, 2014 at 01:54:34PM -0400, John Mudd wrote:
>> > Here is the regular and strace output on 2.4 kernel, more specifically
>> > Linux 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003 i686 i686 i386
>> GNU/Linux.
>> >
>> > $ test_threads2
>> > Counter value functionCount1: 1
>> > Counter value functionCount1: 2
>> > Counter value functionCount1: 3
>> > Counter value functionCount2: 4
>> > Counter value functionCount2: 5
>> > Counter value functionCount2: 6
>> > Counter value functionCount2: 7
>> > Counter value functionCount1: 8
>> > Counter value functionCount1: 9
>> > Counter value functionCount1: 10
>> > Final count: 10
>> > $
>> >
>> > $ strace test_threads2
>> > execve("/home/jmudd/test_threads2", ["test_threads2"], [/* 26 vars */])
>> = 0
>> > rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
>> > set_thread_area({entry_number:-1 -> 6, base_addr:0x804e540,
>> limit:1048575,
>> > seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1,
>> > seg_not_present:0, useable:1}) = 0
>> > set_tid_address(0x804e558)              = 25884
>> > mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
>> 0xb75ea000
>> > mprotect(0xb75eb000, 86016, PROT_READ|PROT_WRITE) = 0
>> > clone(child_stack=0xb75fff30,
>> >
>> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
>> > parent_tidptr=0xb75fff58, {entry_number:6, base_addr:0xb75fff40,
>> > limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
>> limit_in_pages:1,
>> > seg_not_present:0, useable:1}, child_tidptr=0xb75fff58) = 25885
>> > mmap2(NULL, 90112, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
>> 0xb75d4000
>> > mprotect(0xb75d5000, 86016, PROT_READ|PROT_WRITE) = 0
>> > clone(child_stack=0xb75e9f30,
>> >
>> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
>> > parent_tidptr=0xb75e9f58, {entry_number:6, base_addr:0xb75e9f40,
>> > limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
>> limit_in_pages:1,
>> > seg_not_present:0, useable:1}, child_tidptr=0xb75e9f58) = 25886
>> > futex(0xb75fff58, FUTEX_WAIT, 25885, NULLCounter value functionCount1: 1
>> > Counter value functionCount1: 2
>> > Counter value functionCount1: 3
>> > Counter value functionCount2: 4
>> > Counter value functionCount2: 5
>> > Counter value functionCount2: 6
>> > Counter value functionCount2: 7
>> > Counter value functionCount1: 8
>> > Counter value functionCount1: 9
>> > Counter value functionCount1: 10
>> > ) = 0
>> > munmap(0xb75ea000, 90112)               = 0
>> > munmap(0xb75d4000, 90112)               = 0
>> > writev(1, [{"Final count: 10", 15}, {"\n", 1}], 2Final count: 10
>> > ) = 16
>> > exit_group(0)                           = ?
>> > $
>>
>> Is this a stock 2.4.x kernel or a distro-modified one that might have
>> things backported from 2.6?
>>
>> Can you re-run the strace with:
>>
>>     strace -f -o logfile test_threads2
>>
>> -f is needed to trace anything but the main thread/original process,
>> and -o to a file produces nicer output (pid/tid on each line) than the
>> usual default.
>>
>> Rich
>>
>
>

[-- Attachment #2: Type: text/html, Size: 12936 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21 19:48           ` John Mudd
@ 2014-03-21 19:53             ` Rich Felker
  2014-03-21 20:16               ` John Mudd
  0 siblings, 1 reply; 14+ messages in thread
From: Rich Felker @ 2014-03-21 19:53 UTC (permalink / raw)
  To: John Mudd; +Cc: musl

On Fri, Mar 21, 2014 at 03:48:31PM -0400, John Mudd wrote:
> $ getconf GNU_LIBPTHREAD_VERSION
> NPTL 0.60
> $
> 
> So that's it, I lucked out? I can start building my apps on a modern Linux
> and still run on my older ones? If so then this is like being told time
> travel is possible.

Your luck is just that your kernel that claims to be 2.4 is really
essentially 2.6, so it's not as old as you think it is. My impression
is that "enterprise" vendors like RH like to stick with the version
number that was widely known as being stable and reliable at the time,
and end up applying so many patches/backports/local customizations
that the old version number is pretty misleading.

Anyway, if your goal is just to be able to run programs on this
version of RHEL, you should be fine! If you also need to run on other
old systems that print "2.4" as their version number, you probably
need to do further research.

Rich


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21 19:53             ` Rich Felker
@ 2014-03-21 20:16               ` John Mudd
  2014-03-22 11:12                 ` Szabolcs Nagy
  0 siblings, 1 reply; 14+ messages in thread
From: John Mudd @ 2014-03-21 20:16 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 1603 bytes --]

You're too modest? Here's what I get when I build a simple C program on 2.6
without musl and try to run on the RH "2.4".

$ test_malloc
FATAL: kernel too old
Segmentation fault
$

$ cat test_malloc.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <malloc.h>
#include <memory.h>
#include <assert.h>

int main(int argc, char *argv[])
{
    assert(argc == 2);

    int n = atoi(argv[1]);
    char *c = malloc(n);
    printf("allocated.\n");
    memset(c, 0, n);
    printf("set.\n");
    printf("sleeping...\n");
    sleep(60);

    return 0;
}
$




On Fri, Mar 21, 2014 at 3:53 PM, Rich Felker <dalias@aerifal.cx> wrote:

> On Fri, Mar 21, 2014 at 03:48:31PM -0400, John Mudd wrote:
> > $ getconf GNU_LIBPTHREAD_VERSION
> > NPTL 0.60
> > $
> >
> > So that's it, I lucked out? I can start building my apps on a modern
> Linux
> > and still run on my older ones? If so then this is like being told time
> > travel is possible.
>
> Your luck is just that your kernel that claims to be 2.4 is really
> essentially 2.6, so it's not as old as you think it is. My impression
> is that "enterprise" vendors like RH like to stick with the version
> number that was widely known as being stable and reliable at the time,
> and end up applying so many patches/backports/local customizations
> that the old version number is pretty misleading.
>
> Anyway, if your goal is just to be able to run programs on this
> version of RHEL, you should be fine! If you also need to run on other
> old systems that print "2.4" as their version number, you probably
> need to do further research.
>
> Rich
>

[-- Attachment #2: Type: text/html, Size: 2557 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21 20:16               ` John Mudd
@ 2014-03-22 11:12                 ` Szabolcs Nagy
  0 siblings, 0 replies; 14+ messages in thread
From: Szabolcs Nagy @ 2014-03-22 11:12 UTC (permalink / raw)
  To: musl; +Cc: Rich Felker

* John Mudd <johnbmudd@gmail.com> [2014-03-21 16:16:29 -0400]:
> $ test_malloc
> FATAL: kernel too old
> Segmentation fault

this is printed by glibc

glibc can be built with --enable-kernel=x.y.z to set the minimal
compatible kernel version (it spends an extra uname syscall on this
at startup)

and there is a gnu elf note section with linux os abi that contains
a minimum kernel version (readelf or file(1) can print it), i guess
that comes from binutils

so you may be able to change those and then it will "work"


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Build on linux 2.6 and run on linux 2.4?
  2014-03-21  0:51   ` Rich Felker
@ 2014-03-26  6:22     ` Rich Felker
  0 siblings, 0 replies; 14+ messages in thread
From: Rich Felker @ 2014-03-26  6:22 UTC (permalink / raw)
  To: musl

On Thu, Mar 20, 2014 at 08:51:35PM -0400, Rich Felker wrote:
> > However, Linux 2.4 is not officially supported since it lacks a lot of
> > functionality needed to provide a modern POSIX conforming environment.
> > The most notable is that it can't do threads. If you're ok with that,
> > the other problems might be small enough that you don't mind. I
> > remember some people in Freenode #musl trying out 2.4 recently and
> > finding that a few of the busybox applets didn't work right, though,
> > due to missing statfs64 syscall.
> > 
> > This page has details on which kernel versions added which syscalls:
> > 
> > http://man7.org/linux/man-pages/man2/syscalls.2.html
> 
> I looked through this list, and statfs64/fstatfs64 seem to be the only
> two syscalls where the 32-bit off_t version was all that's available
> in 2.4 and the 64-bit version was added in 2.6. So if we could provide
> a fallback for them, this might make 2.4 a fairly viable target for
> single-threaded programs built with musl. (Despite 2.4 being ancient
> and generally a bad idea to use, there are some devices where
> replacing the kernel is hard or where the patches to support the
> device have not been ported to 2.6, so this isn't just a useless
> exercise.)
> 
> The big question that remains of course is how ugly the fallbacks
> would be, and whether we'd need a lot more arch-specific definitions
> _purely_ for 2.4 fallback.

While investigating possible thread pointer fallbacks for phase 2 of
the lazy thread pointer init removal, I discovered that it seems
possible to provide threads even on 2.4, at least for i386. The
modify_ldt-based approach to setting the thread pointer should work
for multiple threads, not just the main thread. However there are
definitely other syscalls 2.4 is missing that would need some
fallbacks to achieve reasonable behavior, even for non-multithreaded
programs. For example, even raise() is likely to be failing now due to
missing tgkill.

So I think we can fairly safely say up til now musl on Linux 2.4 is
quite broken and unlikely to work, even for many simple apps. In a way
that's good because it means it's very unlikely that changes related
to removing lazy thread-pointer init are breaking anything that worked
before. But it's also unfortunate that users who want to run static
musl binaries on ancient kernels might encounter a lot of breakage.

I *think* basic, reasonable support for 2.4 (in the sense of having at
least code that worked back when 2.4 was current still work now) could
probably be achieved without significant complexity or bloat. If
anyone wants to research this, it's basically just a matter of looking
at what functions, other than think syscall wrappers for the new
syscalls themselves, depend on syscalls added after 2.4. In most cases
I think reasonable fallbacks (using whatever old syscalls were used
back then) should be possible, and with inline syscalls such fallbacks
are unlikely to consume more than a few bytes of additional size.

Is anyone interested in looking into this?

[Note that none of this affects John Mudd's (OP's) usage case since
his kernel, despite calling itself 2.4, is a RHEL kernel that's
essentially 2.6.]

Rich


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-03-26  6:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-20 20:58 Build on linux 2.6 and run on linux 2.4? John Mudd
2014-03-20 23:14 ` Rich Felker
2014-03-21  0:51   ` Rich Felker
2014-03-26  6:22     ` Rich Felker
2014-03-21 13:02   ` John Mudd
2014-03-21 16:40     ` Rich Felker
2014-03-21 17:54     ` John Mudd
2014-03-21 18:02       ` Rich Felker
2014-03-21 18:24         ` John Mudd
2014-03-21 19:09           ` Rich Felker
2014-03-21 19:48           ` John Mudd
2014-03-21 19:53             ` Rich Felker
2014-03-21 20:16               ` John Mudd
2014-03-22 11:12                 ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).