OpenCores
Issue List
Segmentation Fault #29
Closed marcelo.guedes opened this issue over 12 years ago
marcelo.guedes commented over 12 years ago

I followed instructions in this website but I received segmentation fault when tried to execute any example software in mlite. It's strange because I didn't modify anything I followed the steps strictly. I'm running an Ubuntu 11.10 linux distro.

I successfully built a mips-elf-gcc, went to path plasma/trunk/tools and executed:

$ make all $ make count $ make run

The return for each command was:

$ make all convert.c: In function ‘main’: convert.c:98:26: warning: variable ‘bss_end’ set but not used -Wunused-but-set-variable convert.c:96:9: warning: variable ‘size’ set but not used -Wunused-but-set-variable tracehex.c: In function ‘main’: tracehex.c:21:22: warning: variable ‘source_start’ set but not used -Wunused-but-set-variable tracehex.c:21:10: warning: variable ‘line_start’ set but not used -Wunused-but-set-variable ram_image.c: In function ‘main’: ram_image.c:69:13: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result -Wunused-result make targets = count, opcodes, pi, test, run, tohex,bootldr, toimage, eterm

$ make count mips-elf-as -o boot.o boot.asm mips-elf-gcc -O2 -Wall -c -s count.c mips-elf-gcc -O2 -Wall -c -s no_os.c mips-elf-ld -Ttext 0 -eentry -Map test.map -s -N -o test.axf \ boot.o count.o no_os.o mips-elf-objdump --disassemble test.axf > test.lst ./convert_bin.exe test.axf -> code.txt & test.bin Entry=0x0 length=2452=0x994 cp code.txt ../vhdl

$ make run mlite.c: In function ‘mem_read’: mlite.c:182:10: warning: cast from pointer to integer of different size -Wpointer-to-int-cast mlite.c:193:19: warning: cast to pointer from integer of different size -Wint-to-pointer-cast mlite.c:199:19: warning: cast to pointer from integer of different size -Wint-to-pointer-cast mlite.c:204:19: warning: cast to pointer from integer of different size -Wint-to-pointer-cast mlite.c: In function ‘mem_write’: mlite.c:239:13: warning: cast from pointer to integer of different size -Wpointer-to-int-cast mlite.c:240:8: warning: cast to pointer from integer of different size -Wint-to-pointer-cast mlite.c:245:10: warning: cast from pointer to integer of different size -Wpointer-to-int-cast mlite.c:256:11: warning: cast to pointer from integer of different size -Wint-to-pointer-cast mlite.c:262:11: warning: cast to pointer from integer of different size -Wint-to-pointer-cast mlite.c:265:11: warning: cast to pointer from integer of different size -Wint-to-pointer-cast mlite.c: In function ‘do_debug’: mlite.c:868:15: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result -Wunused-result mlite.c:875:15: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result -Wunused-result mlite.c:902:15: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result -Wunused-result mlite.c:911:15: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result -Wunused-result mlite.c:915:15: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result -Wunused-result Plasma emulator Read 2452 bytes. make: *** run Segmentation fault

Using gdb I received this report:


"GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: http://bugs.launchpad.net/gdb-linaro/... Reading symbols from plasma/plasma/trunk/tools/mlite.exe...done. (gdb) run test.bin Starting program: plasma/plasma/trunk/tools/mlite.exe test.bin Plasma emulator Read 2452 bytes.

Program received signal SIGSEGV, Segmentation fault. 0x00000000004010f3 in mem_read (s=0x7fffffffdfe0, size=4, address=0) at mlite.c:193 193 value = (int)ptr;


Any help?

rhoads was assigned over 12 years ago
rhoads commented over 12 years ago

Thank you for reporting this bug. The code incorrectly assumed that a pointer could fit in a 32 bit integer. I checked in a couple of changes:

--OLD unsigned int ptr; --OLD ptr = (unsigned int)s->mem + (address % MEM_SIZE); unsigned char *ptr; ptr = s->mem + (address % MEM_SIZE);

Please let me know if this fixes the problem.

Steve

colorete87 commented over 12 years ago

I had the same problem. I made other changes to the code that solved the problem, but your solution is better, and solves the problem at least for me!

Thanks

Federico

rhoads closed this over 12 years ago

Assignee
rhoads
Labels
Bug