RE: Segmentation fault: what's wrong with this code?
"'Michael Wojcik' via openssl-users" <[email protected]> Fri, 5 Jun 2026 21:34:42 +0000
| Newsgroups | gmane.comp.encryption.openssl.user |
|---|---|
| Message-ID | <CH3PPFBCC09965CC65389BD7ED7D2479A92C0112@CH3PPFBCC09965C.namprd07.prod.outlook.com> |
The easiest way to diagnose this might be to build OpenSSL for debug, then = reproduce under valgrind (with memcheck, which is the default tool). Odds a= re decent that will tell you exactly where it went wrong. Even just running= under gdb with debug symbols would be useful. The usual causes of a SEGV in a free-function are an invalid pointer or pri= or heap corruption. An invalid pointer could be already freed (though in si= ngle-threaded programs I think glibc is generally pretty good at catching t= his and SIGABRTs instead) or not a pointer to a heap-allocated object (e.g.= because someone did pointer arithmetic on it, or overwrote it with a buffe= r overflow elsewhere, or it's just rubbish). Prior heap corruption could be= many things. And, of course, a non-trivial free-function would be attempti= ng to operate on data within the object being freed, and something there co= uld be bogus. But using the available tooling - valgrind or even glibc's built-in malloc = debugging - is generally faster than code inspection, if the issue is easy = to reproduce. -- Michael Wojcik =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D Rocket Software, Inc. and subsidiaries =E2=96=A0 77 Fourth Avenue, Waltham = MA 02451 =E2=96=A0 Main Office Toll Free Number: +1 855.577.4323 Contact Customer Support: https://my.rocketsoftware.com/RocketCommunity/RCE= mailSupport Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - = http://www.rocketsoftware.com/manage-your-email-preferences Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D This communication and any attachments may contain confidential information= of Rocket Software, Inc. All unauthorized use, disclosure or distribution = is prohibited. If you are not the intended recipient, please notify Rocket = Software immediately and destroy all copies of this communication. Thank yo= u. --=20 You received this message because you are subscribed to the Google Groups "= openssl-users" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to openssl-users+unsubscribe-MCmKBN63+Bmbup2nOX2J7Q@public.gmane.org To view this discussion visit https://groups.google.com/a/openssl.org/d/msg= id/openssl-users/CH3PPFBCC09965CC65389BD7ED7D2479A92C0112%40CH3PPFBCC09965C= .namprd07.prod.outlook.com.