[DTrace-devel] [PATCH 17/20] speculations, bpf: check for nonexistent CTF before using it

Kris Van Hees kris.van.hees at oracle.com
Tue Jul 19 15:01:25 UTC 2022


I am including this patch in the one I have been working on to support
-xctfpath since that one provides a test that demonstrates this issue (or
the fact that it is resolved).

Thanks!

On Wed, May 11, 2022 at 10:12:59PM +0100, Nick Alcock via DTrace-devel wrote:
> This turns coredumps into a not-all-that-much-more-helpful "no such file
> or directory" error (but turning DT_DEBUG on at least tells you which
> file is missing, i.e. some ctfa file)
> 
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
> ---
>  libdtrace/dt_cc.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
> index c6c31fc92712..9a61134057a0 100644
> --- a/libdtrace/dt_cc.c
> +++ b/libdtrace/dt_cc.c
> @@ -2378,10 +2378,14 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
>  			case DT_CONST_TASK_REAL_PARENT:
>  			case DT_CONST_TASK_COMM: {
>  				ctf_file_t *cfp = dtp->dt_shared_ctf;
> -				ctf_id_t type = ctf_lookup_by_name(cfp, "struct task_struct");
> +				ctf_id_t type;
>  				ctf_membinfo_t ctm;
>  				int rc = 0;
>  
> +				if (!cfp)
> +					return dt_set_errno(dtp, EDT_NOCTF);
> +
> +				type = ctf_lookup_by_name(cfp, "struct task_struct");
>  				if (type == CTF_ERR)
>  					goto err_ctf;
>  
> @@ -2406,10 +2410,14 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
>  			}
>  			case DT_CONST_MUTEX_OWNER: {
>  				ctf_file_t *cfp = dtp->dt_shared_ctf;
> -				ctf_id_t type = ctf_lookup_by_name(cfp, "struct mutex");
> +				ctf_id_t type;
>  				ctf_membinfo_t ctm;
>  				ctf_id_t rc = CTF_ERR;
>  
> +				if (!cfp)
> +					return dt_set_errno(dtp, EDT_NOCTF);
> +
> +				type = ctf_lookup_by_name(cfp, "struct mutex");
>  				if (type == CTF_ERR)
>  					goto err_ctf;
>  
> @@ -2436,6 +2444,9 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
>  				ctf_id_t rc = CTF_ERR;
>  				uint64_t total_offset;
>  
> +				if (!cfp)
> +					return dt_set_errno(dtp, EDT_NOCTF);
> +
>  				type = ctf_lookup_by_name(cfp, "rwlock_t");
>  				if (type == CTF_ERR)
>  					goto err_ctf;
> -- 
> 2.36.1.263.g194b774378.dirty
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list