Welcome to the Builder Academy

Question find_all_dots - Valgrind issue

More
21 Mar 2017 20:18 - 24 Mar 2017 23:19 #6612 by cunning
I have been running the game in Ubuntu 14.04 LTS under Valgrind for several days and When a mobile is killed with no equipment on them, i get this in Valgrind. I have played around trying use memmove to get around this but i get the same result. I can add more detail but its identical to 3.68

==2103== Source and destination overlap in strcpy(0xffefff240, 0xffefff244)
==2103== at 0x4C2E272: strcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2103== by 0x4C8D1F: strcpy (string3.h:104)
==2103== by 0x4C8D1F: find_all_dots (handler.c:1901)
==2103== by 0x42177B: get_from_container (act.item.c:450)
==2103== by 0x4242B8: do_get (act.item.c:587)
==2103== by 0x4B2D20: raw_kill (fight.c:551)
==2103== by 0x4B6247: damage (fight.c:1511)
==2103== by 0x4B4980: hit (fight.c:1771)
==2103== by 0x4B4F2F: perform_violence (fight.c:1076)
==2103== by 0x47C3A4: heartbeat (comm.c:1061)
==2103== by 0x481BD1: game_loop (comm.c:984)
==2103== by 0x40383E: init_game (comm.c:571)
==2103== by 0x40383E: main (comm.c:387)
==2103==


Code:
void get_from_container(struct char_data *ch, struct obj_data *cont, char *arg, int mode, int howmany) { struct obj_data *obj, *next_obj; int obj_dotmode, found = 0; obj_dotmode = find_all_dots(arg); - > 450

Code:
int find_all_dots(char *arg) -> 1901 { if (!strcmp(arg, "all")) return (FIND_ALL); else if (!strncmp(arg, "all.", 4)) { strcpy(arg, arg + 4); /* strcpy: OK (always less) */ -->ISSUE return (FIND_ALLDOT); } else return (FIND_INDIV); }
Last edit: 24 Mar 2017 23:19 by cunning.

Please Log in or Create an account to join the conversation.

More
26 Mar 2017 14:34 #6618 by cunning
I solved my own issue and recommend this be updated in the code.


int find_all_dots(char *arg) -> 1901
{
if (!strcmp(arg, "all"))
return (FIND_ALL);
else if (!strncmp(arg, "all.", 4)) {
arg = strstr(arg, "all.");
return (FIND_ALLDOT);
} else
return (FIND_INDIV);
}

Please Log in or Create an account to join the conversation.

More
26 Mar 2017 19:46 - 26 Mar 2017 19:48 #6619 by WhiskyTest
Testing this change to find_all_dots() :
Code:
int find_all_dots(char *arg) { if (!strcmp(arg, "all")) return (FIND_ALL); else if (!strncmp(arg, "all.", 4)) { // strcpy(arg, arg + 4); /* strcpy: OK (always less) */ arg = strstr(arg, "all."); return (FIND_ALLDOT); } else return (FIND_INDIV); }
left me unable to get or drop all.jeans in this example:
(first, with original code, then after copyover with new code)
Code:
inv You are carrying: ( 6) some ripped jeans 250H 1M 250V > drop all.jea You drop some ripped jeans. You drop some ripped jeans. You drop some ripped jeans. You drop some ripped jeans. You drop some ripped jeans. You drop some ripped jeans. 250H 1M 250V > get all.jeans You get some ripped jeans. You get some ripped jeans. You get some ripped jeans. You get some ripped jeans. You get some ripped jeans. You get some ripped jeans. 250H 0M 250V > save Saving WhiskyTest. 250H 0M 250V > copy *** COPYOVER by WhiskyTest - please remain seated! Restoring from copyover... Copyover recovery complete. The Bucket Fountain The street is paved with dirty red-brown bricks, cracked and overgrown with weeds. Boarded up shop fronts line either side, covered in graffiti. Awnings stretch out overhead to provide some protection from the weather. Several neglected trees dot the area, their roots starting to crack and tear at the pavement. Large intersecting roads are visible to the north and south. This is more or less the center of Cuba Mall, a walkway which runs north to south through the center of Wellington city. [ Exits: N S w ] A colourful bucket fountain clunks and splashes in the middle of the street. Constable Beth is on duty here. 250H 1M 250V > [INFO] Receiving MXP Version From Client. 250H 1M 250V > drop all.jeans You don't seem to have any jeanss. 250H 1M 250V > inv You are carrying: ( 6) some ripped jeans
Last edit: 26 Mar 2017 19:48 by WhiskyTest. Reason: typos

Please Log in or Create an account to join the conversation.

More
26 Mar 2017 20:29 #6620 by cunning
Damn, I tested what you pointed out and that case scenario did not work.

You are correct.

Please Log in or Create an account to join the conversation.

More
18 Apr 2017 23:31 #6641 by Liko
Replied by Liko on topic find_all_dots - Valgrind issue
Why not have it check to see if said mobile has equipment in their inventory. If found inventory, it should run find_all_dots, if nothing in inventory have it continue on.

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
21 Apr 2017 20:33 #6645 by thomas
@cunning - you write that you "played around with memmove". What did you do, exactly?

This should work:
Code:
memmove(arg, arg+4, strlen(arg));

Please Log in or Create an account to join the conversation.

Time to create page: 0.237 seconds