Programming :: Why Malloc() Blocks/sleeps
Jun 2, 2010I have encountered this scenario wherein malloc does not return.
Code:
char * tmp;
rs = 100 to 40000 bytes
[code]...
I have encountered this scenario wherein malloc does not return.
Code:
char * tmp;
rs = 100 to 40000 bytes
[code]...
How do you malloc a struct in C? I have a structure of the form:
Code:
typedef struct child_req_to_parent
{
[code]...
So far I have this:
Code:
int mm_init (mm_t *MM, int hm, int sz) {
int i;
[code]...
Code:
#include <stdio.h>
#include <stdlib.h>
[code]...
So the place where I'm having a problem is here:
Code:
typedef struct {
void **Mem_Chunk;
[code]...
I am developing a code where I need to store the planes of an object in a tree & also i need to store it in a list for further processing ... when I try to allocate using malloc the memory allocation when i checked this in internet , I came to know that it may because the memory that I am trying to allocate may be more than the size_t variable.
View 9 Replies View RelatedIs there a way to hook calls to new/malloc, delete/free in C++? I tried the following methods: LD_PRELOAD -> fails for malloc, because dlsym seems to depend on malloc -Wl,--wrap,malloc -> doesn't work for 'new' gcc hooks -> doesn't work always, e.g. for uclibc there are no hooks Are there any other methods I could try?
View 2 Replies View RelatedI am new to C and linux. My code below does arbitary writes but I cant figure out where or how it does it.
I am calling the insertNode() function with seq = 'MISSISSPPI$' and alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ$'
Code:
Weird behaviour I should mention is that when I check for NULL pointer in node->child[index], the unassigned values are not null anymore, they point to arbitary memory.
I have created an application that has a executable program that loads in a shared object
the shared object loads in another shared object
both of these shared object I have created
For debugging I have been printf'in data to determine what is going on
I now have some odd memory issue, and need a bit more control over debugging...
I have one workspace set up and under my exectuable(will call maintest from now on) I have two items in my link libraries under project build options being soA and soB (so A is the shared object that maintest uses, soB is the SO that soA uses) I also have linker options pthread and ldl
At the beginning of my maintest I do my dlsym and load in each function that I will be using
I always run my program using maintest, because when I have one of the SO as the startup project(turns bold) and try to run it gives me "You must select a host application to run a library"
I tried to set up this host library, i Go to Menu->Project->SetProgramArguments and change the Host Application to the debug version of my maintest
I then hit OK and try to run again but I get the same error: "You must select a host application to run a library"
If I get this part working - which I need help doing, is tehre other steps that need to be taken to debug the so's? or will this make it so when i hit f8 it will run.
My problem is that for an encrypted server my client blocks after I send the QUIT command to the server and I do not know the reason why my client blocks.
Language C, Library openssl, IP4.
Compiler: gcc.
Output:
send: STLS
receive: +Ok ssl handshake
send: USER XXXXX
receive: +OK
send: PASS ***
receive: +OK
Send: STAT
receive: +Ok 0 0
send: QUIT
receive: blocks
At this point I need to use crtl^C to exit the program.
For the non-encrypted mail client everything works fine.
I have been searching previous posts but could not find an example which works with my data. I think I might be the spaces in my fields. I have a massive data file and need to join 5 line blocks separated by a comma.
Code:
2
111.222.333.444
host.edu
[code].....
I am trying to make a perl script which reads data from a file and parse it. The data in the file has the following syntax
Code:
Device Physical Name : Not Visible
Device Symmetrix Name : 1234
Device Serial ID : N/A
Attached BCV Device : N/A
Device Capacity
[Code]...
Each unique record starts with "Device Physical Name". So, I have a set of records within "Device Physical Name". I want to read this set of records starting from "Device Physical Name" and ends up till next "Device Physical Name". Offcourse FS is ":", and I just want to print/or later put info in a csv file.
I am writing a C program which is contains Mysql header files and APIs but it can not compile it and its error is : Quote: undefined reference to
to all of Mysql APIs that I included their headers .In command line I compile my source like this with no problem: Quote: gcc test.c -Wall -o test -lz `mysql_config --cflags --include --libs`
I think code block does not have bold italic part of this command. How can I add this to code block to compile my project or those project that contains Mysql APIs (just my project not all of defined projects that has no relation to mysql APIs)with this gcc flags.
I am writing a C program which is contains Mysql header files and APIs but it can not compile it and its error is :
Quote:
undefined reference to
to all of Mysql APIs that I included their headers .In command line I compile my source like this with no problem:
Quote:
gcc test.c -Wall -o test -lz `mysql_config --cflags --include --libs`
I think code block does not have bold italic part of this command. How can I add this to code block to compile my project or those project that contains Mysql APIs (just my project not all of defined projects that has no relation to mysql APIs)with this gcc flags.
I use debian sidunstable. When I suspend my PC, it does sleep fine, but when I try to wake it up, I get a black screen.
View 3 Replies View RelatedI configured Dell Latitude D620 to go to sleep mode (suspend to ram) when i close the lid. It suspends ok and then I open the lid. It wakes up ok, but few seconds after goes to sleep again! So I need to press the power button to force it to wake up.
Sleep button works just fine. /etc/acpi/sleep.sh from console too.
/etc/acpi/events/lidbtn
Code:
event=button[ /]lid
action=/etc/acpi/sleep.sh
update:
I noticed that it always goes to sleep again when I wake up laptop by opening the lid. For example if I run /etc/acpi/sleep.sh, pm-suspend or press the sleep button laptop goes to sleep, then i close the lid and when i open it back - the problem occurs.
So I've recently switched over to Ubuntu as my media center OS, and I'm running Hulu Desktop (which works very nicely).
The problem is, the screen keeps sleeping on me after inactivity and it won't come back unless I use the keyboard or mouse (the remote won't wake it). The computer is still running, audio and all - and just a black screen.
I have the screensaver set to never, the power saving settings set as high as they go - and it still does it.
I've searched the forums for a solution but I can't seem to come up with anything; any ideas?
Looks like I found a solution; Caffeine (launchpad.net/caffeine) is a little applet that will disable sleep/screensaver while in certain apps (or for a certain amount of time). I don't know why changing the system preferences wouldn't accomplish this, but Caffeine did the trick anyway (and actually works out better anyway)
Running 9.10 on the computer I am having a terrible time with.
Intro
I have a small office of 5 comps. I had a guy come in to change the router to a bigger one, to go from 4 to 8 outlets. I was changing the service, so first we went to the new company's smaller router and then to the bigger one.
Well, my old Dell and another older box never could get reconnected after the guy pulled out the smaller one and put in the bigger one. First migration was fine though.
I believe I have seen this problem before. I have had several instances of weird internet outages involving single (or worse, a pair of) machines that eventually can go back online. There are some serious bugs in NetworkManager I think which are putting these devices to sleep.
Symptoms
Symptoms I have already seen a lot around here. Yes, I have lights where the line goes in. The system will try to get a dhcp lease and then give up, telling me I am disconnected. That's it. I tried to install wicd on the machine that I reinstalled (again to 9.10), but it was the same, no way to get an IP address.
I have nothing in the networkmanager.state file at all. My nm.config.settings has a no-auto-default:00:16:82:XX:XX line.
And of course in frustration I deleted the eth0, so now I had to make a new one, and its not default.
Obligatory Begging
There is no way two machines have the same hardware problem at the same time. Plus, this is the third time in 6 months I have had two machines with connection problems, where we were checking lines against windows machines and wondering about hardware.
I am already resigned to re-installing on the Dell and hoping it goes ok (its really old). And on the other box (a server) I even re-installed multiple times and it still won't work at all, same symptoms. So I am worried at this point that both might be fuXXored by this bug.
I have very small ARM computer with Ubuntu 9.04 (Jaunty) running as a backup and media server for my house. I have attached a new "WD My Passport" 750GB USB drive to it. The drive is recognized and I can mount it and read/write files fine. After several minutes, the drive goes to sleep, even if I was in the middle of writing a backup to it. I can force it to start again with sdparm, but it needs to not shut itself down while it's being written to in the first place. I have tried this command to disable the standby state but it doesn't work:
root@Plug:~# sdparm --clear STANDBY -6 /dev/sdb
/dev/sdb: WD My Passport 0730 1008
change_mode_page: failed setting page: Power condition
I have also been told to change /sys/block/sdb/device/allow_restart from 0 to 1, but no such file exists and one cannot be written there. The hardware itself is fine, if I plug it into a Windows computer, it will not sleep while in use.
i have set the display to go to sleep after 5 min. but it still goes to sleep when i am watching movie.
how can i stop this, it should only go to sleep when it is ideal, not when i am watching movie
I am having a problem watching videos and such in 10.04 LTS, In power management I have display set to sleep in 1 hr but it is going to sleep every 10 minuets and prompting for my password everytime I make a mouse or keyboard movement. Makes it kind of difficult to watch a video.
View 3 Replies View RelatedI am using read() in c++ to get data from a serial port. However, if no data is available on the serial port the function blocks until dta arrives.Example code:
//------------------------------------------------------------
char m_readBuffer[255] = {0};
char* p_curChar = m_readBuffer;
[code]...
#include<stdio.h>
#include<stdlib.h>
int main()
[code]...
I'm trying to compile ink but with no luck. Here are the terminal output,
Code:
[trumpet@Trumpet-PC ink-0.5.1]$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
[code]...
I am getting a weird compilation error with malloc.h/usr/include/malloc.h:86: error: expected ')' before '__size'This is what the code looks like inside malloc.hextern void *(*__morecore) __MALLOC_PMT ((ptrdiff_t __size))When I did some googling, it was stating that ptrdiff_t was not defined; but, it is.#define __malloc_ptrdiff_t ptrdiff_t
View 4 Replies View RelatedI'm afraid I have a huge issue with my newest Fedora 14 server. I recently migrated to Fedora 14 from Centos 5, which was very stable, but had ancient packages and libraries and my users were revolting...The machine is a HP ProLiant 360 G7, with 12G RAM and 6 SAS drives in RAID 5.After I migrated to Fedora 14, I noticed that for some reason, during the course of about 24 hours, all usable RAM "disappears" and applications are forced down to swap space. Needless to say I didn't have this issue on CentOS.
The server does heavy IO as per it's function (it's a heavily loaded file processing server and user simulation computing station among other things, which causes lots of random IO), so I thought it may be the cache, but then I realized it cannot be - because obviously Linux will use onyl "unused" RAM for caching and frees it up as soon as an app need it. Then, I thought to check the "slabtop" to see what's going on in Kernel memory. Unfortunately I don't have the screenshot from the time just before the latest crash, but there's a certain value displayed by slabtop, which slowly, byte-from-byte creeps over all available RAM, eventually forcing applications down to the swap. This is malloc-64, and as you can see from the bellow copy-paste, it's building up again even now...
Code:
Active / Total Objects (% used) : 9118075 / 9153600 (99.6%)
Active / Total Slabs (% used) : 152157 / 152157 (100.0%)
[code]...
I have been trying to fix this problem for 3 days, any ideas before I jump through the window (not the bill gates one)?I am using ubuntu 9.10 and running a ./configure.
View 3 Replies View RelatedOur Fedora-ds was down for some reason,And I got these logs:
[23/Dec/2010:18:59:32 +0200] - libdb: User-specified malloc function returned NULL
[23/Dec/2010:18:59:32 +0200] - id2entry error 12
[23/Dec/2010:18:59:32 +0200] - id2entry get error 12
[code]...
When I am trying to run my application on RHEL 6 (Kernel 2.6*), I am getting the following error.*** glib detected *** ./corenms:malloc(); memory corruption : 0x086691d0 ***
View 4 Replies View RelatedLet's analyse this While registering a Char deriver to kernel think that we had allocated memory using any of malloc/kmalloc/vmalloc.
If we forgot to Free that allocated memory while unregistering, will that memory be allocated aside or kernel clears it...?