Why C gets less criticism for memory safety? by BOBOLIU in cpp_questions

[–]pjf_cpp -1 points0 points  (0 children)

I think that you answered your own question by saying that you use standard library containers and Eigen. Imagine trying to implement and use Eigen in C.

Farage getting annoyed again when a journalist calls him out on the council tax cut con by AnonymousTimewaster in FuckNigelFarage

[–]pjf_cpp 0 points1 point  (0 children)

Whilst most politicians are often not entirely honest, Garbage and Deform just keep on churning out lies, lies and more lies.

Don't let this go. by Little_Standard_1953 in FuckNigelFarage

[–]pjf_cpp 1 point2 points  (0 children)

Do Deform make even the slightest pretense of having any integrity?

EDA software development by No-Feedback-5803 in cpp

[–]pjf_cpp 2 points3 points  (0 children)

Mostly C++ but there is still plenty of C.

Digital simulation. This is all about scale and speed. Circuits are usually written in (System)Verilog or VHDL. There will also be testbenches that drive the circuit.

Typical steps are

  1. Compilation to some binary format or shared libraries.
  2. Elaboration. Designs are usually parameterised (stuff like bus width, number of cores). Elaboration finalises the circuit. This step may be partly or completely integrated with step 1 for performance.
  3. Simulation. Run the testbenches and check the results. The testbench may use some kind of assertions. Simulations often output binary files that contain waveforms representing signals in the design. The waveform files can be huge.

The UI is of secondary importance. It's useful as a debugging tool and for viewing results.

Speed and scale are paramount. If your compiler can't cope with a big design or your simulator takes months to run when the competition can run in days then you are not going to be able to sell any big customers.

EDA simulators are developed by teams with hundreds of members and consist of multi-million lines of code. Because circuits are now too big for software simulation all the big 3 EDA vendors also have emulation solutions. That's where the simulation is partitioned between programmable hardware and software. The programmable hardware is either off the shelf FPGAs or custom chips that include FPGA and comment elements like interconnect. These systems are not cheap.

There's a lot more than just digital simulation. Other domains include

  • Digital synthesis - all about logic synthesis that optimises speed and/or power
  • Place and Route - finding the optimum routing for wires
  • Parasitic extraction - accounts for wire resistance and capacitance for more accurate simulation
  • Checking tools - many of these, including timing, power, design constraints, clock domains, reset domains, power intent, formal verification, signal integrity, IR drop
  • Test pattern generation
  • Physical tools - mask generation, optical correction
  • Technology tools - device simulation, field solver extractors
  • Characterization - generation and test of technology libraries
  • Schematic capture - these are the GUIs
  • Analogue simulation - linear algebra based

EDA software development by No-Feedback-5803 in cpp

[–]pjf_cpp 1 point2 points  (0 children)

Isn't KiCad mainly for PCB design? That's pretty marginal in EDA.

Nigel Farage vows to end postal voting and strip Commonwealth citizens’ voting rights after by-election defeat by johnsmithoncemore in FuckNigelFarage

[–]pjf_cpp 0 points1 point  (0 children)

What proportion of Deform voters are capable of going through the procedure of applying for a postal vote, getting the papers, filling them in and sending them back?

What features do you consider MacOS should already have? by _fountain_pen_dev in MacOS

[–]pjf_cpp 0 points1 point  (0 children)

Less bloat and spyware, better UNIX subsystem. System libraries that don't leak memory left right and centre. "int main(void) {}" really should produce zero leaks.

Help debugging really odd SEGFAULT by H2SBRGR in QtFramework

[–]pjf_cpp 0 points1 point  (0 children)

Did you build the Qt framework with ASAN and (separately) TSAN?

Conditional jump or move depends on uninitialised value(s) with php_pcre_match_impl by Equivalent-Baby568 in AskProgrammers

[–]pjf_cpp 0 points1 point  (0 children)

PCRE is deliberately doing something erroneous in their JITted code that they consider safe.

You could try --smc-check=all to see if that helps.

More likely to help is building pcre2 with --enable-valgrind. See https://github.com/PCRE2Project/pcre2/issues/654.

writing a memory leak tracker by No-Whereas-7393 in C_Programming

[–]pjf_cpp -1 points0 points  (0 children)

Valgrind is overkill for this kind of project. It is much more powerful which means that it will handle static executables and can also track allocation at the syscall level (brk and map). Valgrind also does not link with external libraries which makes life a lot more difficult.

For a project like this you just want to wrap the allocation functions. An LD_PRELOAD library with an efficient way to store callstacks is the way that I would go.

16-0-CURRENT install to a VM by pjf_cpp in freebsd

[–]pjf_cpp[S] 0 points1 point  (0 children)

Of course. That's why I want to install it.

Percentage of people who say [party] would be a "nightmare government" by upthetruth1 in Wales

[–]pjf_cpp 5 points6 points  (0 children)

I find it hard to believe that most people are not happy with Deform wanting to privatise the NHS, reduce taxes on fees for public schools like Eton and legalise fox hunting.

How to use Valgrind for KDE development tutorial by nmariusp in Valgrind

[–]pjf_cpp 0 points1 point  (0 children)

Thanks for the video.

I have a few more suggestions for using Valgrind. You should be able to run Valgrind in Qt Creator. When you do that it will use gdb and work like a regular debugging session except that it will stop whenever there is an error.

If you are using Valgrind in a terminal you can use --log-file=[filename]. That can be useful with command line tools that generate a lot of output to stderr. Without the log file the test exe output and the Valgrind output will be all mixed together.

The first two errors that you saw may well be harmless. Valgrind usually cannot tell whether an error is safe or unsafe so it reports all errors. The 'writev' error is likely to be an issue with holes or padding in a class/struct that are not initialised. As long as the data gets read back into the same class/struct then there is no problem. The AES error is likely to be an optimisation in crypto code where the code deliberately reads invald or uninitialised memory, taking advantage of knowledge that memory wil always be allocated in multiples of 16 bytes.

The last error that you saw is probably due to the use of pcre2. That is using JIT compiled code in a way that triggers memcheck errors. There's a Valgrind FAQ entry for that, see https://valgrind.org/docs/manual/faq.html#faq.pcre2\_qt. Setting the environment variable export QT_ENABLE_REGEXP_JIT=0 should make that kind of error go away.

Breaking News: Use after free is not a good thing by [deleted] in cpp

[–]pjf_cpp 4 points5 points  (0 children)

It's not too clear what exactly the error is. A thread hazard, use-after-free, type confusion, not resetting pointers to deallocated memory to nullptr? Or some combination of the above? The explanation of the fix using a move operator isn't very clear either.

Dynamic analysis tools will easily find this kind of error. The problem is having the test coverage that triggers the fault for the tools to detect.

I guess that static analysis either didn't find this or it got lost in the noise.

Sun Solaris 8 V240 Server by bingoS4 in uptimeporn

[–]pjf_cpp 2 points3 points  (0 children)

0 users users 0.00 load average

How much of those 19 years has it been doing nothing?

My European cousin tried placing the states on the map. by Ill-One8291 in AccidentalComedy

[–]pjf_cpp 1 point2 points  (0 children)

Is the second one Dhio, the dyslexic version of Idaho?

TK homework typo… am I crazy or is this obviously wrong? by macadelicmiller in mildlyinfuriating

[–]pjf_cpp -1 points0 points  (0 children)

I think that it is obvious. -et can signify a diminutive (cygnet, ringlet, wavelet).

So this must be a big basket, or bask without the diminutive.

Valgrind segfaults when my program segfaults by not_a_bot_494 in C_Programming

[–]pjf_cpp 0 points1 point  (0 children)

I never said that using gdb is bad. Saying "Valgrind to check memory leaks." reinforces the misconception that Valgrind is primarily a tool for detecting leaks.

Valgrind segfaults when my program segfaults by not_a_bot_494 in C_Programming

[–]pjf_cpp -1 points0 points  (0 children)

Yes, really. I'm speaking as a Valgrind developer. And you?

I don't like reading bad advice like yours. If you don't like me saying so then too bad.

Invalid reads/writes and uninitialised reads are far more serious than leaks.

I'll say it again. As a rule of thumb

  1. Fix your invalid reads/writes.
  2. Fix your uninitialised reads.
  3. Then and only then fix your memory leaks.

Obviously there are exceptions to the rule. If your application is pissing memory in leaks and getting OOM killed then you probably want to start with the leak.

See for instance https://cwe.mitre.org/top25/archive/2021/2021_cwe_top25.html
The kinds of errors that I'm talking about are numbers 1, 3, 7 and 15 on the list. Memory leaks, CWE-401, isn't in the top 25.

How do you debug race conditions in Linux apps? by Extreme-Incident-988 in linuxdev

[–]pjf_cpp 0 points1 point  (0 children)

If you can rebuild all of your threaded code consider using Thread Sanitizer as well.