Slashdot Mirror


Court Orders Breathalyzer Code Opened, Reveals Mess

Death Metal writes with an excerpt from the website of defense attorney Evan Levow: "After two years of attempting to get the computer based source code for the Alcotest 7110 MKIII-C, defense counsel in State v. Chun were successful in obtaining the code, and had it analyzed by Base One Technologies, Inc. By making itself a party to the litigation after the oral arguments in April, Draeger subjected itself to the Supreme Court's directive that Draeger ultimately provide the source code to the defendants' software analysis house, Base One. ... Draeger reviewed the code, as well, through its software house, SysTest Labs, which agreed with Base One, that the patchwork code that makes up the 7110 is not written well, nor is it written to any defined coding standard. SysTest said, 'The Alcotest NJ3.11 source code appears to have evolved over numerous transitions and versioning, which is responsible for cyclomatic complexity.'" Bruce Schneier comments on the same report and neatly summarizes the take-away lesson: "'You can't look at our code because we don't want you to' simply isn't good enough."

19 of 707 comments (clear)

  1. Code by Quiet_Desperation · · Score: 5, Insightful

    not written well, nor is it written to any defined coding standard

    Ah, so it's like most of the code in the world.

  2. Re:But does it work? by Yold · · Score: 5, Insightful

    I read the report earlier, and there are some very valid issues with the source. The first is that in incorrectly averages readings taken, assigning more weight to the first reading than the subsequent ones. It also has a buffer overflow issue, where an array is being written past its end, and even if this results in an error, it goes unreported.

    You would have to be a fricken moron not to have a problem with mis-averaging, however in my experiences with law-people, they can be even worse than PHBs.

  3. Re:But does it work? by geekgirlandrea · · Score: 5, Informative

    Read the article. The code in question, among other things, calculates an arithmetic mean of a sequence of values by successively averaging each value with the mean of all the previous ones, and reduces 12 bits of precision coming from the hardware sensor to 4 for some unspecified but undoubtedly stupid reason.

  4. Re:Good! by Red+Flayer · · Score: 5, Insightful

    when you do government contracting, the government should own what you do

    But they weren't doing government contracting. The produced a good that was purchased by the government. There's a very big difference.

    The key here is not that the government, or anyone, should own what they produced -- it's that when what they produced is used to convict someone, that person has the right to examine the methods used.

    It's not about openness, at all. It's about the right to a fair trial; openness is just a side effect.

    --
    "Trolls they were, but filled with the evil will of their master: a fell race..." -- J.R.R. Tolkien on Olog-hai
  5. No. by SanityInAnarchy · · Score: 5, Informative

    Just read Schneier's comments. He cites some of the more important things:

    Readings are Not Averaged Correctly: When the software takes a series of readings, it first averages the first two readings. Then, it averages the third reading with the average just computed... There is no comment or note detailing a reason for this calculation, which would cause the first reading to have more weight than successive readings.

    That alone should be enough -- the readings are not averaged correctly. But it goes on:

    The A/D converters measuring the IR readings and the fuel cell readings can produce values between 0 and 4095. However, the software divides the final average(s) by 256, meaning the final result can only have 16 values to represent the five-volt range (or less), or, represent the range of alcohol readings possible. This is a loss of precision in the data; of a possible twelve bits of information, only four bits are used. Further, because of an attribute in the IR calculations, the result value is further divided in half. This means that only 8 values are possible for the IR detection, and this is compared against the 16 values of the fuel cell.

    So we know it's buggy and inaccurate, to a moronic degree. If that wasn't enough:

    Catastrophic Error Detection Is Disabled: An interrupt that detects that the microprocessor is trying to execute an illegal instruction is disabled, meaning that the Alcotest software could appear to run correctly while executing wild branches or invalid code for a period of time. Other interrupts ignored are the Computer Operating Property (a watchdog timer), and the Software Interrupt.

    So, basically, it's designed to always return some value, even if it's wildly inaccurate, and even if the software is executing garbage at the time.

    In other words: It appears to be a very low-level equivalent of Visual Basic's "on error resume next".

    Whiskey. Tango. Foxtrot.

    So to answer your question: No, it does not work. Even if it did somehow work, there's obviously an unacceptably poor level of quality control here.

    --
    Don't thank God, thank a doctor!
    1. Re:No. by Ohio+Calvinist · · Score: 5, Insightful

      The problem in a lot of states is that .01 can make a huge difference between a DUI, a DUI with a "high BAC kicker", a wet-reckless, or nothing at all. It has to be accurate to at least a few 9's or for those "on the bubble" cases do have a severe level of doubt. Because driving with a .07 is not illegal (for the most part), but .08 is. The question in court is not "were you drinking tonight", but "how much did you drink" which is a very specific very objective, very deturminable piece of information.

      As states lower their legal limits to the point where they intersect with non-impaired drinking drivers, especially with a .01 or more margin of error, you're going to get a lot of overzealous cops in cities with revenue shortfalls taking innocent people in for DUIs and hopefully more and more of these "border cases" will bring these devices into question more than the over-the-top blacking out, pissing his pants multiple-offender does in court.

      --
      Forgive my spelling from time to time. I'm often posting during short breaks.
  6. Just remember by captnbmoore · · Score: 5, Insightful

    This will not stop the state from using this to make a felon of you.

    --
    The Navy Motto "IF it ain't broke Fix It" "A day is wasted if you don't learn something new"
  7. Re:not written to a coding standard? by SanityInAnarchy · · Score: 5, Insightful

    Did they find any coding bugs,

    Yes. RTFA.

    2. Readings are Not Averaged Correctly: When the software takes a series of readings, it first averages the first two readings. Then, it averages the third reading with the average just computed.

    There you go. It's also inaccurate:

    The A/D converters measuring the IR readings and the fuel cell readings can produce values between 0 and 4095. However, the software divides the final average(s) by 256... Further, because of an attribute in the IR calculations, the result value is further divided in half. This means that only 8 values are possible for the IR detection...

    And, if there were a catastrophic bug, you wouldn't know it, you'd just keep getting readings:

    An interrupt that detects that the microprocessor is trying to execute an illegal instruction is disabled, meaning that the Alcotest software could appear to run correctly while executing wild branches or invalid code for a period of time. Other interrupts ignored are the Computer Operating Property (a watchdog timer), and the Software Interrupt.

    This belongs on The Daily WTF.

    --
    Don't thank God, thank a doctor!
  8. Re:But does it work? by Carnildo · · Score: 5, Insightful

    Perhaps a better approach would be documented, repeatable testing of the device. When I challenge a radar gun, I get to ask about its calibration documents, but I don't think I get to debate the blueprints from which it was built.

    Calibration and testing won't reveal all the edge cases that might cause errors. Consider a radar gun designed to take the average of five samples. You've got a car moving away from you at 70 MPH, and a duck flies into the beam for one sample, moving towards you at 5 MPH. This gives the following five samples:

    70 70 70 -5 70

    I can see a way that badly-written code would turn that into an average speed of 106 MPH (storing a signed char as an unsigned char, which would turn the -5 into a 251), and yet it would pass calibration and every test someone's likely to perform.

    --
    "They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
  9. Re:But does it work? by Anonymous Coward · · Score: 5, Informative

    >> assigning more weight to the first reading than the subsequent ones.

    It seems to apply more weight to later readings:

    where a1=1, b1=2, c1=3, d1=4
    (A1+B1+C1+D1)/4 = 2.5 (the correct average)
        and
    (((((A1+B1)/2)+C1)/2)+D1)/2 = 3.125

  10. Re:But does it work? by fracai · · Score: 5, Insightful

    Presuming it's the same summary that I read, it contained a mistake.

    Readings are Not Averaged Correctly: When the software takes a series of readings, it first averages the first two readings. Then, it averages the third reading with the average just computed. Then the fourth reading is averaged with the new average, and so on. There is no comment or note detailing a reason for this calculation, which would cause the first reading to have more weight than successive readings.

    This actually places more weight on the final reading, not the first.

    --
    -- i am jack's amusing sig file
  11. Re:But does it work? by JCSoRocks · · Score: 5, Insightful

    I'm not generally someone that insists everything needs to be open source. However, in a situation like this, where this device makes the difference between a life changing conviction and exoneration, it's pretty obvious that people should have the right to examine it. The court was able to order it opened here, but it makes you wonder how many people have been screwed by this.

    Sadly in the majority of cases where evidence based on something like this (DNA, hair analysis, etc) is shown to be based on someone or something that's not good - nothing comes of it. I saw a blurb about a "forensic expert" that would give the prosecution any testimony they wanted. The state he was based in refused to reexamine the cases he was involved in even after he was shown to be a liar.

    It's depressing but it's one reason I steer clear of the law as much as I can. As much as we Americans like to think of our legal system as dispensing justice, the sad fact is that it frequently doesn't.

    --
    You are using English. Please learn the difference between loose and lose; they're, there, and their; your and you're.
  12. Re:But does it work? by digitalunity · · Score: 5, Informative

    In all 50 states, refusal to take a breathalyzer at the police station will result in a 1 year(minimum) suspension of your drivers license.

    In all 50 states, you can refuse to take a roadside breathalyzer as they're inadmissable in a court of law. If you have had even 1 drink, always ask to go to the station for a real breathalyzer. The PBT's, or portable breath testers, are wildly inaccurate and only give the police probable cause to arrest. It will not work in your favor to take it.

    --
    You can't legislate goodness. Let each to his own destiny, by will of his freely made choices.
  13. Re:Lint is crap by MadShark · · Score: 5, Interesting

    I work on embedded system stuff every day. At the end of the day, there are NO lint warnings in my code. First, I tend to avoid coding practices and designs that generate lint warnings. By and large, lint warns for a good reason most of the time. Second, in the limited number of situations where lint flags something incorrectly, there are methods for silencing the warnings via special comments. I'm currently working on a 50000 line project, and there are about 70 places in the entire code base were we had to tell lint to ignore a warning. Each warning suppression is documented as to why lint is incorrect.

    Lint isn't a perfect tool by any means but in my opinion, anyone developing C code without it is not acting in a professional manner.

  14. Re:But does it work? by DeadCatX2 · · Score: 5, Insightful

    You are correct. In the biz, we refer to this as an exponentially-weighted moving-average-filter. Recent samples are weighted more heavily than older samples.

    y(n) = alpha*x(n) + (1 - alpha)*y(n-1)

    The alpha value controls how much of the current input makes it to the output and how much of the old output stays. i.e. with an alpha value of 0.5, half of the new value is added to half of the old value. With an alpha of 0.1, 10% of the new value gets added to 90% of the old value.

    This filter is nice because it doesn't require you to remember all the values that you want to average together, but it's a horrible way to get over the inherent noisiness in sensors.

    --
    :(){ :|:& };:
  15. Re:But does it work? by TheEldest · · Score: 5, Interesting

    This seems to make sense to me. The breathalizer is supposed to measure the blood alcohol content, and this is done by measuring the alcohol content in air expelled by the *lungs* (with a knowlege of partial pressures).

    But if you equally weight beginning readings with ending readings, then you can be skewed by the first reading, which comes from the air in the mouth, instead of the lungs (giving low scores for people with time since their last drink, and people high scores with a recent last drink).

    I would think that this method would give a more accurate reading by filtering out the readings from 'mouth air' and giving preference to 'lung air'.

    But regardles, tests should have been done using both methods, and comparing to blood test to see which returns more consistantly accurate results. I wonder if those tests need to be made public as well.

  16. Re:But does it work? by The+Moof · · Score: 5, Interesting

    Don't always assume the judge will, in fact, look at the evidence and arguments. In their eyes, it doesn't look good to overturn a DUI conviction. Period.

    Had a buddy of mine leave a night club and he got pulled over for supposedly making an illegal left turn. Blew over the state's .07 and got arrested per the usual.

    However, the judge didn't care that there was no reason to be pulled over (with photos of the left-turn sign) since the cop explicitly said it wasn't due to erratic driving, *only* the 'illegal' left turn. Examples must be made. DUI upheld.

    Hell, even I got pulled over once for simply driving at 2am, but my breathalyzer revealed a stunning 0.00% BAC. After chatting with the cop for a bit, turns out they were just looking for easy DUI targets, and I happened to be driving on the same road as them.

  17. But is it broken? HELL YES!!! by swordgeek · · Score: 5, Informative

    OK, LOTS of strange posts from people who claim to have read the article but only see that it's bad code, not actually broken.

    Read it again. It's broken from a legal liability and trustworthiness standpoint. It's broken from a precision standpoint. It's broken from an algorithm standpoint. It is not trusworthy, precise, accurate, or correct.

    "It is clear that, as submitted, the Alcotest software would not pass development standards and testing for the U.S. Government or Military. It would fail software standards for the Federal Aviation Administration (FAA) and Federal Drug Administration (FDA), as well as commercial standards used in devices for public safety. This means the Alcotest would not be considered for military applications such as analyzing breath alcohol for fighter pilots. If the FAA imposed mandatory alcohol testing for all commercial pilots, the Alcotest would be rejected based upon the FAA safety and software standards."

    Nobody in the government or military would be allowed to trust this, if it weren't already in use.

    "Results Limited to Small, Discrete Values"

    Sixteen values is all it displays! It throws away almost all of the precision of the 12-bit ADC, and reduces it to 4 bits! This is NOT precise enough!

    "Catastrophic Error Detection Is Disabled"
    "Diagnostics Adjust/Substitute Data Readings"
    "Range Limits Are Substituted for Incorrect Average Measurements"
    "The software design detects measurement errors, but ignores these errors unless they occur a consecutive total number of times."

    It's not correct. It's not accurate. It's not good enough. The odds are VERY good that some people over the limit have gotten off lucky, and also that some people below the limit now have criminal records.

    --

    "People who do stupid things with hazardous materials often die." -- Jim Davidson on alt.folklore.urban
  18. Re:Is this 1968? by DeadCatX2 · · Score: 5, Insightful

    With an attitude like that, it's obvious that you have little experience with embedded systems...

    --
    :(){ :|:& };: