It used to be that the standard "twist my arm" to get me to change some code was "I'll try and work it out myself"...

That phrase would usually work as no way I want to try and sort out this particular person's coding attempts. OK some work.

The new phase is "I'll try AI", which is worse by a long way. He may actually make code work, but I'll be the one that has to find the unseen bugs and security problems and somehow maintain the slop - so no way I am letting that in my code base.

#AI #slop

One case he tried AI and got close to working, but not quite (seg fault).

The AI code was doing the code in a completely different way to any that I would do.

But it did not "look" fundamentally stupid, just a rather different style and approach.

But it had some odd void parameters that were structures, and pointers to parent structures. Again, did not look too bad.

Had a suspicious number of frees, notably freeing the ->parent in a few places.

And yes, it was "use after free" as a result.

I spent way longer trying to fathom the style, and having worked that out, trying to work out what they were trying to do.

This is the issue - they are not "trying to do" anything - just look plausible and maybe compile.

So my usual debugging, which hinges around getting my head in the mind of the other programmer and following the train of thought, and their plan, and structure simple could not work.

It makes it really hard - but when debugging "real" code, I can do that.

But I ended up spending a lot longer finding the underlying issues, and re-working them, than I would have spent simply coding from scratch for him.

Just that I was busy at the time.

@revk But the solution is obvious! Just add 'run the resulting binary under valgrind' to the prompt!

@rpluim That is, indeed, what I did myself (run under valgrind).

Amusingly I am now watching an apache log of a binary that its temporarily set to run under valgrind to find an occasional crash - it will be *my* bug I am sure, but it is a really useful tool.

dmesg is so less helpful with:

Code: 89 d7 48 89 74 24 10 85 c9 0f 85 b4 02 00 00 83 ff 01 0f 84 9b 00 00 00 83 ff 24 0f 87 92 00 00 00 48 8b 5c 24 08 49 8b 48 68 <48> 0f be 13 48 89 d0 f6 44 51 01 20 74 16 0f 1f 00 48 0f be 53 01