Bus error 10 in Radix Tree C program

I'm writing a program which does operations on a Radix trie and I'm stuck at add() function, getting the Bus error 10.

void addRec(struct tNode *p, char *w) { int matches = prefixMatch(p->word,w); bool insert = true; if ((p == root) || ((matches > 0) && (matches < strlen(w)) && (matches == strlen(p->word)))) { char *updatedWord = &w[matches]; printf("%s\n", updatedWord); struct tNode *tmp = p->child; while (tmp != NULL) { if (tmp->word[0] == updatedWord[0]) { insert = false; addRec(tmp, updatedWord); } tmp = tmp->brother; } if (insert) { addChild(p,updatedWord); } } else if ((matches > 0) && (matches == strlen(w)) && (matches == strlen(p->word))) { if (p->count < 0) p->count = ++globalCount; else printf("ignored"); } else if ((matches > 0) && (matches < strlen(w)) && (matches < strlen(p->word))) { struct tNode *tmp = malloc(sizeof(struct tNode)); tmp->word = &p->word[matches]; p->word[matches+1] = ''; tmp->child = p->child; tmp->count = p->count; tmp->brother = NULL; p->child = tmp; p->count = -1; } }

The error appears to be somewhere inside the while loop but I can't figure out where and what's wrong exactly. Please help.

Category:c# Views:1 Time:2018-03-13
Tags: trie radix

