Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      From Data To Decisions: UX Strategies For Real-Time Dashboards

      September 13, 2025

      Honeycomb launches AI observability suite for developers

      September 13, 2025

      Low-Code vs No-Code Platforms for Node.js: What CTOs Must Know Before Investing

      September 12, 2025

      ServiceNow unveils Zurich AI platform

      September 12, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Distribution Release: Q4OS 6.1

      September 12, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Optimizely Mission Control – Part III

      September 14, 2025
      Recent

      Optimizely Mission Control – Part III

      September 14, 2025

      Learning from PHP Log to File Example

      September 13, 2025

      Online EMI Calculator using PHP – Calculate Loan EMI, Interest, and Amortization Schedule

      September 13, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      sudo vs sudo-rs: What You Need to Know About the Rust Takeover of Classic Sudo Command

      September 14, 2025
      Recent

      sudo vs sudo-rs: What You Need to Know About the Rust Takeover of Classic Sudo Command

      September 14, 2025

      Dmitry — The Deep Magic

      September 13, 2025

      Right way to record and share our Terminal sessions

      September 13, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Tangled Up in Foo

    CodeSOD: Tangled Up in Foo

    April 24, 2025

    DZ‘s tech lead is a doctor of computer science, and that doctor loves to write code. But you already know that “PhD” stands for “Piled high and deep”, and that’s true of the tech lead’s clue.

    For example, in C#:

    <span class="hljs-function"><span class="hljs-keyword">private</span> List<Foo> <span class="hljs-title">ExtractListForId</span>(<span class="hljs-params"><span class="hljs-built_in">string</span> id</span>)</span>
    {
    	List<Foo> list = <span class="hljs-keyword">new</span> List<Foo>();
    	<span class="hljs-keyword">lock</span> (<span class="hljs-keyword">this</span>)
    	{
    		<span class="hljs-keyword">var</span> items = _foos.Where(f => f.Id == id).ToList();
    		<span class="hljs-keyword">foreach</span> (<span class="hljs-keyword">var</span> item <span class="hljs-keyword">in</span> items)
    		{
    			list.Add(item);
    		}
    	}
    	<span class="hljs-keyword">return</span> list;
    }
    

    The purpose of this function is to find all the elements in a list where they have a matching ID. That’s accomplished in one line: _foo.Where(f => f.Id == id). For some reason, the function goes through the extra step of iterating across the returned list and constructing a new one. There’s no real good reason for this, though it does force LINQ to be eager- by default, the Where expression won’t be evaluated until you check the results.

    The lock is in there for thread safety, which hey- the enumerator returned by Where is not threadsafe, so that’s not a useless thing to do there. But it’s that lock which hints at the deeper WTF here: our PhD-having-tech-lead knows that adding threads ensures you’re using more of the CPU, and they’ve thrown threads all over the place without any real sense to it. There’s no clear data ownership of any given thread, which means everything is locked to hell and back, the whole thing frequently deadlocks, and it’s impossible to debug.

    It’s taken days for DZ to get this much of a picture of what’s going on in the code, and further untangling of this multithreaded pile of spaghetti is going to take many, many more days- and much, much more of DZ’s sanity.

    [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleLinux Show Player is a cue player designed for stage productions
    Next Article CVE-2025-3761 – My Tickets – WordPress Privilege Escalation Vulnerability

    Related Posts

    News & Updates

    Building personal apps with open source and AI

    September 12, 2025
    News & Updates

    What Can We Actually Do With corner-shape?

    September 12, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2024-42212 – HCL BigFix Compliance CSRF Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    The Secret Playbook: Leadership Lessons From Indian-Origin CEOs

    Development

    ¿Por que no pytest no encuentra las pruebas? “collected 0 items “

    Development

    The “Super Weight:” How Even a Single Parameter can Determine a Large Language Model’s Behavior

    Machine Learning

    Highlights

    CVE-2025-2172 – Aviatrix Controller Command Injection

    June 23, 2025

    CVE ID : CVE-2025-2172

    Published : June 23, 2025, 2:15 p.m. | 4 hours, 9 minutes ago

    Description : Aviatrix Controller versions prior to 7.1.4208, 7.2.5090, and 8.0.0 fail to sanitize user input prior to passing the input to command line utilities, allowing command injection via special characters in filenames

    Severity: 0.0 | NA

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    Rilasciata FunOS 25.04: la Distribuzione GNU/Linux Leggera e Moderna Basata su Ubuntu 25.04

    Rilasciata FunOS 25.04: la Distribuzione GNU/Linux Leggera e Moderna Basata su Ubuntu 25.04

    April 21, 2025

    OpenAI wins gold at prestigious math competition – why that matters more than you think

    July 21, 2025

    CVE-2025-27031 – Cisco Router IOCTL Memory Corruption

    June 3, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.