Back to evms-1.0.1 && unaligne access && gdb
Hi all,
I need to go back to kernel 2.4.18-pa61 and evms-1.0.1 (see problem in ml:
http://lists.parisc-linux.org/pipermail/parisc-linux/2002-August/017368.html
with last 1.1.0 evsm release)
Kernel build and operate correctly. I so recompile tools with -ggdb gcc option.
Then I use ddd to try to debug problem.
So I first run without break and got from console:evms_vgscan(7998): unaligned access to 0x0002aaae at ip=0x4020a0e3
So I put a break early in main (Ok), relaunch run and try now to insert a breack in gdb window:
b *0x4020a0e3
Accepted but when 'continue' is launch:
warning: Cannot insert breakpoint 2:
Cannot access memory at address 0x4020a0e3
What do I wrong or what should I better do?
Thanks in advance for help,
Joel
Hey,
I am lucky.
A ^C during a run and I got:
^C
Program received signal SIGINT, Interrupt.0x4020a0e4 in isa_null_partition_record (p=0x3fe0ff) at checks.c:65 /usr/src/EVMS/evms-1.0.1/engine/Plugins/defsegmgr/checks.c:65:1603:beg:0x4020a0e4
where I find:
60 BOOLEAN isa_null_partition_record(struct partition *p)
61 {
62 int i;
63 u_int32_t *uip = (u_int32_t *) p;
64
65 for (i=0; i<4; i++) {
66 if (*uip!=0x00) return FALSE;
67 }
68
69 return TRUE;
70 }So am I right to suspect "u_int32_t *uip = (u_int32_t *) p;" being the
actual cause of 'unaligned access' problem?
Thanks in advance for additionnal comments,
Joel
Quoted 38 lines
-- Original Message --
From: [email protected]
To: [email protected]
Subject: [parisc-linux] Back to evms-1.0.1 && unaligne access && gdb
Date: Thu, 29 Aug 2002 11:22:45 +0200Hi all,
I need to go back to kernel 2.4.18-pa61 and evms-1.0.1 (see problem in ml:
http://lists.parisc-linux.org/pipermail/parisc-linux/2002-August/017368.html
with last 1.1.0 evsm release)Kernel build and operate correctly. I so recompile tools with -ggdb gcc option.
Then I use ddd to try to debug problem.So I first run without break and got from console:
evms_vgscan(7998): unaligned access to0x0002aaaeat ip=0x4020a0e3So I put a break early in main (Ok), relaunch run and try now to insert a breack in gdb window:
b *0x4020a0e3Accepted but when 'continue' is launch:
warning: Cannot insert breakpoint 2:
Cannot access memory at address0x4020a0e3What do I wrong or what should I better do?
Thanks in advance for help,
Joel_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Joel,
Quoted 3 lines
I need to go back to kernel 2.4.18-pa61 and evms-1.0.1 (see problem in ml:
http://lists.parisc-linux.org/pipermail/parisc-linux/2002-August/017368.html
with last 1.1.0 evsm release)
Why do you need to regress versions?
Quoted 2 lines
Kernel build and operate correctly. I so recompile tools with -ggdb gcc option. Then I use ddd to try to debug problem.
What did you recompile with "-g"?
Quoted 2 lines
So I first run without break and got from console:
evms_vgscan(7998): unaligned access to0x0002aaaeat ip=0x4020a0e3
The unaligned handler took care of it, everything should still be okay.
Quoted 4 lines
Accepted but when 'continue' is launch:
warning: Cannot insert breakpoint 2:
Cannot access memory at address0x4020a0e3
What do I wrong or what should I better do?
AFAIK we are using software breakpoints in gdb, which means that at certain times we _can't_ insert a breakpoint.
I'm still unclear about the issues here. What's wrong with evms? It dies from a SIGBUS (unaligned handler failed)? SIGSEGV? Operates incorrectly?
c.
Quoted 9 lines
So I put a break early in main (Ok), relaunch run and try now to insert a breack in gdb window:
b *0x4020a0e3Accepted but when 'continue' is launch:
warning: Cannot insert breakpoint 2:
Cannot access memory at address0x4020a0e3What do I wrong or what should I better do?
Nothing. You tried to set a break in a share library that hasn't been loaded. I don't have a great solution but the following should work. Export LD_BIND_NOW so that ld.so binds symbols at program startup. Then, put a break on main and start the program. You should then be able to set a break in a shared library or enable it if the above error occurred. For example, when you hit the break at main,
enable 2
should insert the above.
Dave
Signature · 2 lines
J. David Anglin [email protected] National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
Quoted 2 lines
So am I right to suspect "
u_int32_t*uip = (u_int32_t*) p;" being the
actual cause of 'unaligned access' problem?
Yes, if p is not aligned, a trap will occur.
Dave
Signature · 2 lines
J. David Anglin [email protected] National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
Well it does not seems to be the right place of the problem :(
I try to reproduce with the following simple C example:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
typedef u_int8_t BOOLEAN;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
struct partition {
unsigned char boot_ind; /* 0x80 - active */
unsigned char head; /* starting head */
unsigned char sector; /* starting sector */
unsigned char cyl; /* starting cylinder */
unsigned char sys_ind; /* What partition type */
unsigned char end_head; /* end head */
unsigned char end_sector; /* end sector */
unsigned char end_cyl; /* end cylinder */
unsigned int start_sect; /* starting sector counting from 0 */
unsigned int nr_sects; /* nr of sectors in partition */
};
BOOLEAN isa_null_partition_record(struct partition *p)
{
int i;
u_int32_t *uip = (u_int32_t *) p;
for (i=0; i<4; i++) {
if (*uip!=0x00) return FALSE;
}
return TRUE;
}int main(int argc, char * * argv, char * * env) {
struct partition p1, p2;
p1.boot_ind=0;
p1.head=0;
p1.sector=0;
p1.cyl=0;
p1.sys_ind=0;
p1.end_head=0;
p1.end_sector=0;
p1.end_cyl=0;
p1.start_sect=0;
p1.nr_sects=0;
printf("Is that p1 is a null partition: %u\n", isa_null_partition_record(&p1));
p2.boot_ind=1;
p2.head=2;
p2.sector=3;
p2.cyl=4;
p2.sys_ind=5;
p2.end_head=6;
p2.end_sector=7;
p2.end_cyl=8;
p2.start_sect=9;
p2.nr_sects=10;
printf("Is that p2 is a null partition: %u\n", isa_null_partition_record(&p2));
return 0;
}and compile with same gcc option (i.e. gcc -ggdb -O2 -Wall -fPIC ) and the problem is not reproduced?
Any idea?
Thanks in advance for additional advise,
Joel
Quoted 30 lines
-- Original Message --
From: [email protected]
Subject: RE: [parisc-linux] Back to evms-1.0.1 && unaligne access && gdb
To: [email protected]
Date: Thu, 29 Aug 2002 11:51:36 +0200Hey,
I am lucky.
A ^C during a run and I got:
^C
Program received signal SIGINT, Interrupt.0x4020a0e4inisa_null_partition_record(p=0x3fe0ff) at checks.c:65 /usr/src/EVMS/evms-1.0.1/engine/Plugins/defsegmgr/checks.c:65:1603:beg:0x4020a0e4where I find:
60 BOOLEAN isa_null_partition_record(struct partition *p) 61 { 62 int i; 63 u_int32_t *uip = (u_int32_t *) p; 64 65 for (i=0; i<4; i++) { 66 if (*uip!=0x00) return FALSE; 67 } 68 69 return TRUE; 70 }
Quoted 16 lines
So am I right to suspect "
u_int32_t*uip = (u_int32_t*) p;" being the
actual cause of 'unaligned access' problem?Thanks in advance for additionnal comments,
JoelQuoted 10 lines
-- Original Message --
From: [email protected]
To: [email protected]
Subject: [parisc-linux] Back to evms-1.0.1 && unaligne access && gdb
Date: Thu, 29 Aug 2002 11:22:45 +0200Hi all,
I need to go back to kernel 2.4.18-pa61 and evms-1.0.1 (see problem in
ml:
Quoted 33 lines
Quoted 20 lines
http://lists.parisc-linux.org/pipermail/parisc-linux/2002-August/017368.html
with last 1.1.0 evsm release)Kernel build and operate correctly. I so recompile tools with -ggdb gcc option.
Then I use ddd to try to debug problem.So I first run without break and got from console:
evms_vgscan(7998): unaligned access to0x0002aaaeat ip=0x4020a0e3So I put a break early in main (Ok), relaunch run and try now to insert a breack in gdb window:
b *0x4020a0e3Accepted but when 'continue' is launch:
warning: Cannot insert breakpoint 2:
Cannot access memory at address0x4020a0e3What do I wrong or what should I better do?
Quoted 8 lines
Thanks in advance for help,
Joel_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 2 lines
Quoted 2 lines
Program received signal SIGINT, Interrupt.
0x4020a0e4inisa_null_partition_record(p=0x3fe0ff) at checks.c:65
You can see from the value of p above that it is not properly aligned for a 4 byte access. Put a break on isa_null_partition_record and
cond n p==0x3fe0ff
where n is the breakpoint number of the break at isa_null_partition_record. Then, run the program and it should stop at isa_null_partition_record when the fault is about to occur. You will then have to do a bt to determine why p is incorrectly aligned (last hex digit should be 0, 4, 8 or c).
Dave
Signature · 2 lines
J. David Anglin [email protected] National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
Quoted 11 lines
-- Original Message --
Subject: Re: [parisc-linux] Back to evms-1.0.1 && unaligne access && gdb
To: [email protected]
From: "John David Anglin" <[email protected]>
Cc: [email protected]
Date: Thu, 29 Aug 2002 10:28:48 -0400 (EDT)Quoted 2 lines
Quoted 2 lines
Program received signal SIGINT, Interrupt.
0x4020a0e4inisa_null_partition_record(p=0x3fe0ff) at checks.c:65
Quoted 6 lines
You can see from the value of p above that it is not properly aligned for a 4 byte access. Put a break on
isa_null_partition_recordandcond n p==0x3fe0ff
where n is the breakpoint number of the break at
isa_null_partition_record.
As previously, I could not put a break at isa_null_partition_record (function not define but with ^C I reach to stop recursively in this function and so for example with p==0x26ece I got p.boot_ind=0 ; p.head=63 ; p.sector=224 ; p.cyl=255; ...
p is of type partition define as follow:
struct partition {
unsigned char boot_ind; /* 0x80 - active */
unsigned char head; /* starting head */
unsigned char sector; /* starting sector */
unsigned char cyl; /* starting cylinder */
unsigned char sys_ind; /* What partition type */
unsigned char end_head; /* end head */
unsigned char end_sector; /* end sector */
unsigned char end_cyl; /* end cylinder */
unsigned int start_sect; /* starting sector counting from 0 */
unsigned int nr_sects; /* nr of sectors in partition */
};
So anyway there is a bug because I presume that the for loop is there to scan the 4 int what it doen't do (?) and find another way to say an 'int' is null ( hmm why not simplyu_int8_t *uip = (u_int8_t *)p;
for (i=0 ; i<16 ; i++){
if (*uip+i != 0x00) return FALSE;
}return TRUE;
what do you think?
Quoted 4 lines
Then, run the program and it should stop at
isa_null_partition_recordwhen the fault is about to occur. You will then have to do a bt to determine why p is incorrectly aligned (last hex digit should be 0, 4, 8 or c).
Many thanks,
Joel
Quoted 5 lines
p is of type partition define as follow:
struct partition {
unsigned charboot_ind; /*0x80- active */
unsigned char head; /* starting head */
unsigned char sector; /* starting sector */
Quoted 8 lines
unsigned char cyl; /* starting cylinder */
unsigned charsys_ind; /* What partition type */
unsigned charend_head; /* end head */
unsigned charend_sector; /* end sector */
unsigned charend_cyl; /* end cylinder */
unsigned intstart_sect; /* starting sector counting from 0 */
unsigned intnr_sects; /* nr of sectors in partition */
};
The problem is that a struct of the above type is being allocated at an unaligned address. That's not normal. The cast isn't the problem.
Dave
Signature · 2 lines
J. David Anglin [email protected] National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
Quoted 10 lines
So anyway there is a bug because I presume that the for loop is there to scan the 4 int what it doen't do (?) and find another way to say an 'int' is null ( hmm why not simply
u_int8_t*uip = (u_int8_t*)p;for (i=0 ; i<16 ; i++){ if (*uip+i != 0x00) return FALSE; }return TRUE;
Quick test and yes that works (reduce response time 1/10).
Anyway all better idea is well come :)
Thanks a lot,
Joel
Quoted 6 lines · [email protected] wrote:
Quoted 5 lines
for (i=0 ; i<16 ; i++){ if (*uip+i != 0x00) return FALSE; }return TRUE;
Quick test and yes that works (reduce response time 1/10).
You've avoided the first visible symptom but not solved the problem. The next reference to the int embedded in the struct will cause an unaligned access fault.
grant
Quoted 22 lines
-- Original Message --
Subject: Re: [parisc-linux] Back to evms-1.0.1 && unaligne access && gdb
To: [email protected]
From: "John David Anglin" <[email protected]>
Cc: [email protected]
Date: Thu, 29 Aug 2002 13:10:49 -0400 (EDT)Quoted 5 lines
p is of type partition define as follow:
struct partition {
unsigned charboot_ind; /*0x80- active */
unsigned char head; /* starting head */
unsigned char sector; /* starting sector */Quoted 8 lines
unsigned char cyl; /* starting cylinder */
unsigned charsys_ind; /* What partition type */
unsigned charend_head; /* end head */
unsigned charend_sector; /* end sector */
unsigned charend_cyl; /* end cylinder */
unsigned intstart_sect; /* starting sector counting from 0 */
unsigned intnr_sects; /* nr of sectors in partition */
};
Quoted 2 lines
The problem is that a struct of the above type is being allocated at an unaligned address.
Sorry I do not understand, can you tell me more or where can I found additional
explanation?
Quoted 3 lines
That's not normal. The cast isn't the
problem.
Thanks in advance,
Joel
Quoted 16 lines
-- Original Message --
To: [email protected]
Cc: "John David Anglin" <[email protected]>,
[email protected]
Subject: Re: [parisc-linux] Back to evms-1.0.1 && unaligne access && gdbDate: Thu, 29 Aug 2002 12:11:48 -0600
From: Grant Grundler <[email protected]>Quoted 5 lines · [email protected] wrote:
Quoted 5 lines
for (i=0 ; i<16 ; i++){ if (*uip+i != 0x00) return FALSE; }return TRUE;
Quoted 6 lines
Quoted 1 line
Quick test and yes that works (reduce response time 1/10).
You've avoided the first visible symptom but not solved the problem. The next reference to the int embedded in the struct will cause an unaligned access fault.
Ah ok but where is located the actual problem (gcc, ld, kernel ?). I am not a computer science engineer and have not enough knowledge to understand this problem of unalign access and unalign adress. Can you give me some source of information explaining that stuff?
Thanks for adivises,
Joel
Quoted 1 line · [email protected] wrote:
Ah ok but where is located the actual problem (gcc, ld, kernel ?).
the program.
Quoted 3 lines
I am not a computer science engineer and have not enough knowledge to understand this problem of unalign access and unalign adress. Can you give me some source of information explaining that stuff?
Details for parisc:
"PA-RISC 2.0 Architecture" by Jerry Kane. page 5-11, "Unaligned Data Reference Trap (28)" page 7-84, "Load Word"
heh...doesn't define "aligned address" in the Glossary. The same stuff is in the PA 1.1 Arch books too.
"aligned" means the address of the data falls on a boundary that is modulo the size of the data. It's more complicated for a "struct" but the rule applies to any field in a struct.
Examples:
0x10 is an aligned address for an "int" 0x12 is an aligned address for a "short" but not an "int".
Got it?
BTW, even though x86 CPUs don't trap on unaligned access, they do take a performance hit. IIRC, it's one additional cycle. Under linux, most (all?) RISC CPUs trap and handle the unaligned access in the kernel trap handler. Other OS's could SIGBUS the application to kill it.
Hmm...this is interesting:
/usr/include/linux/prctl.h:# define PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user access */
Maybe you can figure out how to set this and dig through the core file instead of trying to set break points.
grant
Quoted 35 lines
-- Original Message --
To: [email protected]
Cc: "John David Anglin" <[email protected]>,
[email protected]
Subject: Re: [parisc-linux] Back to evms-1.0.1 && unaligne access && gdbDate: Fri, 30 Aug 2002 00:30:51 -0600
From: Grant Grundler <[email protected]>Quoted 1 line · [email protected] wrote:
Ah ok but where is located the actual problem (gcc, ld, kernel ?).
the program.
Quoted 3 lines
I am not a computer science engineer and have not enough knowledge to understand this problem of unalign access and unalign adress. Can you give me some source of information explaining that stuff?
Details for parisc:
"PA-RISC 2.0 Architecture" by Jerry Kane. page 5-11, "Unaligned Data Reference Trap (28)" page 7-84, "Load Word"heh...doesn't define "aligned address" in the Glossary. The same stuff is in the PA 1.1 Arch books too.
"aligned" means the address of the data falls on a boundary that is modulo the size of the data. It's more complicated for a "struct" but the rule applies to any field in a struct.
Examples:
0x10 is an aligned address for an "int" 0x12 is an aligned address for a "short" but not an "int".
Quoted 8 lines
Got it?
BTW, even though x86 CPUs don't trap on unaligned access, they do take a performance hit. IIRC, it's one additional cycle. Under linux, most (all?) RISC CPUs trap and handle the unaligned access in the kernel trap handler. Other OS's could SIGBUS the application to kill it.
Thanks a lot for all info
Quoted 7 lines
Hmm...this is interesting:
/usr/include/linux/prctl.h:# definePR_UNALIGN_SIGBUS2 /* generate
SIGBUS on unaligned user access */Maybe you can figure out how to set this and dig through the core file instead of trying to set break points.
Not sure I will reach but i will have look anyway.
Many thanks again,
Joel
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
p is of type partition define as follow:
struct partition {
unsigned charboot_ind; /*0x80- active */
unsigned char head; /* starting head */
unsigned char sector; /* starting sector */
unsigned char cyl; /* starting cylinder */
unsigned charsys_ind; /* What partition type */
unsigned charend_head; /* end head */
unsigned charend_sector; /* end sector */
unsigned charend_cyl; /* end cylinder */
unsigned intstart_sect; /* starting sector counting from 0 */
unsigned intnr_sects; /* nr of sectors in partition */
};
Quoted 4 lines
Quoted 2 lines
The problem is that a struct of the above type is being allocated at an unaligned address.
Sorry I do not understand, can you tell me more or where can I found additional
You may be able to find a copy of WG14/N869 (Committee Draft -- January 18, 1999) on the web. It is a draft version of the ISO C standard. Section 6.7.2.1 describes struct and union types.
In general, the C standard doesn't define the representation used for objects. However, the alignment requirement of field members (except bit fields) is the same as its type when not in a struct or union. The PA implementation uses a strict "natural" alignment for types. E.g., 4 byte integers are aligned to 4 byte boundaries. Multiple instructions are needed for unaligned data access on the PA.
A pointer to a struct points to the initial member (ie., there is no padding before the first member).
The above struct starts with an unsigned char type so as far as the standard goes it could start at any byte. Note that it contains int types, so that if it didn't start on a 4 byte boundary, there would have to be padding after the last char field. If the struct was given "char" alignment, then different code would be needed to access members when it was and wasn't aligned to a 4 byte boundary. To minimize problems of this nature, gcc aligns structs based on the largest alignment requirement of all its members.
The code generated by gcc will not properly access fields of a struct that isn't properly aligned. Thus, you will need to try and find out why in this particular case the struct isn't aligned and correct the problem. It might be a malloc problem or data read into an arbitrary location.
Because the initial field of the struct is an unsigned char type, the cast to uint32_t is wrong. The code is making implementation dependent assumptions.
Dave
Signature · 2 lines
J. David Anglin [email protected] National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
Quoted 5 lines
Because the initial field of the struct is an unsigned char type, the cast to
uint32_tis wrong. The code is making implementation dependent assumptions.
Finaly this trial version of function:
BOOLEAN isa_null_partition_record(struct partition *p)
{
if (p->boot_ind == 0x00 &&
p->head == 0x00 &&
p->sector == 0x00 &&
p->cyl == 0x00 &&
p->sys_ind == 0x00 &&
p->end_head == 0x00 &&
p->end_sector == 0x00 &&
p->end_cyl == 0x00 &&
p->start_sect == 0x00 &&
p->nr_sects == 0x00 )
return TRUE;
else
return FALSE;
}would be more portable and more easy to read and understand :<)
Thanks again for your help,
Joel
Quoted 4 lines · Joel Soete
Finaly this trial version of function:
BOOLEAN
isa_null_partition_record(struct partition *p)
Quoted 12 lines
{
if (p->boot_ind == 0x00 &&
p->head == 0x00 &&
p->sector == 0x00 &&
p->cyl == 0x00 &&
p->sys_ind == 0x00 &&
p->end_head == 0x00 &&
p->end_sector == 0x00 &&
p->end_cyl == 0x00 &&
p->start_sect == 0x00 &&
p->nr_sects == 0x00 )
return TRUE;Since start_sect and nr_sects are ints, this code will also generate an "unaligned data reference fault" like the original code did. You need to find the origin of "struct partition *p" when the address is un-aligned.
grant