Related post

  • Bus error in a simple C program 2012-01-20

    I am trying to reverse a C style string using the following simple program. #include "stdio.h" void reverse (char * str); int main (int argc , char* argv[]){ char *str = "hello"; reverse(str); return 0; } void reverse (char *str) { char *end = str; c

  • Getting a bus error in Assembly in-line programming x86 2012-04-25

    I stumbled upon an assembly programming challenge where I need to find why the following code gives a Bus Error when trying to run it. After much googling, I still can't figure out why.. My understanding of assembly x86 not great, any tips on finding

  • What is a bus error? 2008-10-17

    What does the "bus error" message mean, and how does it differ from a segfault? --------------Solutions------------- Bus errors are rare nowadays on x86 and occur when your processor cannot even attempt the memory access requested, typically: using a

  • Bus Error in cron job 2010-09-24

    I have set up a cron job for sending emails from my site using php. It was working fine. Today I got one error message like this "/bin/sh: line 1: 29681 Bus error". Could you please tell me what is this bus error and its solutions? Thanks In Advance

  • Bus error while running a simple string C program 2011-04-19

    I was running this simple program, the output i get is a "bus error". using some debugging statements i found the point at which it occurs was at the strcat() call. #include<stdio.h> #include<string.h> main() { char *s = "this is "; char

  • Bus Error - How can I find out where program died? 2011-06-12

    "Bus Error" doesn't tell me much so I want to access the core file to find out where it went wrong. I try to do this: (gdb) core core /this/is/my/directory/Program/core: No such file or directory (gdb) but it says there is no directory. I compile my

  • Why does the following C program give a bus error? 2010-12-18

    I think it's the very first strtok call that's failing. It's been a while since I've written C and I'm at a loss. Thanks very much. #include <stdio.h> #include <string.h> int main(int argc, char **argv) { char *str = "one|two|three"; char

  • Bus error vs Segmentation fault 2009-05-08

    Difference between a bus error and a segmentation fault? Can it happen that a program gives a seg fault and stops for the first time and for the second time it may give a bus error and exit ? --------------Solutions------------- On most architectures

  • C: Bus Error using different compilation arguments 2009-08-03

    So it's the third week of my life in C and I've been given the task of writing a program which takes in upto 100words which are upto 80characters long, calculates the average word length of the inputs, prints words larger than the average, and finall

  • Does unaligned memory access always cause bus errors? 2009-09-30

    According to the Wikipedia page Segmentation fault, a bus error can be caused by unaligned memory access. The article gives an example about how to trigger a bus error. In the example, we have to enable alignment checking to see the bus error. What i

  • Fortran bus error on mac 2009-12-28

    The following Fortran code is giving me a bus error on my Mac but no errors when I run it on my Linux machine: PROGRAM TINY WRITE(UNIT=*, FMT=*) 'Hello, world!' END My understanding is that a bus error occurs when the program attempts to access impos

  • How to get a "bus error"? 2010-01-15

    I am trying very hard to get a bus error. One way is misaligned access and I have tried the examples given here and here, but no error for me - the programs execute just fine. Is there some situation which is sure to produce a bus error? ------------

  • Bus error with semaphore func semctl() in this code running on Solaris 2010-02-14

    This is my first attempt on semaphores and threads. I constructed this code from examples and the man pages found on the Net. I have two doubts with this code. Why do I get a Bus error whenever I try semctl( I know this is the root of the problem bec

  • Why would I get a bus error or segmentation fault when calling free() normally? 2010-04-18

    I have a very simple test program, running on Solaris 5.8: #include <stdio.h> #include <stdlib.h> int main(void) { char *paths; paths = getenv("PATH"); printf("Paths: %s\n", paths); free(paths); // this causes a bus error return 0; } If I

  • std::cin >> *aa results in a bus error 2010-04-25

    I have this a class called PPString: PPString.h #ifndef __CPP_PPString #define __CPP_PPString #include "PPObject.h" class PPString : public PPObject { char *stringValue[]; public: char *pointerToCharString(); void setCharString(char *charString[]); v

  • arm-apple-darwin9-g++ Bus error problem 2010-05-13

    I want to create a mobilesubstrate plugin for iPhone OS 3.2 or I tried to setup toolchain on the iPad device. I have installed the iphone-gcc_4.2-20090304-1-9_iphoneos-arm package and all the relevant packages from Cydia, but when it comes to compili

  • Boost::Interprocess Shared Memory Bus Error 2010-06-23

    I'm using CentOS 5.4 x86_64 and Boost 1.42.0 on a cluster that uses Open-MPI 1.3.3. I'm writing a shared library that uses shared memory to store large amounts of data for multiple processes to use. There's also a loader application that will read in

  • C++ Map Gives Bus Error when trying to set a value 2010-06-29

    I have the following function as the constructor for a class: template<typename T> void Pointer<T>::Pointer(T* inPtr) { mPtr = inPtr; if (sRefCountMap.find(mPtr) == sRefCountMap.end()) { sRefCountMap[mPtr] = 1; } else { sRefCountMap[mPtr]

  • Python PIL ImageTk.PhotoImage() is giving me a bus error? 2010-07-05

    So I am running python 2.6 on a macbook pro and trying to write the code in python to display an image from a file in a label on a tkinter gui. The image is called image.png. The program runs without errors when I use this code i = Image.open("image.

  • Bus error when using GLUT 2010-07-31

    I am trying to create a GLUT application. Currently, I have this code: void init ( GLvoid ) // Create Some Everyday Functions { glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glClearDepth(1

  • help in solving Bus error c++ 2010-09-28

    hey, i am trying to compile a c++ program in Linux, using the command in the shell g++ -Wall *.cpp -o prog and for some reason it keeps on giving me a weird error: g++: Internal error: Bus error (program cc1plus) Please submit a full bug report. See

  • Bus Error just by launching the haxe commando in OSX Terminal 2010-11-12

    I wanted to do again to develop in haxe on my MacBook after quite a long time. So I go on haxe.org, download the mac installer and install the latest version of haxe with it. Then I open the terminal and type haxe, just to encounter this short error

  • Fortran Bus Error When Modifying Parameter 2010-12-13

    Whenever I assign a new value to a parameter, I get a bus error. I don't see how I'm pointing to non-existant memory. I should have access to this address, as it is declared in the parameter list, unless Fortran does not allow parameters to be modifi

  • Bus error when recompiling the binary 2011-03-10

    Sometimes, on various Unix architectures, recompiling a program while it is running causes the program to crash with a "Bus error". Can anyone explain under which conditions this happens? First, how can updating the binary on disk do anything to the

  • Bus Error on Intel Mac, why? 2011-03-21

    Test program which causes a EXC_BAD_ACCESS signal. Why does this cause a bus error? I want to change the 'HI' to 'fI'. //BUS ERROR TEST #include <iostream> void test(char *text) { text[0] = 'f'; } int main() { char *text = (char *)"HI"; test(te

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.263 (s). 11 q(s)