QNX6.5.0 SP1 problem with posix_memalign

In QNX6. 5.0SP1 appears mistake in posix_memalign.
Test program

cat Test.c

#include <stdlib.h>
int main(int argc, char argv)
{
void ptr = 0;
posix_memalign(&ptr, 16, 16 - 2 * sizeof (void
));
posix_memalign(&ptr, 32, 32 - 2 * sizeof (void
));
posix_memalign(&ptr, 64, 64 - 2 * sizeof (void
));
posix_memalign(&ptr, 128, 128 - 2 * sizeof (void*));
return (0);
}

gcc -g -o Test Test.c

After starting - ./Test the program is standing in the STATE = RUNNIG state.
This state is caused by:
posix_memalign(&ptr, 128, 128 - 2 * sizeof (void*));

gdb Test

GNU gdb 6.8 qnx-nto (rev. 506)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type “show copying”
and “show warranty” for details.
This GDB was configured as “i486-pc-nto-qnx6.5.0”…
(gdb) start
Temporary breakpoint 1 at 0x8048699: file Test.c, line 4.
Starting program: /root/Test0
[New pid 2007084 tid 1]

Temporary breakpoint 1, main (argc=1, argv=0x8047a04) at Test.c:4
4 void ptr = 0;
(gdb) n
5 posix_memalign(&ptr, 16, 16 - 2 * sizeof (void
));
(gdb)
6 posix_memalign(&ptr, 32, 32 - 2 * sizeof (void*));
(gdb)
7 posix_memalign(&ptr, 64, 64 - 2 * sizeof (void*));
(gdb)
8 posix_memalign(&ptr, 128, 128 - 2 * sizeof (void*));
(gdb) <= and the program is standing in this place in the RUNNIG state
<= After the interrupt - Ctrl C
Program received signal SIGINT, Interrupt.
0xb032799f in _band_get_aligned () from /usr/qnx650/target/qnx6/x86/lib/libc.so.3
(gdb) q
The program is running. Exit anyway? (y or n) y

I think that the problem lies in the function _band_get_aligned from libc.

I will grant you that there is a bug here. I think the question is, what do you want to do about it?

If you want it fixed, you will have to report it to QNX. If you have a service contract with them, it will be given a tag and dealt with in some order that probably depends on what level of service you’ve paid for.

The only circumstance in the last 25 years that I’ve needed memory alignment beyond size 4, was when doing a driver that needed 64K alignment to avoid having a DMA channel crossing a 64K boundary. That was only necessary with an ISA bus. So I’m wondering if your point is academic or whether you really need 128 byte alignment? If this is an academic point, I’d mention it to QNX but I wouldn’t expect a fix anytime soon.

If you don’t have service contract and/or need a solution more quickly than you are likely to get from QNX, you could write your own allocator on top of malloc()/free() as follows:

Allocate the amount requested + 128.
Adjust the start position so it is aligned.
You will need some way to keep track so when you call free() you are using the right start location.

I not need 128 byte alignment. Problem with glib2 in QNX SP1.
In the QNX 6.5.0 with glib2 was not the problem. SP1 for QNX introduces changes that cause lockups programs using glib2.
From my analysis shows that feature posix_memalign to allocate the memory areas used by glib2 causes these problems.
Test.c I have done on the basis of the configure with glib-2.32.3. Because just testing the posix_memalign configure hangs.
And Test c shows this exactly.
This is not good, that in this case the program does not terminate with an error and is constantly in of RUNNIG state.
This probably has nothing to do with the real time.
I have worked with the QNX2, QNX4 and QNX6. Now since a few years I only QNX hobbyist.
So the problems I am presenting only on Foundry27, openqnx.com and qnx.org.ru. And only on qnx.org.ru and openqnx.com received a response. Thank you
I would like to find such solutions which will work with the software using glib2, as it was until now in QNX.
The more that recently I compiler GNAT GPL 2012 to QNX 6.5.0 and I’d like to test the GtkAda. And for this it is necessary to GNOME.
And still I don’t understand why there is no formal programming language ada in QNX.
Is it prevented the possibility of using QNX in multiple projects.

Ok, so glib2 wants 128 byte aligned data. I think it’s open source in which case you could either remove the alignment requirement or write your own routine to fill in as I previously described. My guess is that glib2 is designed to run on architectures other than x86 which need this. To the best of my knowledge, x86 needs no alignment to run, although providing align(4) may speed up some instructions.

You made it clear that you are a hobbyist without a QNX support contract. In which case you will not be able to request and get a fix from QNX.

It’s probably a bug that has left the code in a loop.

As I understand it, Gtk has been ported to QNX, but Ada has not. There are many interesting compilers that (as far as I know) haven’t been ported to QNX. ALGOL, APL, Fortran, Snowball, LISP, Forth, C#, Objective C, PL/1, the list is long. The only entity I ever recall having a concerted interest in Ada was the US department of defense. I’m not sure why QNX would have a big interest in porting it.

Gtk, glib has been ported to QNX. Ada, GNAT GPL 2012, Fortran, Gprolog and Objective C also have been ported to QNX.
See my web page http://www.ajamweb.pl.
GNAT GPL 2012 is the integrated Ada, C, and C++ toolset. This release provides support for most features in the upcoming Ada 2012 language revision as well as many other improvements to the compiler and toolset. http://libre.adacore.com/