From owner-freebsd-hackers@freebsd.org Sun Apr 18 18:53:42 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 257035F16E1 for ; Sun, 18 Apr 2021 18:53:42 +0000 (UTC) (envelope-from rollingbits@gmail.com) Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FNfH92rTQz4QmS for ; Sun, 18 Apr 2021 18:53:41 +0000 (UTC) (envelope-from rollingbits@gmail.com) Received: by mail-qk1-x72a.google.com with SMTP id d15so20899144qkc.9 for ; Sun, 18 Apr 2021 11:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:from:mime-version:date:message-id :references:in-reply-to:subject:to; bh=a9aQygPswOhV2ki/fr+DPEd9kKYiqrpEUqLUp3yCyJU=; b=OK8qqrvh0Re9nDV/1pfThFIqluJCtXft1U37YZB6jQ8G6m5vyGreCaB8UsZkGmKWyK Km5UG452/z6KF2zCdqEW5keW6UOCl86WFejW9srQnrdyfuqfzSHzDwlw6Zt0Yj8Fe02f YwrxKJtVQqWQCw6WY9pmGyAAXPYAj9UuBeLQ18BCGx4WeEsQ1ujEhHW4rQwP9OFF/0GT aHkYQtWpCBZ2suKE43irzTOMadfIZhmrWkxR+5B9SHSq0oUGa+WIB44rIhW25O79JxwI MPsjPxgZRRDZ/Xk0JGbu9hA1Y/SOnjWlntu0plaJbHtEwUgIqVtbhr6AlX4miKYOGHob X3Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version:date :message-id:references:in-reply-to:subject:to; bh=a9aQygPswOhV2ki/fr+DPEd9kKYiqrpEUqLUp3yCyJU=; b=CdfwF+5FdYfZfFhVAdKjxxDKnPiUYZ0cXReJ6nEGfwF8+ZtY+e956jLdZVLZgmf+G3 eRe4p+2fNjeNW2J+SNe+4Bh1vHOwKQhxBMNgx6okQuHhcMinsqCGIZUGaVwV7BeZR75b MJXVH46CiIIuzkw+imaWR9hPoj166ezraYIt5aPpZ6FhODm1XyfPzSmVM3HmrNyKHvXN l/dfxmuKykaotvf/edDOEDPA6crXd9n6xn8iGL0KttA2eBshNnjbDsgw119yMBeB077F 9jsHJugmlb1eIkUlO9uORJxrorHoltom1ljzP8dLDvpGJRK4fJi5pF5uTKSPaSJJVto9 zaGg== X-Gm-Message-State: AOAM5331YTLIt7bsrSf1GqceZ4LysjIwOsj7AYU7bEEMS+ZicgHnaIQn nz7xXhUlSaRfzzABHQi0mCM5WumDPtU= X-Google-Smtp-Source: ABdhPJy8xtlZUjliqAFgrWd/Pp+WYmEfNHOjMVychA+kzhb4Dbneuy+LZP5oKVXe6ftuGE5GSG/lGg== X-Received: by 2002:a37:953:: with SMTP id 80mr8848700qkj.43.1618772020193; Sun, 18 Apr 2021 11:53:40 -0700 (PDT) Received: from ?IPv6:2804:389:1059:2519:10e0:67ed:2490:5874? ([2804:389:1059:2519:10e0:67ed:2490:5874]) by smtp.gmail.com with ESMTPSA id k26sm8420279qkg.120.2021.04.18.11.53.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 18 Apr 2021 11:53:39 -0700 (PDT) From: =?utf-8?Q?Lucas_Nali_de_Magalh=C3=A3es?= Mime-Version: 1.0 (1.0) Date: Sun, 18 Apr 2021 15:53:37 -0300 Message-Id: <4AF3D639-FB07-46B5-9058-114576BD4EDB@gmail.com> References: In-Reply-To: Subject: Re: Debugging signal 11 To: freebsd-hackers@freebsd.org X-Mailer: iPhone Mail (18D70) X-Rspamd-Queue-Id: 4FNfH92rTQz4QmS X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=OK8qqrvh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rollingbits@gmail.com designates 2607:f8b0:4864:20::72a as permitted sender) smtp.mailfrom=rollingbits@gmail.com X-Spamd-Result: default: False [-2.68 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; MV_CASE(0.50)[]; TO_DN_NONE(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-0.80)[-0.804]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; R_MIXED_CHARSET(0.62)[subject]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::72a:from]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::72a:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::72a:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-hackers] Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Apr 2021 18:53:42 -0000 Hi. There are a few problems after the end of your email. I inlined them. > On Apr 16, 2021, at 8:51 PM, Johannes Totz wrote: > My init(8) is crashing with a signal 11. Crossing with the end, init is the mother of all processes. A longer explanation is in the man page you cited, even. An explanation of signal 11 can be found by googling it and also in https://www.cyberciti.biz/tips/segmentation-fault-on-linux-unix.html a text I found googling. Short story: init is well tested, so it must be hardware f= ault. > I've added a breakpoint() in kern_sig.c: >=20 > static int > issignal(struct thread *td) > { > // [snip] >=20 > case (intptr_t)SIG_DFL: > /* > * Don't take default actions on system processes. > */ > if (p->p_pid <=3D 1) { > #ifdef DIAGNOSTIC > /* > * Are you sure you want to ignore SIGSEGV > * in init? XXX > */ > printf("Process (pid %lu) got signal %d\n", > (u_long)p->p_pid, sig); >=20 > breakpoint(); // added by me > #endif > break; /* =3D=3D ignore */ > } >=20 > // [snip] > } >=20 > That breaks to DDB where I can call dump. So far so good. This also isn't the usual. Debugging a running process is possible but the process you used is the wrong one. Debugging init, OTOH, is a completely different story: init is the first process and is the most important process of any unix. The actual command varies from debugger to debugger but in gdb, "attach pid" may do the trick for you. You will need to be extra cautious because of you are aiming init. Ideally, init is the process supposed to catch the signals and keep the system running. So a break into it may cause your system to crash. > But how do I get back to the stack(trace) and instruction that caused the s= egv? Either in DDB or KGDB? "bt" is a shortcut for "backtrace" and is the command to get a stack trace in gdb. BTW, "attach" and "bt" are two of the most basic debugger commands. --=20 rollingbits =E2=80=94 =F0=9F=93=A7 rollingbits@icloud.com =F0=9F=93=A7 rolli= ngbits@gmail.com =F0=9F=93=A7 rollingbits@yahoo.com =F0=9F=93=A7 rollingbits= @terra.com.br =F0=9F=93=A7 rollingbits@globo.com=