SOLVED: [SLOEBER] program crashes

Development environment specific, Arduino, Eclipse, VS2013,Em::Blocks etc
User avatar
RogerClark
Posts: 6917
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: [SLOEBER] Sloeber problem, program crashes with call to malloc.

Post by RogerClark » Wed Aug 16, 2017 8:47 pm

Rick

You may be able to change the thread title.

Just edit the initial post. This does not change the titles on the replies but it does change what is seen in the listing in the container section.

If you can't change it, let me know and I will see what permissions need to be changed to allow moderators to do that.

User avatar
Rick Kimball
Posts: 1014
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: [SLOEBER] Sloeber problem, program crashes with call to malloc.

Post by Rick Kimball » Wed Aug 16, 2017 8:50 pm

@kostbill seems to have taken care of it Roger.

Thanks @kostbill
-rick

User avatar
RogerClark
Posts: 6917
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: [SLOEBER] Sloeber problem, program crashes with call to malloc.

Post by RogerClark » Wed Aug 16, 2017 8:53 pm

Ok. But it may still be worth testing if you have permission to do this,

I often have to put [SOLVED] into titles as people can't be bothered to do it themselves

victor_pv
Posts: 1654
Joined: Mon Apr 27, 2015 12:12 pm

Re: SOLVED: [SLOEBER] Sloeber problem, program crashes with call to malloc.

Post by victor_pv » Wed Aug 16, 2017 9:53 pm

Rick Kimball wrote:
Wed Aug 16, 2017 9:48 pm
Dudes, let's not hide the answer to this problem ...
Rick, I do have a question about the end symbol, related to this problem.
From what I see _sbrk() declared in syscalls.c does not use "end", in what file is the sbrk function that uses it?
I'm suspecting syscalls.c may not be included in the build, and I don't see any other declaration for sbrk in libmaple F1, so is it pulling an sbrk function from the standard library?
From your output seems like it's pulling it from libnosys.
In that case, when compiling in Arduino, is not pulling that and using the syscalls.c version?
I'm not at home and can't compile to confirm the above.

User avatar
Rick Kimball
Posts: 1014
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: SOLVED: [SLOEBER] Sloeber problem, program crashes with call to malloc.

Post by Rick Kimball » Wed Aug 16, 2017 10:37 pm

victor_pv wrote:
Wed Aug 16, 2017 9:53 pm
I'm suspecting syscalls.c may not be included in the build, and I don't see any other declaration for sbrk in libmaple F1, so is it pulling an sbrk function from the standard library?
Exactly right. As I mentioned above, Sloeber is using a different command line to link than what the Arduino IDE produces. So you end up using the libc _sbrk(). I'd show you the command line except I already uninstalled Sloeber from my eclipse setup.

For the record this is the one produced by the Arduino IDE:
"arm-none-eabi-g++" -Os -Wl,--gc-sections -mcpu=cortex-m3 "-T/home/kimballr/Arduino/hardware/stm32duino/STM32F1/variants/generic_stm32f103c/ld/jtag_c8.ld" "-Wl,-Map,/tmp/arduino_build_6110/malloc_test.ino.map" "-L/home/kimballr/Arduino/hardware/stm32duino/STM32F1/variants/generic_stm32f103c/ld" -o "/tmp/arduino_build_6110/malloc_test.ino.elf" "-L/tmp/arduino_build_6110" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "/tmp/arduino_build_6110/sketch/malloc_test.ino.cpp.o" "/tmp/arduino_build_6110/core/wirish/start.S.o" "/tmp/arduino_build_6110/core/wirish/start_c.c.o" "/tmp/arduino_build_6110/core/wirish/syscalls.c.o" "/tmp/arduino_build_6110/core/board.cpp.o" "/tmp/arduino_build_6110/core/wirish/boards.cpp.o" "/tmp/arduino_build_6110/core/wirish/boards_setup.cpp.o" "/tmp/arduino_build_6110/../arduino_cache_912348/core/core_stm32duino_STM32F1_genericSTM32F103C_device_variant_STM32F103C8,upload_method_STLinkMethod,cpu_speed_speed_72mhz,opt_osstd_755122cd08a3b2bdd89b2d83715e70db.a" -Wl,--end-group
Note that it uses the syscalls.c from variant/wirish not libc.
-rick

victor_pv
Posts: 1654
Joined: Mon Apr 27, 2015 12:12 pm

Re: SOLVED: [SLOEBER] program crashes with call to malloc.

Post by victor_pv » Thu Aug 17, 2017 2:49 am

I ran a compile with the F4 and the F1, and as with Pito, the F4 did not throw the error.
I looked at the differences, and esides the syscalls.c file having small differences, in the F4 is placed in a different folder, so I moved it over in the F1 to the same folder, but that did not make a difference.

Then I looked at the linker options, and the F4 is still using our old friend "--whole-archive", so I added that to the combiner recipe in the F1 and BAM! now it's linking syscalls correctly.
I wonder why the problem went away in the Arduino IDE, but is showing it's ugly face in Sloeber :(

So I suspect that several of the other functions in syscalls.c may not be included either.
I need to run the compile in Arduino IDE and see if the .text size is different. I'm pretty sure it is much larger with the whole-archive flag, but I wonder if it is smaller when that flag is not present and compiled in sloeber, since it's supposedly leaving things out.

User avatar
Rick Kimball
Posts: 1014
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: SOLVED: [SLOEBER] program crashes with call to malloc.

Post by Rick Kimball » Thu Aug 17, 2017 3:12 am

It looks like sloeber does some buid flag fixup in the java code for syscalls depending on the platform:
https://github.com/Sloeber/arduino-ecli ... .java#L650

It doesn't look like they are doing anything special for the stm32 architecture and they don't really care:
jantje wrote:"As I stated before: Feel free to add STM32 base support. In other words I'm not going to do it.
I'm wiling to support you in getting it done but you'll have to do it."
https://github.com/Sloeber/arduino-ecli ... t-73249687 ... status marked as "waiting for implementation"
-rick

User avatar
Rick Kimball
Posts: 1014
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: SOLVED: [SLOEBER] program crashes with call to malloc.

Post by Rick Kimball » Thu Aug 17, 2017 3:17 am

It really is difficult to support just the existing Arduino libmaple version on 3 different OSes with the huge number of boards we have. Adding another project's issues and release cycles is really a waste of our time.
-rick

User avatar
RogerClark
Posts: 6917
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: SOLVED: [SLOEBER] program crashes with call to malloc.

Post by RogerClark » Thu Aug 17, 2017 3:20 am

Rick

I think if someone is using an IDE other than the Arduino IDE, then we need to say that they need to get support from the forum for the IDE in question.

After all, the strap line I've had on the forum, from the beginning is "Everything relating to using STM32 boards with the Arduino IDE"

Anything else is just adding confusion and is Off Topic..

Edit. I"m going to edit the first post to link to what you found about Jantje's plugin

victor_pv
Posts: 1654
Joined: Mon Apr 27, 2015 12:12 pm

Re: SOLVED: [SLOEBER] program crashes

Post by victor_pv » Thu Aug 17, 2017 5:49 am

Interestingly enough, using one of the -LTO options in the board menu, the error disappear.
It's sad Sloeber has this problem, Eclipse is so much better than the Arduino IDE when working in the code.

Post Reply