|
Zombywuf posted:It looks to me that x + 1 == y is the bit that fucks up because the object may change between each side of the equality operator being read. The empty synchronised block appears to be some sort of magical ward against it but as far as I'm aware it does basically nothing in this case. I'm not really up to date on Java though so maybe it does actually do something useful. It's valid but offers very weak semantics. Namely any writes performed before the synchronized block in one thread will be visible to any reads after the synchronized block for the same object in another thread. Of course any subsequent writes may also be visible, and it doesn't guarantee that the writing thread will be the first to hit the block. If the reader hits first, then the conflict still happens. Note that removing the synchronized(this){} block is simply turning it into an infinite loop since the thread checking the value never reassigns it, and the optimizer is perfectly free to never check again that the actual value in memory has changed. edit: Also the object reference can't change between p.x+1 and p.y since it's a local variable, but the value of p.x or p.y could change. 1337JiveTurkey fucked around with this message at 21:32 on Aug 16, 2013 |
# ? Aug 16, 2013 21:26 |
|
|
# ? May 30, 2024 14:14 |
|
This really is surprising. I would have expected that the object needs to be fully constructed before the final assignment operation (currentPos =...) could be performed, but apparently that isn't the case with some JVM optimizations, and thinking about it a little I suppose it's not that surprising since doing so is effectively "safe" here as far as the runtime cares.
|
# ? Aug 17, 2013 00:10 |
|
Volmarias posted:This really is surprising. I would have expected that the object needs to be fully constructed before the final assignment operation (currentPos =...) could be performed, but apparently that isn't the case with some JVM optimizations, and thinking about it a little I suppose it's not that surprising since doing so is effectively "safe" here as far as the runtime cares. Final fields will be initialized unless a reference to the object escapes within the constructor. That is, if you pass a this reference to another thread in the constructor, that thread can see an uninitialized value. On the other end of the lifecycle, the object will always be fully constructed when the finalizer is run, so you can count on that much. However strictly speaking if an object is determined to be unreachable then it can in principle be garbage collected and finalized immediately. If an instance method never references the object itself or any of its fields then the instance can even be garbage collected and finalized before the method has returned since it's unreachable. This can be prevented by synchronizing on the instance.
|
# ? Aug 17, 2013 01:41 |
|
1337JiveTurkey posted:However strictly speaking if an object is determined to be unreachable then it can in principle be garbage collected and finalized immediately. If an instance method never references the object itself or any of its fields then the instance can even be garbage collected and finalized before the method has returned since it's unreachable. This can be prevented by synchronizing on the instance. I get the feeling that someone has counted on this behavior not occurring, and you have dealt with the aftermath. Honestly, the advice I've been given in the past has been to assume that because there's no guarantee of when the finalizer will be run after the object is viable for GC, or that it even WILL be run, to just not bother with them in the first place, something that I've found really isn't a big problem.
|
# ? Aug 17, 2013 02:37 |
|
Volmarias posted:This really is surprising. I would have expected that the object needs to be fully constructed before the final assignment operation (currentPos =...) could be performed, but apparently that isn't the case with some JVM optimizations, and thinking about it a little I suppose it's not that surprising since doing so is effectively "safe" here as far as the runtime cares. Not just JVM optimizations, CPU-level optimizations can break this as well (unless you want to kill performance by having your compiler put memory barriers in what looks like single-threaded code). Especially once you go outside of x86-land and its almost-strict memory ordering.
|
# ? Aug 17, 2013 03:00 |
|
Jabor posted:Not just JVM optimizations, CPU-level optimizations can break this as well (unless you want to kill performance by having your compiler put memory barriers in what looks like single-threaded code). Bingo... Just because the JVM (or CLR) promises not to reorder things doesn't mean poo poo to the CPU. Now that even your phone is multi-core, the phrase "concurrent" really loving means concurrent. The local CPU may never even see an inconsistent view but the thread may run on a different core that does. Don't be clever, just use synchronization primitives in a straightforward way. The number of times a profiler showed synchronization as the bottleneck compared to the number of times people claimed it was must be around 1:100. Programs are meaninglessly executed by meaningless machines producing meaningless output exactly as designed. Concurrency is a great way to prove how little the computer adheres to your idea of what is/is not possible or logical.
|
# ? Aug 17, 2013 04:18 |
|
Plorkyeran posted:In the specific case of C and C++, this is because dependency management is terrible. In Python, Ruby, Javascript, Objective-C (and a bunch of other languages I haven't used for real projects), adding a new dependency consists of adding a single line to the config file and everything just works. Unsurprisingly, it's common to end up with small projects that use 30 simple single-purpose libraries. You're conflating language, IDE, and Operating system there. How many Python modules have you tried to use on win32 that fail to install because gcc isn't in your path? Show me an Objective-C library running on that Debian system you mentioned working with a single line to a config file. Hell I had NodeJS libraries break because the npm guys one day randomly swapped LibraryName for LibraryName2 when you asked for LibraryName which used a totally different build system that wasn't compatible with my version of node. That was a great one to figure out since I had pinned the version of the library in requirements file. Hughlander fucked around with this message at 15:39 on Aug 17, 2013 |
# ? Aug 17, 2013 15:34 |
|
To be fair that Python example is only true because it isn't pure Python, you are now compiling C.
|
# ? Aug 17, 2013 16:40 |
|
Yes, oddly enough I factor things like what platform the code will be running on when picking a language to use for a project rather than trying to do things like use Objective-C on Debian.
|
# ? Aug 17, 2013 16:43 |
|
Ender.uNF posted:Bingo... Just because the JVM (or CLR) promises not to reorder things doesn't mean poo poo to the CPU. Now that even your phone is multi-core, the phrase "concurrent" really loving means concurrent. The local CPU may never even see an inconsistent view but the thread may run on a different core that does. Don't be clever, just use synchronization primitives in a straightforward way. The number of times a profiler showed synchronization as the bottleneck compared to the number of times people claimed it was must be around 1:100. Right, the underlying problem is a lack of synchronization and thread safety, I'm just surprised at how this failed in particular. Volmarias fucked around with this message at 18:10 on Aug 17, 2013 |
# ? Aug 17, 2013 17:41 |
|
We're setting up a data processing system that will takes files on a NAS, make copies of them, do some basic processing on their contents, and then push a result into a database. The software engineer wants to write this system in Python. The program manager (who is sort of a software programmer who eventually clawed his way into management) is forcing him to use MATLAB
|
# ? Aug 17, 2013 19:33 |
|
Demo it in Spyder and tell him its the new version of MATLAB.
|
# ? Aug 17, 2013 19:41 |
|
QuarkJets posted:We're setting up a data processing system that will takes files on a NAS, make copies of them, do some basic processing on their contents, and then push a result into a database. The software engineer wants to write this system in Python. The program manager (who is sort of a software programmer who eventually clawed his way into management) is forcing him to use MATLAB Can't somebody veto this terrible thing before it happens? Surely if you yell loudly enough at the right people you should be able to scare someone into putting a little more critical thought into it.
|
# ? Aug 17, 2013 21:30 |
|
EntranceJew posted:Can't somebody veto this terrible thing before it happens? Surely if you yell loudly enough at the right people you should be able to scare someone into putting a little more critical thought into it. Not happening; the project manager is actually from an outside company, they're a customer for the product. Ultimately they're purchasing whatever they tell us to make even if we recommend something else
|
# ? Aug 18, 2013 05:11 |
|
What was the name of that weird bible type Linux OS that kind of generated random bits as a quote from god? It got posted here a couple months ago, but I can't remember it past that.
|
# ? Aug 18, 2013 07:07 |
|
Master_Odin posted:What was the name of that weird bible type Linux OS that kind of generated random bits as a quote from god? It got posted here a couple months ago, but I can't remember it past that. I'm pretty sure it was LoseThos when the crazy guy who created it was posting around here. He's changed the name about a dozen times since then, for reasons known only to C:/BIBLE.TXT.
|
# ? Aug 18, 2013 07:21 |
|
Temple OS. I don't think it's Linux though. The guy seems to have written it from scratch.
|
# ? Aug 18, 2013 07:39 |
|
Spatial posted:Temple OS. I don't think it's Linux though. The guy seems to have written it from scratch. Yeah, it's been called losethos, sparrowos, templeos, etc. Dude's a crazy idiot in every sense, there's sort of this weird edge to his voice in his youtube ramblings, and he sucks at making operating systems too.
|
# ? Aug 19, 2013 02:34 |
|
Cocoa Crispies posted:Yeah, it's been called losethos, sparrowos, templeos, etc. Dude's a crazy idiot in every sense, there's sort of this weird edge to his voice in his youtube ramblings, and he sucks at making operating systems too. Doesn't his "fully modern" operating system require a dual core and several gigs of RAM to push C64-era graphics because it does everything in (super slow) software? Also it's programmed in Holy C.
|
# ? Aug 19, 2013 03:05 |
|
Cocoa Crispies posted:Yeah, it's been called losethos, sparrowos, templeos, etc. Dude's a crazy idiot in every sense, there's sort of this weird edge to his voice in his youtube ramblings, and he sucks at making operating systems too. To be fair, he wrote a functional OS single-handledly. That's a pretty impressive feat even if it's done poorly and the author is a nutcase.
|
# ? Aug 19, 2013 03:18 |
|
Yeah the general consensus between myself and everybody else I've shown those videos too was less "Hahaha holy poo poo what an idiot" and more "Wait he did what all by himself? And why all the Jesus?!"
|
# ? Aug 19, 2013 05:30 |
|
Ithaqua posted:To be fair, he wrote a functional OS single-handledly. That's a pretty impressive feat even if it's done poorly and the author is a nutcase. Not really. Undergrads do that poo poo, and don't even have ridiculous and wrong ideas about the usefulness of memory mapping, BIOS, VGA, and other features of commodity computers from the last thirty years. The guy's response to somebody criticizing the homemade PRNG he wrote for the babble generator he thinks is god was to paste a shitload of it into YOSPOS [insert joke about how nobody could tell the difference between it and regular yosposting] and get banned for being insane and somehow boring.
|
# ? Aug 19, 2013 05:35 |
|
The great bit for me is that he trumpets how hilariously insecure his operating system is because he designed it to be as much like his beloved Commodore as possible (even eschewing ASCII or Unicode in favour of "8-bit unsigned characters").quote:The main reason TempleOS is simple and beautiful is because it's ring-0-only and identity-mapped. Linux wants to be a secure, multi-user mainframe. That's the vision for Linux. That's why it has file permissions. The vision for TempleOS is a modern, 64-bit Commodore 64. The C64 was a home computer mostly used for games. It trained my generation how to program. It was simple, open and hackable. It was not networked. The games were not multimedia works of art, but generated programmatically with innocent, programmer (non-artist) quality graphics. It was simple and unsecure. If you don't have malware and you don't have bugs, protection just slows things down and makes the code complicated.
|
# ? Aug 19, 2013 06:14 |
|
Edit: Derp, misread, nevermind.
|
# ? Aug 19, 2013 06:21 |
|
Crosscontaminant posted:If you don't have malware and you don't have bugs, protection just slows things down and makes the code complicated. To be fair, an operating system used by one person ever is unlikely to be plagued with malware.
|
# ? Aug 19, 2013 06:42 |
|
seiken posted:To be fair, an operating system used by one person ever is unlikely to be plagued with malware. You could make a compelling argument that an operating system used by one person ever is malware in its own right.
|
# ? Aug 19, 2013 06:46 |
|
seiken posted:To be fair, an operating system used by one person ever is unlikely to be plagued with malware. Also it can't get online, so there's that
|
# ? Aug 19, 2013 06:59 |
|
carry on then posted:Also it's programmed in Holy C. http://www.templeos.org/Wb/Demo/DateTime.html
|
# ? Aug 19, 2013 07:17 |
|
Holy christ... literally. Reminds me a bit of the A-Patch for Windows Messenger, written by a muslim. code:
|
# ? Aug 19, 2013 13:38 |
|
I was looking through the source code to a huge, legacy classic ASP site a few jobs ago, and I found a page that had a weird name. I opened it up, and it was: 1) A large comment written in Hindi that was some sort of prayer 2) A form that allowed you to execute any arbitrary SQL command against the application's database. Where passwords were stored in plaintext. It was public-facing. I promptly deleted the page from production and source control. My boss was horrified; the page was from a consulting firm that had written the original application ~10 years prior.
|
# ? Aug 19, 2013 14:23 |
|
Jesus Christ, just shows that those kinds of horrors aren't limited to PHP
|
# ? Aug 19, 2013 14:44 |
|
git config --global core.precomposeunicode true
|
# ? Aug 19, 2013 17:22 |
|
tef posted:git config --global core.precomposeunicode true I'm trying to find out what the point of that option is and I'm coming up empty. Though I have no trouble believing that an option called "pre-compose unicode" can be a pain. What's your story here?
|
# ? Aug 19, 2013 18:03 |
|
pokeyman posted:I'm trying to find out what the point of that option is and I'm coming up empty. Though I have no trouble believing that an option called "pre-compose unicode" can be a pain. What's your story here? It sounds like it's referring to the form of normalization used. With Unicode there are often equivalent encodings for the same character which are semantically identical but retained to retain round-trip encoding for other character sets. Since a string can contain either, in order to tell if two strings are the same there needs to be some canonical form. NFD is the fully decomposed normal form (everything that can be formed using a base character and combining diacritics is written that way) while NFC is the fully* composed form after full decomposition. I'm not sure how it ties into git. *For small values of fully.
|
# ? Aug 19, 2013 18:25 |
|
pokeyman posted:I'm trying to find out what the point of that option is and I'm coming up empty. Though I have no trouble believing that an option called "pre-compose unicode" can be a pain. What's your story here? Mac OS X does funky stuff with unicode in filenames to remain compatible with a dead OS nobody uses anymore. Linux doesn't, and some dead OS that people still use has always been a special case in Git.
|
# ? Aug 19, 2013 18:29 |
|
Cocoa Crispies posted:Mac OS X does funky stuff with unicode in filenames to remain compatible with a dead OS nobody uses anymore. Linux doesn't, and some dead OS that people still use has always been a special case in Git.
|
# ? Aug 19, 2013 19:28 |
|
Maybe the ultimate in multi-threaded debug printing bugs: http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=44387
|
# ? Aug 19, 2013 22:32 |
|
I wrote this. I'm sorry.code:
|
# ? Aug 20, 2013 11:26 |
|
Crosscontaminant posted:I wrote this. I'm sorry. Python code:
|
# ? Aug 20, 2013 11:47 |
|
|
# ? May 30, 2024 14:14 |
LOOK I AM A TURTLE posted:
Python code:
|
|
# ? Aug 20, 2013 11:51 |