|
From: Mahin P. <mah...@ac...> - 2022-10-19 08:56:18
|
Hi All,
I am getting below error while running Valgrind, not sure if this is bug in Valgrind, application is build using Wine lib.
Can someone check this?
---------------------
…
==2214549== Invalid write of size 8
==2214549== at 0x46C0040: setup_raise_exception (signal_x86_64.c:2158)
==2214549== by 0x46C0653: segv_handler (signal_x86_64.c:2626)
==2214549== by 0x407641F: ??? (in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so)
==2214549== Address 0x22fbd0 is in a rw- anonymous segment
…
…
==2214549== valgrind: Unrecognised instruction at address 0x46bc3d9.
==2214549== at 0x46BC3D9: __wine_syscall_dispatcher (in /usr/local/lib/wine/x86_64-unix/ntdll.so)
==2214549== by 0x170055EEF: LdrResolveDelayLoadedAPI (loader.c:3515)
==2214549== Your program just tried to execute an instruction that Valgrind
==2214549== did not recognise. There are two possible reasons for this.
==2214549== 1. Your program has a bug and erroneously jumped to a non-code
==2214549== location. If you are running Memcheck and you just saw a
==2214549== warning about a bad jump, it's probably your program's fault.
==2214549== 2. The instruction is legitimate but Valgrind doesn't handle it,
==2214549== i.e. it's Valgrind's fault. If you think this is the case or
==2214549== you are not sure, please let us know and we'll try to fix it.
==2214549== Either way, Valgrind will now raise a SIGILL signal which will
==2214549== probably kill your program.
0508:err:seh:segv_handler Got unexpected trap 0
…
--------------------------------
Source code :
> cat a.c
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main (int argc, char *argv[])
{
FILE *fin;
FILE *fout;
char wc;
fin=fopen("fin","r");
fout=fopen("out.txt","w,ccs=UTF-8");
while((wc=fgetc(fin))!=EOF){
fputc(wc,fout);
printf("%c", wc );
}
fclose(fin);
fclose(fout);
printf("\nFile has been created...%d\n", getpid());
sum(1);
return 0;
}
> cat c.c
void sum(int i)
{
return ;
}
void sum1(int i)
{
return ;
}
winegcc -g -o c.o -c c.c
winegcc -g -o a.out a.c c.o
valgrind --trace-children=yes wine64 a.out.so > temp.out 2>&1
Is there option I could use Valgrind for profiling source code? Any pointers/suggestion are welcome.
regards,
Mahin
|
|
From: John R. <jr...@bi...> - 2022-10-19 13:48:30
|
On 10/19/22 01:40, Mahin Pandya wrote: > I am getting below error while running Valgrind, not sure if this is bug in Valgrind, application is build using Wine lib. > > Can someone check this? > > --------------------- > > … > > ==2214549== Invalid write of size 8 > > ==2214549== at 0x46C0040: setup_raise_exception (signal_x86_64.c:2158) > > ==2214549== by 0x46C0653: segv_handler (signal_x86_64.c:2626) > > ==2214549== by 0x407641F: ??? (in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so) > > ==2214549== Address 0x22fbd0 is in a rw- anonymous segment [[snip]] This query is so defective that we'll just ignore it until you fix it. 1. Which version of valgrind? Report the output from "valgrind --version". Where did you get it? If self-built from source then report the git commit hash and date. If pre-built from a software distribution, then report the name and version of the distribution, and the package name and version. 2. Which version of Wine lib? Also give the URL for download of the software and installation instructions. 3. Which execution environment? Report the output from "sed 10q /proc/cpuinfo" and the VM booting banner from early lines of "dmesg". It really does matter which actual or Virtual Machine. 4. Which underlying physical hardware (Intel or AMD)? [Perhaps the same as #3.] > > Is there option I could use Valgrind for profiling source code? Any pointers/suggestion are welcome. DO NOT start a profiling project using valgrind. Instead, start with 'perf' which is vastly more capable, flexible, and fast. |
|
From: Nicholas N. <n.n...@gm...> - 2022-10-19 23:07:01
|
John: I suggest you temper your tone. Mahin is a newcomer who has asked a question in good faith, and doesn't deserve an aggressive reply. Mahin: As the error message says: "Your program has a bug and erroneously jumped to a non-codelocation. If you are running Memcheck and you just saw a warning about a bad jump, it's probably your program's fault." I suggest addressing all the errors reported by Valgrind prior to the "Unrecognised instruction" message. I also suggest checking the return value of `fopen` calls for errors. As for profiling source code, Cachegrind and Callgrind are two tools that come with Valgrind that are good for this. You can read about them in the user manual. `perf` is also a good profiling tool, as John mentioned. Finally, there is a valgrind-users email list that is more appropriate for this kind of question. This list (valgrind-developers) is more about the development of Valgrind itself, rather than its use. Nick On Thu, 20 Oct 2022 at 00:49, John Reiser <jr...@bi...> wrote: > On 10/19/22 01:40, Mahin Pandya wrote: > > I am getting below error while running Valgrind, not sure if this is bug > in Valgrind, application is build using Wine lib. > > > > Can someone check this? > > > > --------------------- > > > > … > > > > ==2214549== Invalid write of size 8 > > > > ==2214549== at 0x46C0040: setup_raise_exception (signal_x86_64.c:2158) > > > > ==2214549== by 0x46C0653: segv_handler (signal_x86_64.c:2626) > > > > ==2214549== by 0x407641F: ??? (in /usr/lib/x86_64-linux-gnu/ > libpthread-2.31.so) > > > > ==2214549== Address 0x22fbd0 is in a rw- anonymous segment > [[snip]] > > This query is so defective that we'll just ignore it until you fix it. > > 1. Which version of valgrind? Report the output from "valgrind --version". > Where did you get it? If self-built from source then report the git commit > hash and date. If pre-built from a software distribution, then report > the name and version of the distribution, and the package name and version. > > 2. Which version of Wine lib? Also give the URL for download of the > software > and installation instructions. > > 3. Which execution environment? Report the output from "sed 10q > /proc/cpuinfo" > and the VM booting banner from early lines of "dmesg". It really does > matter > which actual or Virtual Machine. > > 4. Which underlying physical hardware (Intel or AMD)? [Perhaps the same > as #3.] > > > > > Is there option I could use Valgrind for profiling source code? Any > pointers/suggestion are welcome. > > DO NOT start a profiling project using valgrind. Instead, start with > 'perf' > which is vastly more capable, flexible, and fast. > > > > _______________________________________________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers > |
|
From: Mahin P. <mah...@ac...> - 2022-11-01 10:33:23
|
Hi John, All
Here is more information of OS & Valgrind on which I am getting below error (pasting error and information in single place) while running Valgrind:
--------------------- Valgrind Error ---------
…
==2214549== Invalid write of size 8
==2214549== at 0x46C0040: setup_raise_exception (signal_x86_64.c:2158)
==2214549== by 0x46C0653: segv_handler (signal_x86_64.c:2626)
==2214549== by 0x407641F: ??? (in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so)
==2214549== Address 0x22fbd0 is in a rw- anonymous segment
…
…
==2214549== valgrind: Unrecognised instruction at address 0x46bc3d9.
==2214549== at 0x46BC3D9: __wine_syscall_dispatcher (in /usr/local/lib/wine/x86_64-unix/ntdll.so)
==2214549== by 0x170055EEF: LdrResolveDelayLoadedAPI (loader.c:3515)
==2214549== Your program just tried to execute an instruction that Valgrind
==2214549== did not recognise. There are two possible reasons for this.
==2214549== 1. Your program has a bug and erroneously jumped to a non-code
==2214549== location. If you are running Memcheck and you just saw a
==2214549== warning about a bad jump, it's probably your program's fault.
==2214549== 2. The instruction is legitimate but Valgrind doesn't handle it,
==2214549== i.e. it's Valgrind's fault. If you think this is the case or
==2214549== you are not sure, please let us know and we'll try to fix it.
==2214549== Either way, Valgrind will now raise a SIGILL signal which will
==2214549== probably kill your program.
0508:err:seh:segv_handler Got unexpected trap 0
…
-------------------------------- Source code -----------
> cat a.c
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main (int argc, char *argv[])
{
FILE *fin;
FILE *fout;
char wc;
fin=fopen("fin","r");
fout=fopen("out.txt","w,ccs=UTF-8");
while((wc=fgetc(fin))!=EOF){
fputc(wc,fout);
printf("%c", wc );
}
fclose(fin);
fclose(fout);
printf("\nFile has been created...%d\n", getpid());
sum(1);
return 0;
}
> cat c.c
void sum(int i)
{
return ;
}
void sum1(int i)
{
return ;
}
-------------- Compilation & run Command ----------------
winegcc -g -o c.o -c c.c
winegcc -g -o a.out a.c c.o
valgrind --trace-children=yes wine64 a.out.so > temp.out 2>&1
-------------------------- Valgrind & OS information -------------
1. Which version of valgrind? Report the output from "valgrind --version".
Where did you get it? If self-built from source then report the git commit hash and date. If pre-built from a software distribution, then report the name and version of the distribution, and the package name and version.
valgrind-3.15.0
valgrind/focal-updates,now 1:3.15.0-1ubuntu9.1 amd64 [installed]
OS: Ubuntu 20.04.2 LTS
2. Which version of Wine lib? Also give the URL for download of the software and installation instructions.
Here is installation instruction : https://wiki.winehq.org/Ubuntu
It's winehq-stable release.
Version: wine-7.0
3. Which execution environment? Report the output from "sed 10q /proc/cpuinfo"
and the VM booting banner from early lines of "dmesg". It really does matter which actual or Virtual Machine.
> sed 10q /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 85
model name : Intel(R) Xeon(R) Gold 6238 CPU @ 2.10GHz
stepping : 7
microcode : 0x500002c
cpu MHz : 2095.078
cache size : 30976 KB
physical id : 0
> dmesg | head -20
[ 0.000000] Linux version 5.4.0-122-generic (buildd@lcy02-amd64-095) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)) #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022 (Ubuntu 5.4.0-122.138-generic 5.4.192)
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-5.4.0-122-generic root=/dev/mapper/ubuntu--vg-lv--root ro maybe-ubiquity
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Hygon HygonGenuine
[ 0.000000] Centaur CentaurHauls
[ 0.000000] zhaoxin Shanghai
[ 0.000000] Disabled fast string operations
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x008: 'MPX bounds registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x010: 'MPX CSR'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x020: 'AVX-512 opmask'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x040: 'AVX-512 Hi256'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x080: 'AVX-512 ZMM_Hi256'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x200: 'Protection Keys User registers'
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
[ 0.000000] x86/fpu: xstate_offset[3]: 832, xstate_sizes[3]: 64
[ 0.000000] x86/fpu: xstate_offset[4]: 896, xstate_sizes[4]: 64
[ 0.000000] x86/fpu: xstate_offset[5]: 960, xstate_sizes[5]: 64
[ 0.000000] x86/fpu: xstate_offset[6]: 1024, xstate_sizes[6]: 512
[ 0.000000] x86/fpu: xstate_offset[7]: 1536, xstate_sizes[7]: 1024
[ 0.000000] x86/fpu: xstate_offset[9]: 2560, xstate_sizes[9]: 8
[ 0.000000] x86/fpu: Enabled xstate features 0x2ff, context size is 2568 bytes, using 'compacted' format.
[ 0.000000] BIOS-provided physical RAM map:
4. Which underlying physical hardware (Intel or AMD)? [Perhaps the same as #3.]
> lshw -short
H/W path Device Class Description
================================================
system VMware Virtual Platform
/0 bus 440BX Desktop Reference Platform
/0/0 memory 86KiB BIOS
/0/1 processor Intel(R) Xeon(R) Gold 6238 CPU @ 2.10GHz
/0/1/0 memory 16KiB L1 cache
/0/1/1 memory 16KiB L1 cache
/0/2 processor Intel(R) Xeon(R) Gold 6238 CPU @ 2.10GHz
/0/28 memory 16GiB System Memory
/0/28/0 memory 16GiB DIMM DRAM EDO
/0/28/1 memory DIMM DRAM [empty]
We tried using perf but it is not generating line wise source code profiling eg. time taken by each function calls etc. If any you have some good documentation on perf which can help please suggest.
Is there option I could use Valgrind for profiling source code? Any pointers/suggestion are welcome.
regards,
Mahin
-----Original Message-----
From: John Reiser <jr...@bi...>
Sent: Wednesday, October 19, 2022 3:48 PM
To: val...@li...
Subject: Re: [Valgrind-developers] valgrind: Unrecognised instruction error
On 10/19/22 01:40, Mahin Pandya wrote:
> I am getting below error while running Valgrind, not sure if this is bug in Valgrind, application is build using Wine lib.
>
> Can someone check this?
>
> ---------------------
>
> …
>
> ==2214549== Invalid write of size 8
>
> ==2214549== at 0x46C0040: setup_raise_exception
> (signal_x86_64.c:2158)
>
> ==2214549== by 0x46C0653: segv_handler (signal_x86_64.c:2626)
>
> ==2214549== by 0x407641F: ??? (in
> /usr/lib/x86_64-linux-gnu/libpthread-2.31.so)
>
> ==2214549== Address 0x22fbd0 is in a rw- anonymous segment
[[snip]]
This query is so defective that we'll just ignore it until you fix it.
1. Which version of valgrind? Report the output from "valgrind --version".
Where did you get it? If self-built from source then report the git commit hash and date. If pre-built from a software distribution, then report the name and version of the distribution, and the package name and version.
valgrind-3.15.0
valgrind/focal-updates,now 1:3.15.0-1ubuntu9.1 amd64 [installed]
OS: Ubuntu 20.04.2 LTS
2. Which version of Wine lib? Also give the URL for download of the software and installation instructions.
Here is installation instruction : https://wiki.winehq.org/Ubuntu
It's winehq-stable release.
Version: wine-7.0
3. Which execution environment? Report the output from "sed 10q /proc/cpuinfo"
and the VM booting banner from early lines of "dmesg". It really does matter which actual or Virtual Machine.
> sed 10q /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 85
model name : Intel(R) Xeon(R) Gold 6238 CPU @ 2.10GHz
stepping : 7
microcode : 0x500002c
cpu MHz : 2095.078
cache size : 30976 KB
physical id : 0
> dmesg | head -20
[ 0.000000] Linux version 5.4.0-122-generic (buildd@lcy02-amd64-095) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)) #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022 (Ubuntu 5.4.0-122.138-generic 5.4.192)
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-5.4.0-122-generic root=/dev/mapper/ubuntu--vg-lv--root ro maybe-ubiquity
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Hygon HygonGenuine
[ 0.000000] Centaur CentaurHauls
[ 0.000000] zhaoxin Shanghai
[ 0.000000] Disabled fast string operations
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x008: 'MPX bounds registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x010: 'MPX CSR'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x020: 'AVX-512 opmask'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x040: 'AVX-512 Hi256'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x080: 'AVX-512 ZMM_Hi256'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x200: 'Protection Keys User registers'
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
[ 0.000000] x86/fpu: xstate_offset[3]: 832, xstate_sizes[3]: 64
[ 0.000000] x86/fpu: xstate_offset[4]: 896, xstate_sizes[4]: 64
[ 0.000000] x86/fpu: xstate_offset[5]: 960, xstate_sizes[5]: 64
[ 0.000000] x86/fpu: xstate_offset[6]: 1024, xstate_sizes[6]: 512
[ 0.000000] x86/fpu: xstate_offset[7]: 1536, xstate_sizes[7]: 1024
[ 0.000000] x86/fpu: xstate_offset[9]: 2560, xstate_sizes[9]: 8
[ 0.000000] x86/fpu: Enabled xstate features 0x2ff, context size is 2568 bytes, using 'compacted' format.
[ 0.000000] BIOS-provided physical RAM map:
4. Which underlying physical hardware (Intel or AMD)? [Perhaps the same as #3.]
> lshw -short
H/W path Device Class Description
================================================
system VMware Virtual Platform
/0 bus 440BX Desktop Reference Platform
/0/0 memory 86KiB BIOS
/0/1 processor Intel(R) Xeon(R) Gold 6238 CPU @ 2.10GHz
/0/1/0 memory 16KiB L1 cache
/0/1/1 memory 16KiB L1 cache
/0/2 processor Intel(R) Xeon(R) Gold 6238 CPU @ 2.10GHz
/0/28 memory 16GiB System Memory
/0/28/0 memory 16GiB DIMM DRAM EDO
/0/28/1 memory DIMM DRAM [empty]
>
> Is there option I could use Valgrind for profiling source code? Any pointers/suggestion are welcome.
DO NOT start a profiling project using valgrind. Instead, start with 'perf'
which is vastly more capable, flexible, and fast.
_______________________________________________
Valgrind-developers mailing list
Val...@li...
https://lists.sourceforge.net/lists/listinfo/valgrind-developers
|
|
From: John R. <jr...@bi...> - 2022-11-15 03:33:25
|
On 11/1/22 03:31, Mahin Pandya wrote: > ==2214549== valgrind: Unrecognised instruction at address 0x46bc3d9. > ==2214549== at 0x46BC3D9: __wine_syscall_dispatcher (in /usr/local/lib/wine/x86_64-unix/ntdll.so) > ==2214549== by 0x170055EEF: LdrResolveDelayLoadedAPI (loader.c:3515) > ==2214549== Your program just tried to execute an instruction that Valgrind > ==2214549== did not recognise. There are two possible reasons for this. A bug has been entered as https://bugs.kde.org/show_bug.cgi?id=461855 "(wine xsavec64) vex amd64->IR: unhandled instruction bytes: 0x48 0xF 0xC7 0xA1 0xC0 0x0 0x0 0x0 0x48 0xF" This might not be the actual problem that Mahin reported (Mahin's report does not include the instruction stream bytes), but Wine definitely does execute unhandled 'xsavec64', so this is a place to start fixing. |
|
From: John R. <jr...@bi...> - 2022-11-15 18:22:32
|
>> ==2214549== valgrind: Unrecognised instruction at address 0x46bc3d9. >> ==2214549== at 0x46BC3D9: __wine_syscall_dispatcher (in /usr/local/lib/wine/x86_64-unix/ntdll.so) > A bug has been entered as https://bugs.kde.org/show_bug.cgi?id=461855 > "(wine xsavec64) vex amd64->IR: unhandled instruction bytes: 0x48 0xF 0xC7 0xA1 0xC0 0x0 0x0 0x0 0x48 0xF" Probably the bug should be closed as Invalid; see Comment https://bugs.kde.org/show_bug.cgi?id=461855#c2 The Original Poster is using an ancient version (6 years old) of valgrind that does not print the unrecognized instruction bytes. The program being analyzed is really wine64, not a.out.so, and debug symbols for wine64 are not available. Wine64 requires an "installation" of Microsoft Windows. Altogether a very disappointing episode. |