--- Log opened Thu Mar 28 00:00:58 2019 |
00:02 | | Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has quit [[NS] Quit: http://www.kiwiirc.com/ - A hand crafted IRC client] |
00:10 | | Degi [Degi@Nightstar-uqe748.dyn.telefonica.de] has quit [Connection reset by peer] |
00:11 | | celmin|away is now known as celticminstrel |
00:37 | | Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has joined #code |
00:37 | | mode/#code [+o Reiv] by ChanServ |
01:32 | | Kindamoody is now known as Kindamoody[zZz] |
01:42 | | catalyst [Jessikat@Nightstar-5dv16h.cable.virginm.net] has quit [Connection closed] |
03:03 | | gizmore|2 [kvirc@Nightstar-gag74d.dip0.t-ipconnect.de] has quit [Connection reset by peer] |
03:47 | | Vorntastic [uid293981@Nightstar-6br85t.irccloud.com] has joined #code |
03:47 | | mode/#code [+qo Vorntastic Vorntastic] by ChanServ |
04:29 | | Derakon is now known as Derakon[AFK] |
05:05 | | celticminstrel is now known as celmin|sleep |
09:12 | | Callidus [Callidus@Nightstar-pc7srk.cable.rogers.com] has joined #code |
09:13 | < simon_> | I'm debugging some C code for the first time in a looong time. |
09:13 | <&McMartin> | Hail, fellow pirate, sailing the seven Cs |
09:13 | < simon_> | with tmp, tmp2 and tmp3 being integers, after this line: fscanf(mob_f, " %Dd%D+%D ", &tmp, &tmp2, &tmp3); they're not updated. |
09:14 | < simon_> | could I somehow read the line into a string, print the string, and then sscanf it? |
09:14 | <&McMartin> | What is fscanf returning? |
09:14 | < simon_> | (I'm not fluent with gdb, so finding whatever fscanf reads before attempting to parse it is a little above my head.) |
09:14 | < simon_> | I don't know. |
09:14 | <~Vorntastic> | I miss C sometimes |
09:14 | <&McMartin> | I would first check that; that is how many characters it read before giving up |
09:15 | < simon_> | this is DikuMUD, so I'm doing archaeology here! |
09:15 | <&McMartin> | But I think I know your problem here |
09:15 | <&McMartin> | D Equivalent to ld; this exists only for backward compatibility. (Note: thus only in libc4. In libc5 |
09:15 | <&McMartin> | and glibc the %D is silently ignored, causing old programs to fail mysteriously.) |
09:15 | < simon_> | ahhh, haha. |
09:15 | < simon_> | so legacy. |
09:15 | < simon_> | where's that from? |
09:15 | < simon_> | man fscanf? |
09:15 | <&McMartin> | man scanf |
09:16 | <&McMartin> | (scanf, fscanf, sscanf, vscanf, vfscanf, and vsscanf are all the same man page) |
09:16 | < simon_> | wow, thanks, that saved me a lot of investigation! |
09:17 | | * McMartin salutes |
09:17 | < simon_> | so %ld instead. |
09:17 | < simon_> | tmp, tmp2 and tmp3 are longs. good. |
09:19 | <&McMartin> | You say "bug in the core runtime", I say "undocumented API restriction" >_> |
09:19 | <&McMartin> | Except this one was actually documented, mirabile dictu |
09:20 | <&McMartin> | gcc and clang both "ought" to have some warning to the effect of "your format strings do not match you arguments" |
09:20 | <&McMartin> | ought in that "I know this is a setting that exists" |
09:20 | <&McMartin> | A setting that I do not know exists but which I would hope exists is something that makes it say "what the Hell is this %D shit" |
09:45 | < simon_> | McMartin, at least my compiler doesn't launch tetris, because "undefined behavior". |
09:47 | < simon_> | https://feross.org/gcc-ownage/ -- this was the reference I had in mind. |
09:49 | | Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has quit [[NS] Quit: http://www.kiwiirc.com/ - A hand crafted IRC client] |
09:49 | < simon_> | hahaha |
09:49 | < simon_> | this is excellent |
09:49 | < simon_> | I finally get the server up and running, telnet in, it asks me for a name and a password, and then coredumps. |
09:49 | < simon_> | I was afraid it'd be simple. |
10:05 | | Kindamoody[zZz] is now known as Kindamoody |
10:25 | | Kindamoody is now known as Kindamoody|afk |
10:34 | | Callidus [Callidus@Nightstar-pc7srk.cable.rogers.com] has quit [[NS] Quit: have fun!] |
10:50 | | Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has joined #code |
10:52 | < simon_> | for (; isspace(*arg); arg++); |
10:52 | < simon_> | |
10:52 | < simon_> | if (*arg == 'y' || *arg == 'Y') |
10:52 | < simon_> | so DikuMUD supports "yaaaas". |
10:52 | < simon_> | ahead of its time. |
11:11 | | Degi [Degi@Nightstar-rfogee.dyn.telefonica.de] has joined #code |
11:19 | <~Vorntastic> | It also accepts "yeah nah" except wrong |
11:33 | <@TheWatcher> | On the plus side, it's inclusive for martians - they can use "yip yip yip" and it'll work! |
12:25 | <&ToxicFrog> | McMartin: gcc does warn on format string/argument mismatches, but I don't know if that warning is on by default, and I suspect that -Wall -Wextra on an old codebase like Diku will generate a lot of noise. |
12:28 | | celmin|sleep is now known as celmin|away |
13:21 | | McMartin [mcmartin@Nightstar-rpcdbf.sntcca.sbcglobal.net] has quit [Ping timeout: 121 seconds] |
13:35 | | McMartin [mcmartin@Nightstar-rpcdbf.sntcca.sbcglobal.net] has joined #code |
13:35 | | mode/#code [+ao McMartin McMartin] by ChanServ |
13:45 | < simon_> | https://gist.github.com/sshine/85387677709d67d666e404377cf1ef2b |
13:49 | < simon_> | https://stackoverflow.com/questions/13978692/strcpy-sse2-unaligned-s-not-found -- I tried figuring out why I get this. |
13:50 | < simon_> | this StackOverflow suggests that I might not have included the right part of libc. |
13:50 | < simon_> | but I have #include <string.h> in this file, in which strncpy should be defined. |
13:55 | <&ToxicFrog> | Did you read the answer on SO? gdb is saying that it can't find the source code for __strncpy_sse2_unaligned, so you can't step line-by-line through that function |
13:55 | < simon_> | ah, sigh. |
13:56 | <&ToxicFrog> | If there are source and/or debugging symbols packages for libc in your package manager, installing those may fix this |
13:56 | < simon_> | so I looked at that crypt() call: |
13:56 | < simon_> | >> char *wat = crypt(arg, d->character->player.name); |
13:56 | < simon_> | and setting a breakpoint after having run this, 'print wat' in gdb gives me: $2 = 0xfffffffff7dd41e0 <error: Cannot access memory at address 0xfffffffff7dd41e0> |
13:58 | < simon_> | ToxicFrog, what does this imply, exactly? I've added -g -rdynamic to my compile flags, and I'm using backtrace*() functions in the source code for stack traces when print debugging. |
13:59 | <&ToxicFrog> | Hmm. So "arg" here is the password and the player name is being used as the salt? |
13:59 | <&ToxicFrog> | The implication here is that crypt() is returning an invalid pointer, which is surprising |
13:59 | < simon_> | yep, "arg" is the input password and the input player name is >2 characters long, so that shouldn't be the cause. |
14:00 | <&ToxicFrog> | You're not checking errno, but on error it should be returning NULL anyways |
14:00 | < simon_> | doing 'char *wat = "helloworld"' skips the coredump to the next call to crypt(). |
14:00 | < simon_> | ah, I could check errno. ok. |
14:01 | <&ToxicFrog> | You could, but crypt(3) says that on error it returns NULL and sets errno, and it's not returning NULL, so... |
14:02 | < simon_> | OK, so just to spell out the error I'm getting: it's not related to the bug, but related to the fact that the debugger can't step into the function that emitted the signal. |
14:04 | <&ToxicFrog> | Yes. |
14:05 | <&ToxicFrog> | We can (probably) safely assuming that you aren't hitting a bug in strncpy(), so all this loses you in practice is the ability to inspect its arguments at function entry, rather than (as you're doing here) saving them in separate variables and inspecting them there. |
14:05 | < simon_> | right. |
14:06 | < simon_> | okay, so there's some bug related to crypt() on my system. the other guy who ran this didn't experience anything. |
14:07 | <&ToxicFrog> | It occuts to me that crypt(3) doesn't say whether the return value is null-terminated or not, but that it will be "a sequence of 13 printable characters", and you're setting n=10 in the call to strncpy(), so it's not running off the end there. |
14:09 | <&ToxicFrog> | simon_: something to double check: that you are actually running `print wat` after crypt() returns and not just before it's called; IME it's easy to make that mistake with gdb. |
14:11 | <~Vorntastic> | Wat |
14:13 | < simon_> | ToxicFrog, yes, I am. |
14:14 | < simon_> | ToxicFrog, I made a breakpoint on both the line of 'print wat' and on the line of 'strncpy', and continuing to the second breakpoint sets wat to that address that I "can't access". |
14:14 | < simon_> | Welcome to DikuMUD |
14:14 | < simon_> | 3) Read the background story |
14:14 | < simon_> | Make your choice: 3 |
14:14 | < simon_> | This will soon be the background story of DIKU-MUD. |
14:15 | < simon_> | 28 years later. |
14:15 | <&ToxicFrog> | Oh, is it working now? What was the problem? |
14:15 | < simon_> | ToxicFrog, sorry, the crypt() thing isn't working, I just sidestepped it temporarily. |
14:16 | <&ToxicFrog> | Aah |
14:22 | <&ToxicFrog> | If I had to guess, I'd guess some issue with memory management elsewhere in the code is stomping on stuff crypt() needs to function correctly, rather than crypt() being inherently broken |
14:22 | <&ToxicFrog> | It might be worth writing a minimal program that calls crypt() with those arguments and sees what it returns |
14:28 | | Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has joined #code |
14:28 | | mode/#code [+qo Vornicus Vornicus] by ChanServ |
14:34 | <@TheWatcher> | Or try using crypt_r |
14:56 | | Degi [Degi@Nightstar-rfogee.dyn.telefonica.de] has quit [Connection reset by peer] |
15:10 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:15 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:15 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:19 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:19 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:20 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:20 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:27 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:29 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:34 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:34 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:34 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:34 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:34 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:35 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:35 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:35 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:35 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:35 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:35 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:35 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:43 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:43 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:43 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:44 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:44 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:44 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:44 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
15:44 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has joined #code |
15:44 | | gizmore [kvirc@Nightstar-73ula5.dip0.t-ipconnect.de] has quit [Connection closed] |
16:27 | | Vorntastic [uid293981@Nightstar-6br85t.irccloud.com] has quit [[NS] Quit: Connection closed for inactivity] |
18:35 | | Kindamoody|afk is now known as Kindamoody |
19:37 | | Vorntastic [uid293981@Nightstar-6br85t.irccloud.com] has joined #code |
19:37 | | mode/#code [+qo Vorntastic Vorntastic] by ChanServ |
19:51 | | Degi [Degi@Nightstar-rfogee.dyn.telefonica.de] has joined #code |
20:17 | | Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has joined #code |
20:17 | | mode/#code [+o Reiv] by ChanServ |
22:05 | | Derakon [Derakon@Nightstar-fr5qel.ca.comcast.net] has joined #code |
22:05 | | mode/#code [+ao Derakon Derakon] by ChanServ |
22:07 | | Derakon[AFK] [Derakon@Nightstar-fr5qel.ca.comcast.net] has quit [Ping timeout: 121 seconds] |
22:27 | | himi [sjjf@Nightstar-v37cpe.internode.on.net] has quit [Ping timeout: 121 seconds] |
22:57 | | Vorntastic [uid293981@Nightstar-6br85t.irccloud.com] has quit [[NS] Quit: Connection closed for inactivity] |
23:06 | | Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has quit [Connection closed] |
23:13 | | Degi [Degi@Nightstar-rfogee.dyn.telefonica.de] has quit [Connection closed] |
23:13 | | Vash [Vash@Nightstar-sjaki9.res.rr.com] has joined #code |
23:13 | | Vash [Vash@Nightstar-sjaki9.res.rr.com] has quit [Connection closed] |
23:25 | | Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has quit [Ping timeout: 121 seconds] |
23:55 | | Kindamoody [Kindamoody@Nightstar-eubaqc.tbcn.telia.com] has quit [Connection closed] |
23:57 | | Kindamoody|autojoin [Kindamoody@Nightstar-eubaqc.tbcn.telia.com] has joined #code |
23:57 | | mode/#code [+o Kindamoody|autojoin] by ChanServ |
--- Log closed Fri Mar 29 00:00:59 2019 |