*** glibc detected *** ./test: free(): invalid pointer: - resultset

I am trying to fetch and store ID and Status from Database using statements ID = r->getInt(1) and stat = r->getString(10) where I have declared ID as int and stat as string.
Where first field is an ID containing value 1 and 10th field is status containing value 'A'.
If I try to fetch only ID, my code works fine. Else, when I try to fetch status as well, then while running the code, I am getting below mentioned error:
*** glibc detected *** ./test: free(): invalid pointer: 0x000000001c3f5a60 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3d23e71684]
/lib64/libc.so.6(cfree+0x8c)[0x3d23e74ccc]
/usr/lib64/libstdc++.so.6(_ZNSsD1Ev+0x3a)[0x3d28a9dc1a]
./test[0x401837]
./test(__gxx_personality_v0+0x310)[0x401120]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x3d23e1d8b4]
./test(__gxx_personality_v0+0x89)[0x400e99]
Please help.
Adding just the basics of what I am trying to achieve:
char loader_session[10];
char sql_query[500];
int ID;
string STATUS;
string CURRENT_CNT_FILE
env = Environment::createEnvironment (Environment::DEFAULT);
conn = env->createConnection( user, passwd, db);
strcpy(loader_session,"TEST");
sprintf(sql_query,"SELECT ID, SESSION_NAME, SRC_SUCCESS_PATH, SRC_CDR_PATH, LOG_FILE, CURRENT_CNT_FILE, LOG_MAX_FILE_CNT, LOG_MAX_FILE_SIZE, PROCEDURE_NAME, STATUS, ERROR_CDR_PATH, LOCK_FILE_PATH FROM TEST_DB WHERE SESSION_NAME = '%s'",loader_session);
Statement* const s = conn->createStatement(sql_query);
s->setPrefetchRowCount(10);
ResultSet* const r = s->executeQuery();
while (r->next())
{
ID = r->getInt(1);
STATUS = r->getString(10);
CURRENT_CNT_FILE = r->getString(6);
}

Ok I got a temporary solution for my question. Just by setting MALLOC_CHECK_ to 0, I am not getting the error and my code is running fine. Don't know the side effects of this, but as of now, it's working fine.

Related

Bro script for reading a list of Ips and domains

I am trying to read a file with a list of IP addresses and another one with domains, as a proof of concept of the Input Framework defined in https://docs.zeek.org/en/stable/frameworks/input.html
I´ve prepared the following bro scripts:
reading.bro:
type Idx: record {
ip: addr;
};
type Idx: record {
domain: string;
};
global ips: table[addr] of Idx = table();
global domains: table[string] of Idx = table();
event bro_init() {
Input::add_table([$source="read_ip_bro", $name="ips",
$idx=Idx, $destination=ips, $mode=Input::REREAD]);
Input::add_table([$source="read_domain_bro", $name="domains",
$idx=Idx, $destination=domains, $mode=Input::REREAD]);
Input::remove("ips");
Input::remove("domains");
}
And the bad_ip.bro script, which check if an IP is in the blacklist, which loads the previous one:
bad_ip.bro
#load reading.bro
module HTTP;
event http_reply(c: connection, version: string, code: count, reason: string)
{
if ( c$id$orig_h in ips )
print fmt("A malicious IP is connecting: %s", c$id$orig_h);
}
However, when I run bro, I get the error:
error: Input stream ips: Table type does not match index type. Need type 'string':string, got 'addr':addr
Segmentation fault (core dumped)
You cannot assign a string type to an addr type. In order to do so, you must use the utility function to_addr(). Of course, it would be wise to verify that that string contains a valid addr first. For example:
if(is_valid_ip(inputString){
inputAddr = to_addr(inputString)
} else { print "addr expected, got a string"; }

Getting an invalid token on an interpolated string sent from python/jinga2 backend

I'm sending a variable called apiID from a tornado/jinja2 python file to my vuejs template like this:
class SmartAPIUIHandler(BaseHandler):
def get(self, yourApiID):
doc_file = "smartapi-ui.html"
dashboard_template = templateEnv.get_template(doc_file)
dashboard_output = dashboard_template.render(apiID = yourApiID )
self.write(dashboard_output)
then in vuejs I'm interpolating the variable with no problem except it gives me an error
it says: Uncaught SyntaxError: Invalid or unexpected token
I checked on the python handler file and apipID is a string, so I don't see the problem. I'm quite new to python so maybe the answer is more obvious to one of you. I appreciate the help!!
Because of dashboard_output = dashboard_template.render(apiID = yourApiID ), you must have, in your template, something around the code:
this.apiID = {{ apiID }};
Due to the value being not a number but a string, add the 's:
this.apiID = '{{ apiID }}';

ABAP Webdynpro error in supply function for a singleton

The following error text was processed in system EH5 : Invalid operand type for the MOVE-CORRESPONDING statement.
◾ The error occurred on the application server CRMEHP2_EH5_24 and in the work process 8 .
◾ The termination type was: RABAX_STATE
◾ The ABAP call stack was:
Method: IF_WD_CONTEXT_ELEMENT~GET_STATIC_ATTRIBUTES of program CL_WDR_CONTEXT_ELEMENT========CP
Method: BOOKINGS_READ of program /1BCWDY/0AA4D2ZOSMXD1LD8M8M2==CP
Method: BOOKINGS_READ of program /1BCWDY/0AA4D2ZOSMXD1LD8M8M2==CP
Method: SUPPLY_ELEMENTS of program CL_WDR_CONTEXT_NODE_VAL=======CP
Method: IF_WD_CONTEXT_NODE~GET_LEAD_SELECTION of program CL_WDR_CONTEXT_NODE_VAL=======CP
Method: IF_WD_CONTEXT_NODE~GET_LEAD_SELECTION of program CL_WDR_CONTEXT_NODE_MAP=======CP
Method: GET_LEAD_SELECTION of program CL_WDR_TABLE_DATA_PROVIDER====CP
Method: UPDATE_RANGE_SELECT_START of program CL_WDR_TABLE_DATA_PROVIDER====CP
Method: GET_TABLE_DATA of program CL_WDR_TABLE_DATA_PROVIDER====CP
Method: GET_VISIBLE_TABLE_DATA of program CL_WDR_TABLE_DATA_PROVIDER====CP
I have created two controllers
Componentcontroller is bound to flightinfo table. This table is populated. However, if_componentcontroller=>element_flightinfo dosen't fetch any data. Why?
Customcontroller2 is bound to bookingtab table.
Method:
**METHOD bookings_read.**
DATA:
stru_flight TYPE if_componentcontroller=>element_flightinfo,
itab_booking TYPE if_customcontroller2=>elements_bookingtab.
* Get Parent Element.
* Error is here: All attributes of stru_flight are either blank or zero.
* The error disappears once CALL METHOD is commented.
CALL METHOD parent_element->get_static_attributes
IMPORTING
static_attributes = stru_flight.
* read bookings
*Rest of the satatements work fine.
SELECT * FROM sbook
INTO CORRESPONDING FIELDS OF TABLE itab_booking
WHERE carrid = stru_flight-carrid
AND connid = stru_flight-connid
AND fldate = stru_flight-fldate.
* bind all the elements
node->bind_table(
new_items = itab_booking
set_initial_elements = abap_true ).
**ENDMETHOD.**
Definition of parent_element, and stru_flights structure
NODE Importing IF_WD_CONTEXT_NODE
PARENT_ELEMENT Importing IF_WD_CONTEXT_ELEMENT
stru_flight TYPE if_componentcontroller=>element_flightinfo,
**CALL METHOD parent_element->get_static_attributes
IMPORTING
static_attributes = stru_flight.**
implicit constant definition for context node bookingtab types:
Element_bookingtab type SBOOK,
Elements_bookingtab type standard table of Element_bookingtab with default key.

NSManaged object sometimes is null and causes crash

I am using coredata and often my app crashes because one of the properties of a managed object turn out null. For example when i set text of a UILabel to a text property of the managed object it displays NULL
To find the problem I overrode the setter which assigns the NSManagedObject to a instance variable. In the setter I use NSLog to print the object:
NSLog(#"TSC: setting segment: %#", segment);
its output:
2012-11-05 21:01:56.758 JetLagged[4505:907] TSC: setting segment: <Segment: 0x1d0ab790> (entity: Segment; id: 0x1d0a7f60 <x-coredata://BF6F2D98-0658-4005-8BEF-9FE6B398AF86/Segment/p8> ; data: {
arrivalDate = "2012-11-11 05:00:17 +0000";
arrivalLeg = "0x1d0abba0 <x-coredata://BF6F2D98-0658-4005-8BEF-9FE6B398AF86/IteneryLeg/p11>";
departureDate = "2012-11-10 19:00:17 +0000";
departureLeg = "0x1d0abba0 <x-coredata://BF6F2D98-0658-4005-8BEF-9FE6B398AF86/IteneryLeg/p11>";
iteneryLegs = (
"0x1d0abba0 <x-coredata://BF6F2D98-0658-4005-8BEF-9FE6B398AF86/IteneryLeg/p11>"
);
trip = "0x1c58add0 <x-coredata://BF6F2D98-0658-4005-8BEF-9FE6B398AF86/Trip/p5>";
})
All looks fine, however app still displayes null in some places or crashes. I catch the problem I added some NSAsserts and when I ran the code below in the same run as the output above it failed the assertion. Here is the assert code (segmentToCheck is segment from above).
NSSet *legs = [segmentToCheck valueForKey:#"iteneryLegs"];
NSAssert([legs count] != 0, #"Error: nolegs %#", legs);
its output:
2012-11-05 21:01:56.763 JetLagged[4505:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error: nolegs (null)'
When i run the app again (without any data modification) it works fine. Any idea what it might be?
Looks like a typo: #"itineryLegs" instead of #"iteneryLegs".

WCF-project will not return data with 64-bit Win Vista and VS2010

I thought I found the solution to my problem when I found this, but it didn't work for me.
When I run in debug mode, my WcfTestClient does not retrieve any data and I receive the error:
A first chance exception of type 'System.NotSupportedException' occurred in System.Data.Entity.dll
The thread '<No Name>' (0x1b50) has exited with code 0 (0x0).
The program '[7040] WCFTestClient.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).....................................
What WILL retrieve data is the following method:
public List<WShortDeal> Test()
{
try
{
return entities.ProductInstance_Deal
.Select(d => new WShortDeal()
{
Id = d.Deal.Id
// ,
// Name = d.Deal.Deal_Language.SingleOrDefault(l => l.Language.Id == 1).Name**
,
NewPrice = (double)d.ProductInstance.Price * (1 - d.Deal.SalesPercentage / 100)
,
OldPrice = (double)d.ProductInstance.Price
,
Valuta = d.ProductInstance.Valuta.ValutaCode
,
Type = d.Deal.Type
,
IdCompanyAccount = d.ProductInstance.IdCompanyAccount
})
.ToList();
}
catch (Exception)
{
return null;
}
}
If I uncomment the two lines that are now commented out, though, I stop receiving data and receive the error message mentioned above in my output window.
Also if I add this line
,ProductCategory = d.ProductInstance.ProductType.ProductCategory.ProductCategory_Language.Where(pcl => pcl.IdLanguage == idLanguage).Single().Name
instead of the line
, Name = d.Deal.Deal_Language.SingleOrDefault(l => l.Language.Id == 1).Name
to my original SELECT-statement, it will also return no data. So I guess maybe it has something to do with all the tables that represent the many-to-many-relationship with my Language-table(??). Because whenever I forget about the join with the "ProductCategory_Language"-table, I can retrieve data again.
Could someone please help? Is there another solution for my problem? I've been struggling with this problem for days now :(
Thanks in advance.
What if the line returns a null before selecting the name?
Try
Name = d.Deal.Deal_Language.Where(l => l.Language.Id == 1)
.Select(s=>s.Name).SingleOrDefault()