[mercury-users] Heap space limited for C when called from Mercury?
Ondrej Bojar
oboj7042 at ss1000.ms.mff.cuni.cz
Tue Mar 11 03:31:11 AEDT 2003
Hi.
I'm calling a lot of C/C++ code from Mercury and this C++ code allocates
some (not too much, in current relations) memory. However, the C++ code
crashes on a 'new' something.
Is the size of heap limited for C code? Or is the heap probably already
corrupt at that state?
The behaviour after the unsuccessful 'new' is quite odd:
Mercury reports:
*** Mercury runtime: caught segmentation violation ***
caught fault at 0x29000e90
address not in any redzone.
PC at signal: 135671916 (816306c)
address involved: 0x29000e90
This may have been caused by a stack overflow, due to unbounded recursion.
*** Mercury runtime: caught segmentation violation ***
caught fault at 0x74
address not in any redzone.
PC at signal: 135521813 (813e615)
address involved: 0x74
This may have been caused by a stack overflow, due to unbounded recursion.
..and the second message then loops ad infinitum.
Running the program in gdb confirms the crash in malloc:
Program received signal SIGSEGV, Segmentation fault.
0x0816306c in malloc ()
(gdb) where
#0 0x0816306c in malloc ()
#1 0x0814bf2d in __builtin_new (sz=8) at ../../gcc/cp/new1.cc:-1
#2 0x08081ff6 in CHandlSeznam::nastav_arg ()
#3 0x0809a07c in db_update ()
#4 0x08095b85 in connect_to_server (name=0x819f085 "localhost",
port=24444,
SentencesHeard=0xbffff3cc, ArgumentFromWS=0xbffff3c8,
DeadFlag=0xbffff3c4)
at core_cint.cc:60
#5 0x08048f73 in communicator__c_connect_to_server_5_p_0 (
communicator__Host_1=0x819f085 "localhost",
communicator__Port_2=24444,
communicator__Status_3=0xbffff440) at communicator.m:116
#6 0x08049309 in communicator__connect_to_server_6_p_0
(communicator__DB_7=0,
communicator__Host_8=0x819f085 "localhost",
communicator__Port_9=24444,
communicator__OutStatus_10=0xbffff49c) at communicator.m:42
#7 0x08048715 in main_2_p_0 () at chatter.m:22
#8 0x0813c26b in MR_do_interpreter () at mercury_wrapper.c:1652
#9 0x080485fc in mercury_main (argc=2, argv=0xbffff594) at
chatter_init.c:1266
#10 0x0804861c in main (argc=2, argv=0xbffff594) at chatter_init.c:1276
#11 0x0814ec92 in __libc_start_main ()
Here, gcc 2.96 is used, and I cannot do anything with it.
As I really do not like C/C++, and I'm not too experienced with it (the
code is not mine), I cannot think of any technique for for catching heap
corruption bugs. Could you please suggest me something?
Thanks a lot, Andrew.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list