Skip to contentSkip to conversation

Problem with MALLOC_CHECK_

Xenomai Bill Vareka 2 participants 2 messages Sep 7, 2012

lore
Share & tools
lore
#0 lore raw

We've discovered a weird problem. Basically, when using the xenomai
posix skin and allocating and releasing large amounts of memory in a secondary mode thread, the application corrupts the entire system (kernel and all) *if* the MALLOC_CHECK_ macro is disabled. Attached is a simple c++ demo program showing this problem (compile with gcc). If you compile using standard posix it works no matter what. If you compile using the xenomai posix skin, then if the environment variable MALLOC_CHECK_=3 then the program runs fine with no problems. However, if you run with MALLOC_CHECK_=0 then the program appears to corrupt system memory. After running this program, less, cat, and other standard programs now segfault and won't run. Also in our case, we see that the output of ifconfig is also corrupted (shows table data rather than normal format). The kernel is completely unstable.
We have encountered the problem before without identifying the source. Currently this affected us because our application ran fine under a login shell when testing (since it automatically defined the env var) but when we added a launch script to sysVinit to automatically launch it at startup, it failed because the environmental variables were much different there and did not define this variable.

Again, our app is C++ and this test is with stl strings but I strongly suspect the same behavior can be generated using a standard C program and malloc/free.

Our setup:

architecture x86 32-bit
Linux 2.6.38.8
adeos ipipe 2.11-01
xenomai-2.6.1
gcc46-4.6.2_20111026-1.1.4.i586
libstdc++46-4.6.2_20111026-1.1.4.i586
glibc-2.14.1-14.12.2.i686

Regards,
Bill Vareka
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: memtst.cpp
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20120907/ad3c81c5/attachment.ksh>

#1 lore raw
Quoted 24 lines · Bill Vareka

We've discovered a weird problem. Basically, when using the xenomai
posix skin and allocating and releasing large amounts of memory in a secondary mode thread, the application corrupts the entire system (kernel and all) *if* the MALLOC_CHECK_ macro is disabled. Attached is a simple c++ demo program showing this problem (compile with gcc). If you compile using standard posix it works no matter what. If you compile using the xenomai posix skin, then if the environment variable MALLOC_CHECK_=3 then the program runs fine with no problems. However, if you run with MALLOC_CHECK_=0 then the program appears to corrupt
system memory. After running this program, less, cat, and other
standard programs now segfault and won't run. Also in our case, we see that the output of ifconfig is also corrupted (shows table data rather than normal format). The kernel is completely unstable.
We have encountered the problem before without identifying the source. Currently this affected us because our application ran fine under a login shell when testing (since it automatically defined the env var) but when we added a launch script to sysVinit to automatically launch it at startup, it failed because the environmental variables were much different there and did not define this variable.

Again, our app is C++ and this test is with stl strings but I strongly suspect the same behavior can be generated using a standard C program and malloc/free.

Quoted 5 lines

Our setup:

architecture x86 32-bit
Linux 2.6.38.8
adeos ipipe 2.11-01

Could you check the I-pipe patch for Linux 3.2? It has this commit:
http://git.denx.de/?p=ipipe.git;a=commit;h=c9f834f80257c4e7c2c01a3c6d34f5485af2be51

Which 2.6.38 does not appear to have.

Signature · 1 line
                                                                Gilles.