code logs -> 2018 -> Wed, 27 Jun 2018< code.20180626.log - code.20180628.log >
--- Log opened Wed Jun 27 00:00:20 2018
--- Day changed Wed Jun 27 2018
00:00
<&[R]>
It effectively does x[0] = 88; repeatedly, except it keeps incrementing *x*, so maybe it eventually mutates y?
00:00
<&[R]>
Except not enough to make the loop's continue condition become false.
00:01
<&McMartin>
Well, he's running it in DOSbox and doesn't actually say what his Turbo c settings were
00:01
<&McMartin>
Assuming, generously, that he's using the "small memory model"
00:01
<&McMartin>
ints and pointers are in fact two bytes wide if he was checking the binaries
00:01
<&McMartin>
That will fill the 64KB after DS:0000 with "8800"
00:02
<&McMartin>
Well, no, with the 16-bit hex for 88
00:02 ErikMesoy [Bruker@Nightstar-hq72t5.customer.cdi.no] has quit [Ping timeout: 121 seconds]
00:03
<&McMartin>
also
00:03
<&McMartin>
'if ((x = malloc(400)) == NULL) { /* when sizeof() is a burden */'
00:03
<&McMartin>
based on the comments later on, I get the impression he added that comment
00:03
<&McMartin>
sizeof() is useless for dynamically allocated values
00:04
<&[R]>
Uhh what?
00:04
<@Tamber>
I think he is adding the comments.
00:04
<&McMartin>
`if ((x = malloc(400)) == NULL)` has nothing at all to do with anything you should be calling sizeof() in.
00:05
<&[R]>
`if ((x = malloc(200 * sizeof(int))) == NULL)`
00:05
<&McMartin>
That's doing a malloc and then both assigning and checking the result in one expression, which is *usually* bad form but is sufficiently not bad form that there are some idioms that still do that
00:06
<&McMartin>
Ah, OK, and thus <= 198, and that's where the assumption of sizeof(int) comes in.
00:06
<&ToxicFrog>
McMartin: the "assumes int is 2 bytes" and "when sizeof() is a burden" comments both relate to for (y = 0; y <= 198; ++x)
00:06
<&McMartin>
Right, I was focusing too tightly, it seems
00:07
<&McMartin>
Also yeah, it will never segfault in DOS~
00:08
<&ToxicFrog>
The further into this I get the more alarmed I am
00:08
<&ToxicFrog>
int square(int,int*) /* aaaaaaa */
00:09
<&[R]>
You haven't seen square(int*,int*) yet though
00:10
<&McMartin>
Given the things the article writer isn't seeing fit to mention I'm genuinely impressed that he got Turbo C to produce runnable programs -_-
00:10
<~Vornicus>
this is terrible
00:11
<&McMartin>
Until 64-bit GCC became the default, DOS was in fact the only common example of sizeof(int) != sizeof(int *), and even then only was if you set certain build settings
00:11
<&McMartin>
So in order for him to get as far as he clearly did, he had to ensure a specific ABI was used of the, um, five standards ones
00:11
<&McMartin>
*standard
00:12
<&McMartin>
Of those, the runaway loop will behave as described in two of them and hardlock the system in the other three, one much faster than the others.
00:15
<&ToxicFrog>
It's not even assuming that sizeof(int) == sizeof(int*), it's assuming that sizeof(int) == 2
00:15
<&McMartin>
Different example
00:16
<&McMartin>
(Every non-DPMI DOS compiler I'm aware of has sizeof(int) == 2)
00:18
<&McMartin>
The other fun part of 16-bit DOS that didn't come up here is that function pointers and data pointers will often be different sizes
00:19
<&McMartin>
(The five ABIs are the four possible combinations of answers to "will the Code Segment register ever change?" and "will the Data Segment register ever change?", and one bonus one which is 'no, no, and in fact those registers are equal to each other')
00:21
<&McMartin>
(And then there's a sixth extra "ABI" that is the 'yes/yes' ABI but insists that no individual array is larger than 64KB, thus allowing you to use the segment register to identify any array without additional resegmentation while traversing)
00:36 VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has joined #code
00:36 mode/#code [+ao VirusJTG VirusJTG] by ChanServ
00:48 celticminstrel [celticminst@Nightstar-jocbi5.dsl.bell.ca] has joined #code
00:48 mode/#code [+o celticminstrel] by ChanServ
00:58 Derakon[AFK] is now known as Derakon
01:16 ErikMesoy [Bruker@Nightstar-hq72t5.customer.cdi.no] has joined #code
02:09
<&[R]>
https://wozniak.ca/blog/2018/06/25/Massacring-C-Pointers/notes.html
02:25
<~Vornicus>
gnaaaah what'd I do wrong
02:54 Degi [Degi@Nightstar-aivame.dyn.telefonica.de] has quit [Connection closed]
03:22 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has quit [Connection closed]
03:31
<@celticminstrel>
I wanna see the discussion of multi-dimensional arrays now...
03:32 * celticminstrel notes that far pointers aren't unique to DOS, I'm pretty sure the classic Macs had that too.
03:35
<@celticminstrel>
This is hilarious though.
03:36
<@celticminstrel>
I almost want to read this book.
03:36
<@celticminstrel>
Almost.
04:35 macdjord [macdjord@Nightstar-grpbnp.mc.videotron.ca] has quit [[NS] Quit: Pie Jesu Domine (*thunk*), Donna Eis Requiem (*thunk*).]
04:50 celticminstrel [celticminst@Nightstar-jocbi5.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
04:52 macdjord [macdjord@Nightstar-grpbnp.mc.videotron.ca] has joined #code
04:52 mode/#code [+o macdjord] by ChanServ
05:36 Derakon is now known as Derakon[AFK]
06:00
<&[R]>
'"In 1984, I began work on CBREEZE, a translator program that accepts BASIC language source code and converts it to C source code." (p. 153) — THIS EXPLAINS EVERYTHING.'
06:05
<&McMartin>
qb64 did the job
06:08
<&[R]>
'"When a C program calls a function, the calling program actually relinquishes control to the function. This takes more time than if the function were actually written within the calling program, proper." (p. 84) — I'm still trying to figure out what he means by "program" as opposed to "function".'
06:11
<&McMartin>
He's saying that CALL costs more cycles than JMP
06:14
<&[R]>
Aye, not something that really belongs in an introductory textbook though, no?
06:14
<&[R]>
Unless it were covering assembly
06:33
<&McMartin>
It's also dangerously wrong in important ways
06:33
<&McMartin>
16-bit x86 gains less from function inlining than you'd expect, because the register pressure is so high you'll need to spill to the stack anyway.
06:33
<&[R]>
In ways beyond "don't write functions"?
06:34
<&McMartin>
Now you have a large function that has to spill regularly while in mid-function.
06:36
<&McMartin>
It's got six registers, but their uses are restricted in inconvenient ways. 16-bit x86 is a hopped-up accumulator architecture in ways that IA32 is not.
06:52 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has joined #code
06:52 mode/#code [+qo Vornicus Vornicus] by ChanServ
07:09 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has quit [Ping timeout: 121 seconds]
07:18 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has joined #code
07:18 mode/#code [+qo Vornicus Vornicus] by ChanServ
07:23 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has quit [Ping timeout: 121 seconds]
07:43 crystalclaw [crystalclaw@Nightstar-12q9ui.xyz] has quit [Ping timeout: 121 seconds]
07:44 Vorntastic [uid293981@Nightstar-6br85t.irccloud.com] has joined #code
07:44 crystalclaw [crystalclaw@Nightstar-12q9ui.xyz] has joined #code
07:44 mode/#code [+o crystalclaw] by ChanServ
07:52 Kindamoody[zZz] is now known as Kindamoody
08:27 Kindamoody is now known as Kindamoody|afk
13:26 celticminstrel [celticminst@Nightstar-jocbi5.dsl.bell.ca] has joined #code
13:26 mode/#code [+o celticminstrel] by ChanServ
13:41
<@celticminstrel>
This is getting close to its next stretch goal with less than 2 days left. https://www.kickstarter.com/projects/619141553/queens-wish-the-conqueror
13:44
< simon_>
today's line of horrible Perl code contribution to the world: my @hrefs = map { +{$_->%*} } @objs;
13:55
<@TheWatcher>
That's...
13:57
<@TheWatcher>
That's just doing a copy of the hashrefs, right?
13:58
<@TheWatcher>
$_ -> %* is pulling all the key/value pairs out of the $_ hashref as a list, and +{ } is promoting that back to a hashref... I think?
13:58
<@celticminstrel>
Urgh?
13:58
<@celticminstrel>
That seems like a terrible syntax though.
14:01
< simon_>
TheWatcher, yup.
14:03 celticminstrel [celticminst@Nightstar-jocbi5.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
14:22 macdjord is now known as macdjord|slep
14:47
<&[R]>
<Lope> what's a easy way to undelete a file on vfat that I deleted accidentally?
14:47
<&[R]>
<Sitri> Lope: restore from backup
14:47
<&[R]>
<Lope> Sitri, not funny
15:04 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has joined #code
15:04 mode/#code [+qo Vornicus Vornicus] by ChanServ
15:21
<@TheWatcher>
Hrm, slack appears to be non-working
15:34 Vorntastic [uid293981@Nightstar-6br85t.irccloud.com] has quit [[NS] Quit: Connection closed for inactivity]
15:42
<&[R]>
Isn't that the normal operating state of all these IRC killers?
15:42
<@TheWatcher>
iDunno, only using it because I haven't persuaded some people in work to switch to IRC~
15:42
<@TheWatcher>
Yet.
15:54
<@gnolam>
Our Slack is up and running at least.
15:54
<@gnolam>
... wait, I spoke too soon.
15:54
<@gnolam>
It actually loaded the channel I was in, but everything else seems offline.
15:57
<@TheWatcher>
I think I will email people with "So, slack is down... you know I run an IRC server in the school, right?" >.>
15:57
<&[R]>
Do eet
15:57
<@gnolam>
Heh
15:57
<&[R]>
Cure them of the disease
16:12 ErikMesoy1 [Bruker@Nightstar-hq72t5.customer.cdi.no] has joined #code
16:14 ErikMesoy [Bruker@Nightstar-hq72t5.customer.cdi.no] has quit [Ping timeout: 121 seconds]
16:33
<&jerith>
Go is severely limiting my ability to write good code.
16:48 * Vornicus hunts around in his thing, finds some bugs, still has no idea what's going wrong.
16:49
<~Vornicus>
The problem with a lot of these geometry algorithms is that they're 1. highly monolithic and 2. packed to the gills with special cases
17:06
<~Vornicus>
So I can test things for special cases I can think of but then there will be a special case I can't hunt down because it's just plain Not Mentioned in the standard algorithm descriptions
17:22 Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has joined #code
18:47 * abudhabi tries to figure out the simplest hack he can to be able to SSH/VNC into his home box from arbitrary near future spacetime.
18:48
<@abudhabi>
I need to set up some kind of port forwarding to my box on the router. That's easy.
18:48
<@abudhabi>
But then I need to know the IP, because the ISP tends to reset it a couple times a day.
18:51
<@abudhabi>
I have an shell account that also provides a personal webpage with PHP.
18:51
<@abudhabi>
Perhaps I could rig up a php document that writes to a file on that shell account the IP address of whoever looked it up last.
18:52
<@abudhabi>
Fire that up on my home box and set it to refresh every hour or so.
18:52
<@abudhabi>
Then if I need to know that box's IP, I simply SSH into this thing and look it up.
18:52
<@abudhabi>
Then I can SSH into my home box.
18:53
<~Vornicus>
most routers I know have the ability to log into a dynamic DNS system and announce their new IP that way
18:53
<@abudhabi>
Right... I wonder if no-ip.org still gives out free domains.
18:55
<@abudhabi>
I wouldn't then need to even set up a DMZ. A simple port forward would do the trick.
18:59
<~Vornicus>
even if you can't do it on the router, most provide PC-side scripts that do the same thing
18:59
<@abudhabi>
Pretty sure I can do it on the router.
18:59
<@abudhabi>
If I recall the router password. :V
18:59
<~Vornicus>
that would help
19:00
<&[R]>
https://fil.forbrukerradet.no/wp-content/uploads/2018/06/2018-06-27-deceived-by-design-final.pdf
19:04
<&[R]>
abudhabi: on home, in cron: ssh SHELLBOX awk "'{print \$1}'" '<<<$SSH_CLIENT' '>' .ip
19:05
<&[R]>
On laptop (or other remote machine): ssh $(ssh SHELLBOX cat .ip) ...
19:05 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has quit [Ping timeout: 121 seconds]
19:06
<@abudhabi>
[R]: Already set up a DDNS domain and configured it on the router, but thanks!
19:09
<&[R]>
Okay
19:15
<@abudhabi>
Now if only the damn thing didn't refuse connections.
19:16
<&[R]>
Check other ports?
19:16
<&[R]>
My ISP used to block common ports on residential connections
19:17
<&[R]>
IIRC one even just blanket banned everything that wasn't >1024
19:18
<@abudhabi>
Aha! I just messed up.
19:18
<@abudhabi>
I recalled I changed the default port, but then I was checking it on my remote shell, instead of locally.
19:18
<@abudhabi>
So I got 'it's 22' rather than the proper info I had set up here.
19:22 Kindamoody|afk is now known as Kindamoody
19:25 Degi [Degi@Nightstar-8maogd.dyn.telefonica.de] has joined #code
19:29 danny [papaglembo@Nightstar-2bq.fcl.80.202.IP] has joined #code
19:29
< Degi>
Hewwo danny
19:30
< danny>
siapa disana
19:30
< Degi>
It's me
19:31
< danny>
it's in the back
19:32 danny [papaglembo@Nightstar-2bq.fcl.80.202.IP] has left #code []
20:05
<@gnolam>
What.
20:23 Degi_ [Degi@Nightstar-57f.mhi.212.185.IP] has joined #code
20:25 Degi- [Degi@Nightstar-57f.mhi.212.185.IP] has joined #code
20:26 Degi [Degi@Nightstar-8maogd.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
20:27 Degi- is now known as Degi
20:29 Degi_ [Degi@Nightstar-57f.mhi.212.185.IP] has quit [Ping timeout: 121 seconds]
20:39 Degi_ [Degi@Nightstar-2et.mhi.212.185.IP] has joined #code
20:42 Degi [Degi@Nightstar-57f.mhi.212.185.IP] has quit [Ping timeout: 121 seconds]
20:50 macdjord|slep is now known as macdjord
21:32 Degi- [Degi@Nightstar-mld.mhi.212.185.IP] has joined #code
21:33 Degi-- [Degi@Nightstar-8maogd.dyn.telefonica.de] has joined #code
21:33 Degi- [Degi@Nightstar-mld.mhi.212.185.IP] has quit [Connection closed]
21:33 Degi-- is now known as Degi
21:33 Degi [Degi@Nightstar-8maogd.dyn.telefonica.de] has quit [[NS] Quit: Leaving]
21:34 Degi [Degi@Nightstar-8maogd.dyn.telefonica.de] has joined #code
21:36 Degi_ [Degi@Nightstar-2et.mhi.212.185.IP] has quit [Ping timeout: 121 seconds]
23:05 Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has quit [Ping timeout: 121 seconds]
23:21
<@macdjord>
Assuming the weight of the wood and rope is negligible, that each pulley is directly over its corresponding bucket, and that the other end of each rope attaches to the middle of the table, how much more must one bucket weigh than the others before the table will tip? https://i.imgur.com/nRAJIEa.jpg
23:23 Kindamoody is now known as Kindamoody[zZz]
23:27
<@macdjord>
(Solution so far: In order for the heavy bucket to move down, the table center has to move up. This means all the other pulley systems will be slack, so the heavy bucket has to be heavy enough to lift all the other buckets. The problem thus can be treated as a 2D lever arm, with the heavy bucket on one end, two buckets in the middle, and the final bucket at the other end. The pivot of this lever arm is somewhere between the heavy bucket
23:27
<@macdjord>
and the midpoint of the arm, but I can't calculate where.)
23:28
< ErikMesoy1>
macdjord: "tip" as in?
23:28 ErikMesoy1 is now known as ErikMesoy
23:28
< ErikMesoy>
Seems to me the system would just angle slightly until the midpoint of bucket and table fastenpoint was below the pulley of the heavy bucket.
23:29 mode/#code [+o ErikMesoy] by ChanServ
23:30
<@macdjord>
ErikMesoy: You've seen the diagram? It's obvious, looking at it, that if all 4 buckets contain an equal weight, the table will remain level. If you add a bit of weight to one bucket, it will remain level, since in order for any one corner to go down, all the others must go up. But if you add enough weight, eventually it will tip.
23:32
<@ErikMesoy>
I've seen the image you linked, if that's what you mean by diagram.
23:32
<@macdjord>
ErikMesoy: Yes.
23:33
<@ErikMesoy>
I do not think it is obvious that the system will remain level if you add weight to one bucket.
23:35
<@ErikMesoy>
Degenerate case: assuming infinite friction (buckets effectively glued to table) the system cannot tip, only lean. And I think the system will lean if enough weight is applied into one glued bucket.
23:37
<@macdjord>
ErikMesoy: Alright, imagine it's hanging there with equal weights in all the buckets. You walk up and try to tip the table so that one corner goes down, the opposite corner goes up, and the center of the table stays at the same height. The bucket on the rising corner must go up, lifted by the table. The bucket on the dropping corner will be left hanging in the air on its rope, because the center (where the other end of the rope is
23:37
<@macdjord>
attached) hasn't moved any closer to the pulley.
23:38
<@ErikMesoy>
The table might swing sideways and bring the center closer to one pulley.
23:51
<@macdjord>
Hmm. You're right. The question thus becomes: for which combinations of tilt and sideslip do all 4 pulleys remain taut? We know there is one solution, at (0 tilt, 0 sideslip).
23:51
<@macdjord>
If the solution is continuous over the whole tilt range of 0 to 90 degrees, then adding weight to a bucket will cause it to either tilt into a new equilibrium or just fall over (depending on if the solutions are stable or not).
23:52
<@macdjord>
If (0,0) is the only solution, or if there are a finite number of discrete solutions, then we're back to having a specific tipping point - namely, the point where the heavy bucket is heavy enough to lift the opposite bucket with its pulley slack. Up to that point, the table will remain level.
23:53
<@macdjord>
It could even be a combination - continuous up to some angle less than 90, then no or discrete solutions beyond that. In which case it will tip to some angle, then stop there until a tipping point is passed.
--- Log closed Thu Jun 28 00:00:25 2018
code logs -> 2018 -> Wed, 27 Jun 2018< code.20180626.log - code.20180628.log >

[ Latest log file ]