Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
shrughes
Oct 11, 2008

(call/cc call/cc)

beoba posted:

google-test buddy! :respek:

PS why does this need to be tested, does sizeof(cache_t) frequently change?

This was the test that I added which exposed the bug.

I was getting some crazy errors from valgrind about uninitialized data allegedly created at a certain point in some function on the stack. It made no sense. We had had some problems that had allegedly been fixed with object sizes being too big, so I ruled that out. It turns out that they weren't fixed. I don't know what my coworkers are smoking. The stack pointer had completely overflown a guard page.

It turns out that some performance monitoring variables just make a fixed-size array hardcoded to the maximum possible number of POSIX threads that the system allows. (It was a hard-coded constant in our project set to 128 -- by default we actually use fewer threads than that, depending on command line arguments or the CPU.) So putting such large arrays in an object is a braindead idea, especially when you have a bunch of them. And really the performance monitoring variables should have been allocating those arrays on the heap anyway -- that's something I should have fixed.

(We can't nonchalantly say "dynamically decide how big such arrays should be based on command line arguments" because that would needlessly complicate them.)

My coworkers found this sort of bug a few days before but apparently they only fixed the one case where they saw the behavior instead of thinking about the other places they had been mucking with performance monitoring.

shrughes fucked around with this message at 09:00 on May 17, 2012

Adbot
ADBOT LOVES YOU

pseudopresence
Mar 3, 2005

I want to get online...
I need a computer!
I don't want to keep linking this blog but this is amazing.

http://abandonmatlab.wordpress.com/2012/05/17/heres-another-way-to-crash-matlab/

code:
function pushdown(N, crash)
    %an N of more than about 1000000 with crash=1 is interesting.
    a = {};
    for i = 1:N
        a = {rand() a};
    end

    if ~exist('crash', 'var') || ~crash
        %feed it to matlab's deallocator one piece at a time, or it will choke.
        for i = 1:N
            a = a{2};
        end
    end
end
If you set crash=1, only the first part of the code runs. It creates a linked list of N items using cell arrays for the nodes. When MATLAB tries to garbage collect it, it will crash. The 'fix' is the guarded code below it, which manually pops from the head of the list so the garbage collection can process it one node at a time.

People pay money for this.

ToxicFrog
Apr 26, 2008


Fib posted:

If you set crash=1, only the first part of the code runs. It creates a linked list of N items using cell arrays for the nodes. When MATLAB tries to garbage collect it, it will crash. The 'fix' is the guarded code below it, which manually pops from the head of the list so the garbage collection can process it one node at a time.

People pay money for this.

How the gently caress :psyduck:

Does it use a recursive mark-and-sweep collector and blow its stack when traversing the list or something?

E: no, that can't be it or the fix wouldn't work as written.

E: Oh, the post links to an earlier one that explains why it dies - apparently, when deallocating, the deallocator for the list head triggers deallocation of the next list node, which is to say, it calls the destructor for it. This means you end up with one stack frame per list node as they get destroyed and it rapidly blows the stack. Jesus.

ToxicFrog fucked around with this message at 17:46 on May 17, 2012

uncleTomOfFinland
May 25, 2008

STS as in SpringSource Tools Suite (glorified Eclipse as far as I can tell)

quote:

DON'T INSTALL STS INTO "Program Files" UNDER WINDOWS 7. This causes a number of problems when STS, Roo or tc Server tries to write to files. Windows 7 treats the "Program Files" part of your drive very specifically, because it tries to avoid that programs manipulate the content of the "Program Files" directory. This causes weird problems with Spring Roo (which tries to write some configuration files) and possibly also tc Server.
Looks like Spring people haven't gotten the hang of this do not write to Program Files ever thing.

Sang-
Nov 2, 2007

uncleTomOfFinland posted:

STS as in SpringSource Tools Suite (glorified Eclipse as far as I can tell)

Looks like Spring people haven't gotten the hang of this do not write to Program Files ever thing.

I thought that if something tried to write config files to that location, windows did something with AppData\Local\VirtualStore instead?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Sang- posted:

I thought that if something tried to write config files to that location, windows did something with AppData\Local\VirtualStore instead?

Sure, but if the OS silently writes them there and you've hard-coded %ROO_INSTALL_DIR%\some\path to go looking for them, they won't be there and things will act funny or outright break. I'm fairly certain there are still Notepad++ plugins that still don't understand this as well.

Didn't Microsoft threaten to make Windows 7 not do that just to encourage good behavior?

edit: By 'not do that' I mean hand the program a nice access error instead of letting it poo poo in the corner and pretend nothing happened.

Munkeymon fucked around with this message at 23:19 on May 17, 2012

Zamujasa
Oct 27, 2010



Bread Liar
You can always get around the issue of not writing to Program Files by just making your program always run as Administrator. Nothing could possibly go wrong with that. :rolleyes:





I hate to keep bringing more and more horrors from work to this thread, but when they're created right in front of my eyes by the "CTO", I... ugh.


Boss decided that he was going to implement a Javascript-based cost calculator to our system when you add a device, ostensibly because I have too much to do as it is.

The database table for it was already created backwards. Rather than create plans and tie the accounts to a plan, the plans are instead tied to the account, and everything is nullable. I can only imagine the kind of fun that will emerge if we have two rows in the plans table that have the same account ID, or if there's an account that has no matching rows in the plans table.

Then I noticed that the layout of the page seemed wrong, like how most browsers break if you gently caress up a table or otherwise break something fundamental that makes it go into total quirks mode. So I open up the source to the page and

code:
<SCRIPT>
var sms_cost = 5;
var email_cost = 1;
var magic3_cost = 3;
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" />

 [lots of HTML and some JS sprinkled about, along with a real gem
  of a huge mudball that creates a new row in a table cell by cell,
  with no idea how these amazing things called "arrays" work]


	var num_rows = document.form1.num_rows.value;



	for(var i=0;i<num_rows;i++){

		var numSubRow = eval("document.form1.numRow_"+(i+1)+".value");	

:suicide:

(as usual, the left-alignment is not an error in copying.)

I tried to explain to him why his database table layout was absurd (it even includes an auto-created column from MySQL Workbench that is totally unused, like all of his other tables) and he basically just gave me a funny look and made some dumb joke. :eng99:



Fake edit: Oh god, I just realized that rather than pouplate the dropdowns on this form with the ID numbers from the table it pulls from, they're in that Typical_Boss_Coding~~MagicVal format. There's no way at all that can go wrong. (Oh, and the "specialists" that built this system also named all the form fields "field_1_4", because the fact you can name them field[1][4] and save yourself huge amounts of work seemed to have escaped them.)

Impotence
Nov 8, 2010
Lipstick Apathy

Zamujasa posted:

<html xmlns="http://www.w3.org/1999/xhtml" />

Did he seriously close the <html> tag?

nielsm
Jun 1, 2009



Biowarfare posted:

Did he seriously close the <html> tag?

That's impressive. I didn't think it was possible to make that many different XML mistakes on a single XHTML page.

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
When I used Matlab about 15 years ago it didn't have a reputation of being a broken piece of poo poo. Maybe Mathworks has had some major developer rotation since then.

Although anyone who approaches Matlab with the idea that they won't have to translate their problem into matrix-crunching terms has already lost.

Gazpacho fucked around with this message at 00:08 on May 18, 2012

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Zamujasa posted:

You can always get around the issue of not writing to Program Files by just making your program always run as Administrator. Nothing could possibly go wrong with that. :rolleyes:
You could also just make the installer grant write permissions to the user on the program's folder.

Zamujasa
Oct 27, 2010



Bread Liar

Biowarfare posted:

Did he seriously close the <html> tag?

:stare:

I didn't even notice that. He didn't edit that part, though -- that's from the last people who worked on this monstrosity.

VikingofRock
Aug 24, 2008




Today my lab partner (I'm an undergrad physicist) told me he wrote a 400-line Python program to parse a CSV file. Here's what the file looks like:

code:
Spectrum Name:,Cobalt 60
Description:,
Student ID:,Matt and Devon
Detector Used:,NaI(TI) Model 6S6P1.5VDC2
Comments:,2-28-12
Acquisition Mode:,PHA
High Voltage:,550
Conversion Gain:,1024
Coarse Gain:,4
Fine Gain:,1.24
ULD:,102.300000%
LLD:,1.300000%
Real Time Elapsed:,603.00
Live Time Elapsed:,600.00
Start Time:,Thursday, March 01, 2012, 15:10:03
End Time:,Thursday, March 01, 2012, 15:20:07

Channel Data:
Chan,,Counts
[1024 lines of x data, y data]

Vanadium
Jan 8, 2005

I'd be more worried about whatever generated that file.

VikingofRock
Aug 24, 2008




Vanadium posted:

I'd be more worried about whatever generated that file.

It's a spectrometer, which we have no control over unfortunately.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
That is not a CSV file.

ToxicFrog
Apr 26, 2008


Gazpacho posted:

When I used Matlab about 15 years ago it didn't have a reputation of being a broken piece of poo poo. Maybe Mathworks has had some major developer rotation since then.

Although anyone who approaches Matlab with the idea that they won't have to translate their problem into matrix-crunching terms has already lost.

15 years ago was Matlab 5 which the AbandonMatlab guy does not have fond memories of either.

If I had to guess, I'd guess it's just a matter of less to compare it to and fewer people to do the comparison - Python was relatively new, most scientists were using MATLAB or Fortran and the proportion of scientists who were also programmers was smaller. MATLAB was originally meant to be a kinder, gentler interface to Fortran numeric computation libraries; its flaws are a lot less obvious when you're coming to it from Fortran '77 rather than SciPy or R.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Zamujasa posted:

*Don't know how to use arrays....*
Apparently this is a common sickness...

http://forums.somethingawful.com/showthread.php?threadid=2803713&pagenumber=281&perpage=40#post401853293

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
Last week I posted in this thread about a terrible digital video camera driver that takes 300+ milliseconds to acquire a 640x480 image frame. After getting nowhere with the manufacturer on the issue I finally decompiled their dll file to see what the hell was going on.

Their dll connects to a lower-level driver process via .NET's remoting system to pass data back and forth. Unfortunately none of .NET's picture classes are serializable in the way remoting requires so they can't be used. Their solution was to create a Pixel class that was serializable and then pass 640*480 = 307200 of those Pixel objects per frame, calling for each one individually. This consumes 100% of the CPU cycles for one core of a modern machine to pass ~3MB/second between two local processes.

Then just for kicks the RGB values of each Pixel are mapped wrong and effectively you get BGR data with RGB labeling.

evensevenone
May 12, 2001
Glass is a solid.

Fib posted:

People pay money for this.

You're paying money for the libraries and toolkits, not the language. The language is from like 1975 and is trash and the interpreter is janky as a result. But that's not really the point, the point is that it's really fast to develop in and the library code is written by people with actual understanding of numerical methods. It's a prototyping environment, that's all.

I haven't used SciPy a ton but I would imagine the libraries are still way behind where matlab is

ToxicFrog
Apr 26, 2008


evensevenone posted:

You're paying money for the libraries and toolkits, not the language. The language is from like 1975 and is trash and the interpreter is janky as a result. But that's not really the point, the point is that it's really fast to develop in and the library code is written by people with actual understanding of numerical methods. It's a prototyping environment, that's all.

I haven't used SciPy a ton but I would imagine the libraries are still way behind where matlab is

The AbandonMatlab guy certainly seems to think that SciPy and R stack up favourably against Matlab even when taking the libraries into account (and he has a lot bad to say about how hard developing and sharing libraries is in matlab).

Not having used Matlab and only having barely used SciPy and R I can't say how right he is.

hobbesmaster
Jan 28, 2008

Suspicious Dish posted:

That is not a CSV file.

There are values separated by commas! Of course it's a csv file! I bet it even imports to excel.

In fact, if excel can read it I wouldn't think about the format. There's far worse in EE land...

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

hobbesmaster posted:

There are values separated by commas! Of course it's a csv file! I bet it even imports to excel.

In fact, if excel can read it I wouldn't think about the format. There's far worse in EE land...

Agreed, that's not at all a bad output format for that kind of hardware. Generally the threshold of acceptability for measurement output files is (1) Can I open it in Excel? and (2) Can I interpret the Excel file without having to study the file format spec in rigorous detail?

The main things I'd bitch about are that 'Channel' should really be displayed as wavelength (with units) and that the date/time fields have unnecessary commas. Also Matt and Devon need to fill out Description fields so they can associate a datafile with a particular experiment.

For comparison, we have a spectrophotomer that produces output files like
code:
600
0.1
[400, 600, 800, 1100]
[0.157, 0.136, 0.298, 0.175]
1234
1578
955
(500 more lines)
which requires that you understand what those unlabeled numbers mean to reconstruct the spectrum. I'd take that other format any day, but probably wouldn't need 400 lines of code to parse it.

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug

PDP-1 posted:

Last week I posted in this thread about a terrible digital video camera driver that takes 300+ milliseconds to acquire a 640x480 image frame. After getting nowhere with the manufacturer on the issue I finally decompiled their dll file to see what the hell was going on.

Their dll connects to a lower-level driver process via .NET's remoting system to pass data back and forth. Unfortunately none of .NET's picture classes are serializable in the way remoting requires so they can't be used. Their solution was to create a Pixel class that was serializable and then pass 640*480 = 307200 of those Pixel objects per frame, calling for each one individually. This consumes 100% of the CPU cycles for one core of a modern machine to pass ~3MB/second between two local processes.

Then just for kicks the RGB values of each Pixel are mapped wrong and effectively you get BGR data with RGB labeling.

Was it Canon EOD? I had this problem, except that their image preview utility output video just fine, and the internet was full of people wondering how to get it to work that well with no solutions.

uncleTomOfFinland
May 25, 2008

Plorkyeran posted:

You could also just make the installer grant write permissions to the user on the program's folder.

Or even make the installer warn you about the fact that this unusual way of installing programs into Program Files will break your IDE. :downs:

nielsm
Jun 1, 2009



hobbesmaster posted:

There are values separated by commas! Of course it's a csv file! I bet it even imports to excel.

In fact, if excel can read it I wouldn't think about the format. There's far worse in EE land...

Not into Excel running on a machine with European number formats configured!
Last time I tried loading a file with comma-separated values directly in Excel it just laughed at me and gave me rows with a single data cell in each, containing all the values.
It wants semicolons here.

(You can go through some explicit Import function to get it to load properly, but as I recall, you don't access it through the normal Open command.)

geonetix
Mar 6, 2011


nielsm posted:

Not into Excel running on a machine with European number formats configured!
Last time I tried loading a file with comma-separated values directly in Excel it just laughed at me and gave me rows with a single data cell in each, containing all the values.
It wants semicolons here.

(You can go through some explicit Import function to get it to load properly, but as I recall, you don't access it through the normal Open command.)

Oh god, this has bugged me for so long. Every time somebody writes an export CSV function in some application, it comes out with comma or semicolon separated values. Then we proceed into getting complaints from half the office that it "won't work". I always thought it depended on the version of Excel being used, but somehow I didn't think of localized number formats. Is there a way to force Excel into dealing with it properly, or do I have to succumb to using xslx?

Good job MS Office team :golfclap:

KaneTW
Dec 2, 2011

Sang- posted:

Matlab could fill this entire thread with how awful it is.

Don't even get me started about MAPLE.

I have no idea how people can write software that terrible. Been using Mathematica for a couple years now and it's oh so much better.

Except this class requires me to use MAPLE.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

geonetix posted:

Oh god, this has bugged me for so long. Every time somebody writes an export CSV function in some application, it comes out with comma or semicolon separated values. Then we proceed into getting complaints from half the office that it "won't work". I always thought it depended on the version of Excel being used, but somehow I didn't think of localized number formats. Is there a way to force Excel into dealing with it properly, or do I have to succumb to using xslx?

Good job MS Office team :golfclap:

If everyone's using Excel why are you using csvs in the first place?

nielsm
Jun 1, 2009



Jonnty posted:

If everyone's using Excel why are you using csvs in the first place?

Sounds like other software/scripts that produce raw data which they then want to process in Excel.

geonetix
Mar 6, 2011


Jonnty posted:

If everyone's using Excel why are you using csvs in the first place?

The office checks it in excel (or open office), we put it in other things and so do customers.

nielsm
Jun 1, 2009



geonetix posted:

The office checks it in excel (or open office), we put it in other things and so do customers.

At least OpenOffice asks you what format that CSV is actually in before opening, and gives you a preview. (But otherwise it's more annoying than Excel to use.)

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Suspicious Dish posted:

That is not a CSV file.
You say that as if anyone ever gets CSV output right. This file is saner than most.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

KaneTW posted:

Don't even get me started about MAPLE.

I have no idea how people can write software that terrible. Been using Mathematica for a couple years now and it's oh so much better.

Except this class requires me to use MAPLE.

I made a couple of posts a while ago itt about Maple, but I don't think many people have used it, so I didn't get a response. Never used Mathematica.

KaneTW
Dec 2, 2011

Hammerite posted:

I made a couple of posts a while ago itt about Maple, but I don't think many people have used it, so I didn't get a response. Never used Mathematica.

Yeah, I think Maple is more used in Europe than the US. My core complaints about Maple are that it tries to shoehorn 'all those programming trends' into a single thing and requires you to write code like

code:
ugh := x -> Quantity(GetValue(x) * GetUnit(x), GetError(x) * GetUnit(x)):
ME := ugh(Constant(M[Earth]));
MS := ugh(Constant(M[Sun]));
G := ugh(Constant(G));
a := Quantity(simplify(Unit(AU)), 1^(-20) * Unit(m));
T := combine(sqrt(4 * Pi^2 / (G*a^3*(MS+ME))), errors);
Nope, you can't use Constant directly despite the object being supported by Getxxx.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
If you control the output, use tab-separated. Tabs are almost *never* part of the valid data stream for these kinds of files. Why the hell would you use a really common character like commas or quotes? That would be like making the ? mark your end of line character instead of... I dunno, the unprintable CR/LF which are also almost never part of a valid data stream.

Hell is other programmers.

tef
May 30, 2004

-> some l-system crap ->
If only there were ascii characters for this very purpose :q:

nielsm
Jun 1, 2009




If just there was an easy way to type them.
(Yeah, there probably would be if they had ever been used in practice.)

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

:chord::hf::smug:
The cool thing is that they are printed as this weird symbol in the console, so the text doesn't look all run together.

One of my guys was delimiting fields using a colon, guess what happened when we received a url? I told him about those separators and he got all happy and started using them everywhere they made sense. :unsmith:

Adbot
ADBOT LOVES YOU

..btt
Mar 26, 2008

Ender.uNF posted:

If you control the output, use tab-separated.

That's not much use if you want your average user to be able to double-click the file to load it into Excel. In which case the real solution is to properly quote/delimit special characters - it's not complicated. I wrote an Excel-compatible csv parser/generator in about 30 minutes not too long ago (because for some reason .net doesn't have one built-in).

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply