Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when deleting a character. #255

Open
sean-gilliam opened this issue Mar 6, 2024 · 5 comments
Open

Segfault when deleting a character. #255

sean-gilliam opened this issue Mar 6, 2024 · 5 comments

Comments

@sean-gilliam
Copy link
Collaborator

A segfault happens when deleting a character. This issue was reported by @danielw97 here #251 (comment). Creating a new issue so this doesn't get lost.

Hi again,
No rush on this of course, although one other thing I thought I would note.
I've just attempted to delete a player, however received the following error. It looks as though the game is trying to move a player file with essentially a nonsense name, see below with a line for context:
[email protected] has autoquit. [8 played, 10 (0) obj]
mv: cannot stat '../player/'$'\r\337'']'$'\310\331''u.plr': No such file or dire
ctory
Segmentation fault
If this is something on my end let me know, as I'm happy to try a different os etc.

@rezalas
Copy link
Owner

rezalas commented Mar 6, 2024

Those appear to be escape codes. Like it's trying to send a new line, then \337] to modify the color, $ then \310 \331 would be HI I believe. But, the bracket is facing the wrong direction, so I'm not sure what's going on.

@sean-gilliam
Copy link
Collaborator Author

I mentioned it in the other post, but I think it's either uninitialized memory or reusing the string without zeroing it out first that is causing the weirdness.

@rezalas
Copy link
Owner

rezalas commented Mar 6, 2024

The deletion code looks like it's in act_comm.c.

char strsave[MAX_INPUT_LENGTH];
sprintf(strsave, "%s/%s.plr", RIFT_PLAYER_DIR, capitalize(ch->name));

But that's not even used. What is actually sent to the delete command, which expects the path, is

riftshadow/code/act_comm.c

Lines 111 to 113 in dfac902

auto cname = palloc_string(ch->true_name);
auto save_pfile = ((ch->played + (current_time - ch->logon)) / 3600) >= 15;
delete_char(cname, true); // >= 15 hours. Make name unusable.

which calls into our old friend DevExtra.c

riftshadow/code/devextra.c

Lines 762 to 777 in dfac902

void delete_char(char *name, bool save_pfile)
{
char buf1[MSL], buf2[MSL], query[MSL];
name = capitalize(name);
int cres = 0;
// whack their pfile.. or maybe just move it to dead_char
if (save_pfile)
sprintf(buf2, "mv %s/%s.plr %s/dead_char/%s.plr", RIFT_PLAYER_DIR, name, RIFT_PLAYER_DIR, name);
else
sprintf(buf2, "rm %s/%s.plr", RIFT_PLAYER_DIR, name);
auto returnCode = system(buf2);
if(returnCode != 0) // both mv and rm return 0 on SUCCESS, > 0 on ERROR. system returns -1 on ERROR
RS.Bug("Command [%s] failed with exit code [%d]", buf2, returnCode);

Another fun find here is we're purging logs for no good reason. Go figure.

riftshadow/code/devextra.c

Lines 782 to 795 in dfac902

sprintf(query, "DELETE FROM pklogs WHERE killer='%s'", name);
one_query(query);
sprintf(query, "DELETE FROM theft WHERE ch='%s'", name);
one_query(query);
sprintf(query, "DELETE FROM offerings WHERE player='%s'", name);
one_query(query);
sprintf(query, "DELETE FROM logins WHERE name='%s'", name);
one_query(query);
sprintf(query, "DELETE FROM inductions WHERE ch='%s'", name);
one_query(query);

@sean-gilliam
Copy link
Collaborator Author

Happy happy joy joy.

Another fun find here is we're purging logs for no good reason. Go figure.

Are we? Where do you see that?

@sean-gilliam
Copy link
Collaborator Author

Oh nvm. You meant the SQL logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants