Hi all, I am porting an application written in HP-UX to Linux [pure C] for unobvious reasons like Linux being wider and cheaper supported Unix platform for cheap IBM/PC arch. Somehow the client my employer has put in service of - seems to agree with me. So here I am - porting the application to Linux. Luckily, except for datatype "long long", all the basic datatypes are of the same width. Hence run-time errors shall be less.
But here is one. Below is the output from gdb's command "where" - the stack at the time of failure. I get a segmentation violation while running - at the time of a malloc. There are printf statements both before and after the malloc - as well as /proc/meminfo is examined before and after malloc. malloc - supposed to return null if the request is not complete - seems to be crashing. Take a look and see if anyone can see something good here? [wrapped lines are actually contiguous] --------- piece of code --------- -- struct RegistryItem *new_item2 = NULL; -- printf("Malloc for %s, size = %d\n", name, sizeof(RegistryItem)); system("cat /proc/meminfo > /home/rohit/Code/Mediator/refmt_base/port_test/asm/memory"); system("echo ABOUT TO MALLOC >> /home/rohit/Code/Mediator/refmt_base/port_test/asm/memory"); new_item2 = malloc(sizeof(RegistryItem)); printf("Malloc returned "); printf(" %p\n", new_item2); system("cat /proc/meminfo >> /home/rohit/Code/Mediator/refmt_base/port_test/asm/memory"); ---- So as you see - I am trying to access all that I can. Program fails on console with this message: Malloc for 19_1_-1_0, size = 40 Malloc returned 0x8077d28 Malloc for 19_1_21_1, size = 40 mediator_cmd:F:*** Trapped signal 11: (Segmentation violation ---- Contents of memory file, rewritten to check status of memory available, are: rohit@force:~/Code/Mediator/refmt_base> cat port_test/asm/memory total: used: free: shared: buffers: cached: Mem: 129925120 125538304 4386816 0 8687616 40652800 Swap: 271425536 1200128 270225408 MemTotal: 126880 kB MemFree: 4284 kB MemShared: 0 kB Buffers: 8484 kB Cached: 38756 kB SwapCached: 944 kB Active: 43928 kB Inactive: 60300 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 126880 kB LowFree: 4284 kB SwapTotal: 265064 kB SwapFree: 263892 kB ABOUT TO MALLOC -- and then it fails. >From gdb, I took a trace of stack using "where" and this followed: Program received signal SIGSEGV, Segmentation fault. 0x400edd65 in chunk_free () from /lib/libc.so.6 (gdb) where #0 0x400edd65 in chunk_free () from /lib/libc.so.6 #1 0x400eda3a in chunk_alloc () from /lib/libc.so.6 #2 0x400ed224 in malloc () from /lib/libc.so.6 #3 0x40043705 in register_item2 (which=4, name=0xbfffc590 "19_1_21_1", location=0x8077b88, nelem=1, stat_ind=0, clear_ind=0, is_dyn=0) at registry.c:909 #4 0x401a2ccb in process_aggregate_list (path=0x8051238 "ddt/aggregate_table.dat") at aggregate_table.c:660 #5 0x401a223b in ddt_load_aggregate_table (name=0x8051200 "ddt_aggregate_table", source=0x8051238 "ddt/aggregate_table.dat", location=0xbfffc874, nelem=0xbfffc870, argument=0x0) at aggregate_table.c:223 #6 0x4001eeab in call_load_functions () at /home/rohit/Code/Mediator/refmt_base/programs/additionaldata.c:769 #7 0x400229c0 in load_or_display_file (disp_f=0) at /home/rohit/Code/Mediator/refmt_base/programs/load_or_display.c:739 #8 0x40022a1d in load_file () at /home/rohit/Code/Mediator/refmt_base/programs/load_or_display.c:753 #9 0x080499f2 in main (argc=11, argv=0xbffff1f4) at reformatter_cmd.c:361 #10 0x400969ed in __libc_start_main () from /lib/libc.so.6 (gdb) This was quite a mail. Can anyone let me know what is familiar here? I shall meanwhile try and see if there are any updated available for libc. Rohit __________________________________________________ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ linux-india-help mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/linux-india-help