[LU-8819] lprocfs_alloc_stats() Segmentation fault (core dumped) Created: 10/Nov/16 Updated: 14/Mar/17 |
|
| Status: | Open |
| Project: | Lustre |
| Component/s: | None |
| Affects Version/s: | Lustre 2.8.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | ShijunDeng | Assignee: | Lai Siyao |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | lprocfs | ||
| Environment: |
lustre 2.8.0 centos7 kernel-3.10.0_3.10.0_327.3.1.el7_lustre.x86_64-1.x86_64 |
||
| Attachments: |
|
| Epic/Theme: | Lustre-2.8.0 |
| Severity: | 4 |
| Epic: | interoperability |
| Project: | Test Infrastructure |
| Rank (Obsolete): | 9223372036854775807 |
| Description |
|
In lustre/obdclass/lprocfs_status.c ,and in the function "lprocfs_alloc_stats", |
| Comments |
| Comment by Peter Jones [ 10/Nov/16 ] |
|
Lai Could you please advise on this issue? Thanks Peter |
| Comment by John Hammond [ 10/Nov/16 ] |
|
lprocfs_stats_counter_get() is only used after successful calls to lprocfs_stats_lock() or checks that stats->ls_percpu[i] is not NULL. |
| Comment by ShijunDeng [ 11/Nov/16 ] |
|
struct lprocfs_counter {
struct lprocfs_percpu { struct lprocfs_stats {
/* has ls_num of counter headers */ the above code is corresponding definition,In lustre/obdclass/lprocfs_status.c ,and in the function "lprocfs_alloc_stats", the access to stats->ls_percpu[i] is safe,but it's not safe to acccess lp_cntr[index],to simplify the analysis for the problem,I will justify my position by giving one example as follow: #include<stdio.h> int main(){ struct en e; the small demo can run correctly,sometimes.but it's not safe.For the same reson, |
| Comment by Lai Siyao [ 14/Nov/16 ] |
|
Did you really meet segfault? If so, can you post logs or backtraces? I verified the code LIBCFS_ALLOC(stats, offsetof(typeof(*stats), ls_percpu[num_entry])); does allocate percpu data, and can be accessed successfully. While your example code is different from above code, if you change to below: #include<stdio.h>
struct en
{ int a; int b; int c[0]; }
;
int main()
{
struct en *e = malloc(offset(struct en, c[1001]);
e->c[0]=1000;
e->c[1]=2000;
e->c[2]=3000;
e->c[1000]=3000;
printf("e.c[0]=%d\n",e->c[0]);
printf("e.c[1]=%d\n",e->c[1]);
printf("e.c[2]=%d\n",e->c[2]);
printf("e.c[1000]=%d\n",e->c[1000]);
return 0;
}
It should always work, could you take a try? |
| Comment by Gerrit Updater [ 04/Dec/16 ] |
|
please ignore. |